org.apache.helix.manager.zk.ZKUtil.createChildren()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(5.8k)|赞(0)|评价(0)|浏览(108)

本文整理了Java中org.apache.helix.manager.zk.ZKUtil.createChildren()方法的一些代码示例,展示了ZKUtil.createChildren()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKUtil.createChildren()方法的具体详情如下:
包路径:org.apache.helix.manager.zk.ZKUtil
类名称:ZKUtil
方法名:createChildren

ZKUtil.createChildren介绍

暂无

代码示例

代码示例来源:origin: apache/helix

public static void createChildren(HelixZkClient client, String parentPath, List<ZNRecord> list) {
 client.createPersistent(parentPath, true);
 if (list != null) {
  for (ZNRecord record : list) {
   createChildren(client, parentPath, record);
  }
 }
}

代码示例来源:origin: org.apache.helix/helix-core

public static void createChildren(ZkClient client, String parentPath, List<ZNRecord> list) {
 client.createPersistent(parentPath, true);
 if (list != null) {
  for (ZNRecord record : list) {
   createChildren(client, parentPath, record);
  }
 }
}

代码示例来源:origin: apache/helix

@Test()
public void testNullChildren() {
 String path = PropertyPathBuilder.instanceConfig(clusterName, "id6");
 ZKUtil.createChildren(_gZkClient, path, (List<ZNRecord>) null);
}

代码示例来源:origin: apache/helix

@Override
public void addResource(String clusterName, String resourceName, IdealState idealstate) {
 logger.info("Add resource {} in cluster {}.", resourceName, clusterName);
 String stateModelRef = idealstate.getStateModelDefRef();
 String stateModelDefPath = PropertyPathBuilder.stateModelDef(clusterName, stateModelRef);
 if (!_zkClient.exists(stateModelDefPath)) {
  throw new HelixException(
    "State model " + stateModelRef + " not found in the cluster STATEMODELDEFS path");
 }
 String idealStatePath = PropertyPathBuilder.idealState(clusterName);
 String resourceIdealStatePath = idealStatePath + "/" + resourceName;
 if (_zkClient.exists(resourceIdealStatePath)) {
  throw new HelixException("Skip the operation. Resource ideal state directory already exists:"
    + resourceIdealStatePath);
 }
 ZKUtil.createChildren(_zkClient, idealStatePath, idealstate.getRecord());
}

代码示例来源:origin: org.apache.helix/helix-core

@Override
public void addResource(String clusterName, String resourceName,
  IdealState idealstate) {
 logger.info("Add resource {} in cluster {}.", resourceName, clusterName);
 String stateModelRef = idealstate.getStateModelDefRef();
 String stateModelDefPath = PropertyPathBuilder.stateModelDef(clusterName, stateModelRef);
 if (!_zkClient.exists(stateModelDefPath)) {
  throw new HelixException(
    "State model " + stateModelRef + " not found in the cluster STATEMODELDEFS path");
 }
 String idealStatePath = PropertyPathBuilder.idealState(clusterName);
 String resourceIdealStatePath = idealStatePath + "/" + resourceName;
 if (_zkClient.exists(resourceIdealStatePath)) {
  throw new HelixException("Skip the operation. Resource ideal state directory already exists:"
    + resourceIdealStatePath);
 }
 ZKUtil.createChildren(_zkClient, idealStatePath, idealstate.getRecord());
}

代码示例来源: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: apache/helix

@Override
public void addInstance(String clusterName, InstanceConfig instanceConfig) {
 logger.info("Add instance {} to cluster {}.", instanceConfig.getInstanceName(), clusterName);
 if (!ZKUtil.isClusterSetup(clusterName, _zkClient)) {
  throw new HelixException("cluster " + clusterName + " is not setup yet");
 }
 String instanceConfigsPath = PropertyPathBuilder.instanceConfig(clusterName);
 String nodeId = instanceConfig.getId();
 String instanceConfigPath = instanceConfigsPath + "/" + nodeId;
 if (_zkClient.exists(instanceConfigPath)) {
  throw new HelixException("Node " + nodeId + " already exists in cluster " + clusterName);
 }
 ZKUtil.createChildren(_zkClient, instanceConfigsPath, instanceConfig.getRecord());
 _zkClient.createPersistent(PropertyPathBuilder.instanceMessage(clusterName, nodeId), true);
 _zkClient.createPersistent(PropertyPathBuilder.instanceCurrentState(clusterName, nodeId), true);
 _zkClient.createPersistent(PropertyPathBuilder.instanceError(clusterName, nodeId), true);
 _zkClient.createPersistent(PropertyPathBuilder.instanceStatusUpdate(clusterName, nodeId), true);
 _zkClient.createPersistent(PropertyPathBuilder.instanceHistory(clusterName, nodeId), true);
}

代码示例来源:origin: org.apache.helix/helix-core

@Override
public void addInstance(String clusterName, InstanceConfig instanceConfig) {
 logger.info("Add instance {} to cluster {}.", instanceConfig.getInstanceName(), clusterName);
 if (!ZKUtil.isClusterSetup(clusterName, _zkClient)) {
  throw new HelixException("cluster " + clusterName + " is not setup yet");
 }
 String instanceConfigsPath = PropertyPathBuilder.instanceConfig(clusterName);
 String nodeId = instanceConfig.getId();
 String instanceConfigPath = instanceConfigsPath + "/" + nodeId;
 if (_zkClient.exists(instanceConfigPath)) {
  throw new HelixException("Node " + nodeId + " already exists in cluster " + clusterName);
 }
 ZKUtil.createChildren(_zkClient, instanceConfigsPath, instanceConfig.getRecord());
 _zkClient.createPersistent(PropertyPathBuilder.instanceMessage(clusterName, nodeId), true);
 _zkClient.createPersistent(PropertyPathBuilder.instanceCurrentState(clusterName, nodeId), true);
 _zkClient.createPersistent(PropertyPathBuilder.instanceError(clusterName, nodeId), true);
 _zkClient.createPersistent(PropertyPathBuilder.instanceStatusUpdate(clusterName, nodeId), true);
 _zkClient.createPersistent(PropertyPathBuilder.instanceHistory(clusterName, nodeId), true);
}

相关文章