@Test
public void testClientRetry() throws IOException, InterruptedException, TimeoutException{
CountdownWatcher cdw1 = new CountdownWatcher();
CountdownWatcher cdw2 = new CountdownWatcher();
ZooKeeper zk = new ZooKeeper(hostPort, 10000, cdw1);
try {
cdw1.waitForConnected(CONNECTION_TIMEOUT);
ZooKeeper zk2 = new ZooKeeper(hostPort, 10000, cdw2);
try {
States s1 = zk.getState();
States s2 = zk2.getState();
Assert.assertSame(s1,States.CONNECTED);
Assert.assertSame(s2,States.CONNECTING);
cdw1.reset();
cdw1.waitForDisconnected(CONNECTION_TIMEOUT);
cdw2.waitForConnected(CONNECTION_TIMEOUT);
Assert.assertSame(zk2.getState(),States.CONNECTED);
} finally {
zk2.close();
}
} finally {
zk.close();
}
}
ClientRetry.java 文件源码
java
阅读 33
收藏 0
点赞 0
评论 0
项目:ZooKeeper
作者:
评论列表
文章目录