本文整理了Java中org.apache.helix.manager.zk.ZkClient.createEphemeral()
方法的一些代码示例,展示了ZkClient.createEphemeral()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZkClient.createEphemeral()
方法的具体详情如下:
包路径:org.apache.helix.manager.zk.ZkClient
类名称:ZkClient
方法名:createEphemeral
暂无
代码示例来源:origin: org.apache.helix/helix-core
zkClient.createEphemeral("/" + clusterName + "/CONFIGS/CLUSTER/verify");
} catch (ZkNodeExistsException ex) {
LOG.error("There is already a verification in progress", ex);
代码示例来源:origin: apache/helix
@Test
public void testCloseZkClient() {
String className = TestHelper.getTestClassName();
String methodName = TestHelper.getTestMethodName();
String clusterName = className + "_" + methodName;
System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis()));
ZkClient client =
new ZkClient(ZK_ADDR, HelixZkClient.DEFAULT_SESSION_TIMEOUT,
HelixZkClient.DEFAULT_CONNECTION_TIMEOUT, new ZNRecordSerializer());
String path = String.format("/%s", clusterName);
client.createEphemeral(path);
client.close();
Assert.assertFalse(_gZkClient.exists(path), "Ephemeral node: " + path
+ " should be removed after ZkClient#close()");
System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis()));
}
代码示例来源:origin: apache/helix
@Test
public void testZkSessionExpiry() throws Exception {
String className = TestHelper.getTestClassName();
String methodName = TestHelper.getTestMethodName();
String clusterName = className + "_" + methodName;
System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis()));
ZkClient client =
new ZkClient(ZK_ADDR, HelixZkClient.DEFAULT_SESSION_TIMEOUT,
HelixZkClient.DEFAULT_CONNECTION_TIMEOUT, new ZNRecordSerializer());
String path = String.format("/%s", clusterName);
client.createEphemeral(path);
String oldSessionId = ZkTestHelper.getSessionId(client);
ZkTestHelper.expireSession(client);
String newSessionId = ZkTestHelper.getSessionId(client);
Assert.assertNotSame(newSessionId, oldSessionId);
Assert.assertFalse(client.exists(path), "Ephemeral znode should be gone after session expiry");
client.close();
System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis()));
}
代码示例来源:origin: apache/helix
@Test
public void testCloseZkClientInZkClientEventThread() throws Exception {
String className = TestHelper.getTestClassName();
String methodName = TestHelper.getTestMethodName();
String clusterName = className + "_" + methodName;
System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis()));
final CountDownLatch waitCallback = new CountDownLatch(1);
final ZkClient client =
new ZkClient(ZK_ADDR, HelixZkClient.DEFAULT_SESSION_TIMEOUT,
HelixZkClient.DEFAULT_CONNECTION_TIMEOUT, new ZNRecordSerializer());
String path = String.format("/%s", clusterName);
client.createEphemeral(path);
client.subscribeDataChanges(path, new IZkDataListener() {
@Override
public void handleDataDeleted(String dataPath) throws Exception {
}
@Override
public void handleDataChange(String dataPath, Object data) throws Exception {
client.close();
waitCallback.countDown();
}
});
client.writeData(path, new ZNRecord("test"));
waitCallback.await();
Assert.assertFalse(_gZkClient.exists(path), "Ephemeral node: " + path
+ " should be removed after ZkClient#close() in its own event-thread");
System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis()));
}
代码示例来源:origin: org.apache.helix/helix-core
retry = false;
try {
_zkclient.createEphemeral(liveInstancePath, liveInstance.getRecord());
LOG.info("LiveInstance created, path: " + liveInstancePath + ", sessionId: " + liveInstance.getSessionId());
} catch (ZkNodeExistsException e) {
_zkclient.createEphemeral(liveInstancePath, liveInstance.getRecord());
LOG.info("LiveInstance created, path: " + liveInstancePath + ", sessionId: " + liveInstance.getSessionId());
} catch (Exception e) {
内容来源于网络,如有侵权,请联系作者删除!