CommitRateLimiter implements CommitHook { public void setDelay(long delay) { if (LOG.isTraceEnabled()) { if (this.delay != delay) { LOG.trace("setDelay: delay changed from " + this.delay + " to " + delay); } } this.delay = delay; if (delay == 0) { synchronized (this) { this.notifyAll(); } } }  void blockCommits(); void unblockCommits(); boolean getBlockCommits(); void setDelay(long delay); @NotNull @Override NodeState processCommit(NodeState before, NodeState after, CommitInfo info); void blockCommit(); void beforeNonBlocking(); void afterNonBlocking(); boolean isThreadBlocking();  }
@Test public void delayCommitsWithReset() throws InterruptedException, ExecutionException, TimeoutException { limiter.setDelay(10000); new Thread(commit).start(); limiter.setDelay(0); assertTrue(commit.get(1, TimeUnit.SECONDS) >= 100); }
@Test(expected = ExecutionException.class) public void delayCommitsWithInterrupt() throws InterruptedException, ExecutionException, TimeoutException { limiter.setDelay(10000); Thread t = new Thread(commit); t.start(); t.interrupt(); commit.get(1, TimeUnit.SECONDS); }