2016-11-03 122 views
0

对于我的测试,我正在使用Zookeeper测试服务器,但我希望能够等到服务器完全启动(因为我将它作为测试init进程的一部分启动)。如何使用Curator检查Zookeeper服务器是否已启动?

如何可以干净地检查使用Curator正确启动(Test)Zookeeper服务器?某种形式的ping/etc?

回答

1

我设法找到答案并希望分享。

策展人有一个方法blockUntilConnected它将等待,直到它从Zookeeper获得连接。

CuratorFramework curator = CuratorFrameworkFactory.newClient("localhost:" + TestConstants.TEST_ZOOKEEPER_PORT, new RetryOneTime(100)); 
curator.start(); 
curator.blockUntilConnected(); 
相关问题