@Test public void rapidChanges() throws Exception { final int maxPropagationTime = 100; final String pathPrefix = "/foo/rapido"; curator.create().creatingParentsIfNeeded().forPath(pathPrefix); final int numNodes = 50; final ListenerCounter listener = new ListenerCounter(numNodes, 0, numNodes); final NodeCollectionWatcher nodeCollectionWatcher = new NodeCollectionWatcher(zooKeeper, pathPrefix, listener); for (int i = 0; i < numNodes; i++) { curator.create().forPath(pathPrefix + "/node" + i, getData()); } assertTrue(listener.createLatch.await(maxPropagationTime, TimeUnit.MILLISECONDS)); assertThat(listener.createCount.get(), is(numNodes)); assertThat(listener.dataCount.get(), is(0)); assertThat(listener.removeCount.get(), is(0)); int total = 0; for (int j = 0; j < 5; j++) { listener.dataLatch = new CountDownLatch(numNodes); for (int i = 0; i < numNodes; i++) { curator.setData().forPath(pathPrefix + "/node" + i, getData()); } total += numNodes; assertTrue(listener.dataLatch.await(maxPropagationTime, TimeUnit.MILLISECONDS)); assertThat(listener.createCount.get(), is(numNodes)); assertThat(listener.dataCount.get(), is(total)); assertThat(listener.removeCount.get(), is(0)); } for (int i = 0; i < numNodes; i++) { curator.delete().forPath(pathPrefix + "/node" + i); } assertTrue(listener.removeLatch.await(maxPropagationTime, TimeUnit.MILLISECONDS)); assertThat(listener.createCount.get(), is(numNodes)); assertThat(listener.dataCount.get(), is(total)); assertThat(listener.removeCount.get(), is(numNodes)); nodeCollectionWatcher.shutdown(); }
public void shutdown() { shuttingDown.set(true); }
NodeCollectionWatcher { public void shutdown() { shuttingDown.set(true); } }
NodeCollectionWatcher { public void shutdown() { shuttingDown.set(true); } NodeCollectionWatcher(
            final ZooKeeper zk, final String pathToWatch, final NodeWatcherListener listener); }
NodeCollectionWatcher { public void shutdown() { shuttingDown.set(true); } NodeCollectionWatcher(
            final ZooKeeper zk, final String pathToWatch, final NodeWatcherListener listener); void shutdown(); }
NodeCollectionWatcher { public void shutdown() { shuttingDown.set(true); } NodeCollectionWatcher(
            final ZooKeeper zk, final String pathToWatch, final NodeWatcherListener listener); void shutdown();  }