本文整理了Java中org.apache.helix.manager.zk.ZKUtil.dropChildren()
方法的一些代码示例,展示了ZKUtil.dropChildren()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKUtil.dropChildren()
方法的具体详情如下:
包路径:org.apache.helix.manager.zk.ZKUtil
类名称:ZKUtil
方法名:dropChildren
暂无
代码示例来源:origin: org.apache.helix/helix-core
public static void dropChildren(ZkClient client, String parentPath, List<ZNRecord> list) {
// TODO: check if parentPath exists
if (list != null) {
for (ZNRecord record : list) {
dropChildren(client, parentPath, record);
}
}
}
代码示例来源:origin: apache/helix
public static void dropChildren(HelixZkClient client, String parentPath, List<ZNRecord> list) {
// TODO: check if parentPath exists
if (list != null) {
for (ZNRecord record : list) {
dropChildren(client, parentPath, record);
}
}
}
代码示例来源:origin: apache/helix
@Test()
public void testChildrenOperations() {
List<ZNRecord> list = new ArrayList<ZNRecord>();
list.add(new ZNRecord("id1"));
list.add(new ZNRecord("id2"));
String path = PropertyPathBuilder.instanceConfig(clusterName);
ZKUtil.createChildren(_gZkClient, path, list);
list = ZKUtil.getChildren(_gZkClient, path);
AssertJUnit.assertEquals(2, list.size());
ZKUtil.dropChildren(_gZkClient, path, list);
ZKUtil.dropChildren(_gZkClient, path, new ZNRecord("id1"));
list = ZKUtil.getChildren(_gZkClient, path);
AssertJUnit.assertEquals(0, list.size());
ZKUtil.dropChildren(_gZkClient, path, (List<ZNRecord>) null);
}
代码示例来源:origin: org.apache.helix/helix-core
@Override
public void dropInstance(String clusterName, InstanceConfig instanceConfig) {
logger.info("Drop instance {} from cluster {}.", instanceConfig.getInstanceName(), clusterName);
String instanceName = instanceConfig.getInstanceName();
String instanceConfigPath = PropertyPathBuilder.instanceConfig(clusterName, instanceName);
if (!_zkClient.exists(instanceConfigPath)) {
throw new HelixException(
"Node " + instanceName + " does not exist in config for cluster " + clusterName);
}
String instancePath = PropertyPathBuilder.instance(clusterName, instanceName);
if (!_zkClient.exists(instancePath)) {
throw new HelixException(
"Node " + instanceName + " does not exist in instances for cluster " + clusterName);
}
String liveInstancePath = PropertyPathBuilder.liveInstance(clusterName, instanceName);
if (_zkClient.exists(liveInstancePath)) {
throw new HelixException(
"Node " + instanceName + " is still alive for cluster " + clusterName + ", can't drop.");
}
// delete config path
String instanceConfigsPath = PropertyPathBuilder.instanceConfig(clusterName);
ZKUtil.dropChildren(_zkClient, instanceConfigsPath, instanceConfig.getRecord());
// delete instance path
_zkClient.deleteRecursively(instancePath);
}
代码示例来源:origin: apache/helix
@Override
public void dropInstance(String clusterName, InstanceConfig instanceConfig) {
logger.info("Drop instance {} from cluster {}.", instanceConfig.getInstanceName(), clusterName);
String instanceName = instanceConfig.getInstanceName();
String instanceConfigPath = PropertyPathBuilder.instanceConfig(clusterName, instanceName);
if (!_zkClient.exists(instanceConfigPath)) {
throw new HelixException(
"Node " + instanceName + " does not exist in config for cluster " + clusterName);
}
String instancePath = PropertyPathBuilder.instance(clusterName, instanceName);
if (!_zkClient.exists(instancePath)) {
throw new HelixException(
"Node " + instanceName + " does not exist in instances for cluster " + clusterName);
}
String liveInstancePath = PropertyPathBuilder.liveInstance(clusterName, instanceName);
if (_zkClient.exists(liveInstancePath)) {
throw new HelixException(
"Node " + instanceName + " is still alive for cluster " + clusterName + ", can't drop.");
}
// delete config path
String instanceConfigsPath = PropertyPathBuilder.instanceConfig(clusterName);
ZKUtil.dropChildren(_zkClient, instanceConfigsPath, instanceConfig.getRecord());
// delete instance path
_zkClient.deleteRecursively(instancePath);
}
内容来源于网络,如有侵权,请联系作者删除!