{
@Override
public List<Integer> call() throws Exception
{
final List<Integer> countList = Lists.newArrayList();
CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
clients.add(client);
client.start();
SharedCount count = new SharedCount(client, "/count", 10);
counts.add(count);
final CountDownLatch latch = new CountDownLatch(1);
count.addListener
(
new SharedCountListener()
{
@Override
public void countHasChanged(SharedCountReader sharedCount, int newCount) throws Exception
{
if ( newCount < 0 )
{
latch.countDown();
}
else
{
countList.add(newCount);
}
semaphore.release();
}
@Override
public void stateChanged(CuratorFramework client, ConnectionState newState)
{
}
}
);
count.start();
startLatch.countDown();
latch.await();
return countList;
}
}
);
futures.add(future);
}
CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
clients.add(client);
client.start();
Assert.assertTrue(startLatch.await(10, TimeUnit.SECONDS));