@Override protected void after() { if(!initializeOnce) { zookeeperStarter.stop(); } else { zookeeperStarter.registerShutdownHook(); } }
@Override public void run() { Starter.this.stop(); } });
public void untilZookeeperPathIsCreated(String... path) { untilZookeeperPathIsCreated(stream(path).collect(joining("/"))); }
public void untilZookeeperPathNotExists(String... path) { untilZookeeperPathNotExists(stream(path).collect(joining("/"))); }
public CuratorFramework curator() { return zookeeperStarter.curator(); }
public void untilZookeeperClientStopped() { this.untilZookeeperClientStopped(zookeeper); }
public void untilZookeeperClientStarted() { this.untilZookeeperClientStarted(zookeeper); }
public void untilZookeeperPathIsEmpty(String... path) { untilZookeeperPathIsEmpty(stream(path).collect(joining("/"))); } }
private Subscription forceAssignment(Subscription sub) { workTracker.forceAssignment(sub); wait.untilZookeeperPathIsCreated(basePath, sub.getQualifiedName().toString(), supervisorId); return sub; }
@Override protected void after() { if(!initializeOnce) { zookeeperStarter.stop(); } else { zookeeperStarter.registerShutdownHook(); } }
private Subscription dropAssignment(Subscription sub) { workTracker.dropAssignment(sub); wait.untilZookeeperPathNotExists(basePath, sub.getQualifiedName().toString(), supervisorId); return sub; } }
public CuratorFramework curator() { return zookeeperStarter.curator(); }
@Override public void run() { Starter.this.stop(); } });
public void untilZookeeperClientStopped() { this.untilZookeeperClientStopped(zookeeper); }
public void untilZookeeperClientStarted() { this.untilZookeeperClientStarted(zookeeper); }
public void untilZookeeperPathIsEmpty(String... path) { untilZookeeperPathIsEmpty(stream(path).collect(joining("/"))); } }
@Test public void shouldIncrementCounterAtomicallyWhenIncrementedConcurrently() { // given SharedCounter otherCounter = new SharedCounter(zookeeperClient, 72 * 3600, 1000, 3); // when counter.increment("/sharedIncrement", 10); otherCounter.increment("/sharedIncrement", 15); wait.untilZookeeperPathIsCreated("/sharedIncrement"); // then assertThat(counter.getValue("/sharedIncrement")).isEqualTo(25); }