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

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

本文整理了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

  1. public static void createChildren(HelixZkClient client, String parentPath, List<ZNRecord> list) {
  2. client.createPersistent(parentPath, true);
  3. if (list != null) {
  4. for (ZNRecord record : list) {
  5. createChildren(client, parentPath, record);
  6. }
  7. }
  8. }

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

  1. public static void createChildren(ZkClient client, String parentPath, List<ZNRecord> list) {
  2. client.createPersistent(parentPath, true);
  3. if (list != null) {
  4. for (ZNRecord record : list) {
  5. createChildren(client, parentPath, record);
  6. }
  7. }
  8. }

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

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

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

  1. @Override
  2. public void addResource(String clusterName, String resourceName, IdealState idealstate) {
  3. logger.info("Add resource {} in cluster {}.", resourceName, clusterName);
  4. String stateModelRef = idealstate.getStateModelDefRef();
  5. String stateModelDefPath = PropertyPathBuilder.stateModelDef(clusterName, stateModelRef);
  6. if (!_zkClient.exists(stateModelDefPath)) {
  7. throw new HelixException(
  8. "State model " + stateModelRef + " not found in the cluster STATEMODELDEFS path");
  9. }
  10. String idealStatePath = PropertyPathBuilder.idealState(clusterName);
  11. String resourceIdealStatePath = idealStatePath + "/" + resourceName;
  12. if (_zkClient.exists(resourceIdealStatePath)) {
  13. throw new HelixException("Skip the operation. Resource ideal state directory already exists:"
  14. + resourceIdealStatePath);
  15. }
  16. ZKUtil.createChildren(_zkClient, idealStatePath, idealstate.getRecord());
  17. }

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

  1. @Override
  2. public void addResource(String clusterName, String resourceName,
  3. IdealState idealstate) {
  4. logger.info("Add resource {} in cluster {}.", resourceName, clusterName);
  5. String stateModelRef = idealstate.getStateModelDefRef();
  6. String stateModelDefPath = PropertyPathBuilder.stateModelDef(clusterName, stateModelRef);
  7. if (!_zkClient.exists(stateModelDefPath)) {
  8. throw new HelixException(
  9. "State model " + stateModelRef + " not found in the cluster STATEMODELDEFS path");
  10. }
  11. String idealStatePath = PropertyPathBuilder.idealState(clusterName);
  12. String resourceIdealStatePath = idealStatePath + "/" + resourceName;
  13. if (_zkClient.exists(resourceIdealStatePath)) {
  14. throw new HelixException("Skip the operation. Resource ideal state directory already exists:"
  15. + resourceIdealStatePath);
  16. }
  17. ZKUtil.createChildren(_zkClient, idealStatePath, idealstate.getRecord());
  18. }

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

  1. @Test()
  2. public void testChildrenOperations() {
  3. List<ZNRecord> list = new ArrayList<ZNRecord>();
  4. list.add(new ZNRecord("id1"));
  5. list.add(new ZNRecord("id2"));
  6. String path = PropertyPathBuilder.instanceConfig(clusterName);
  7. ZKUtil.createChildren(_gZkClient, path, list);
  8. list = ZKUtil.getChildren(_gZkClient, path);
  9. AssertJUnit.assertEquals(2, list.size());
  10. ZKUtil.dropChildren(_gZkClient, path, list);
  11. ZKUtil.dropChildren(_gZkClient, path, new ZNRecord("id1"));
  12. list = ZKUtil.getChildren(_gZkClient, path);
  13. AssertJUnit.assertEquals(0, list.size());
  14. ZKUtil.dropChildren(_gZkClient, path, (List<ZNRecord>) null);
  15. }

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

  1. @Override
  2. public void addInstance(String clusterName, InstanceConfig instanceConfig) {
  3. logger.info("Add instance {} to cluster {}.", instanceConfig.getInstanceName(), clusterName);
  4. if (!ZKUtil.isClusterSetup(clusterName, _zkClient)) {
  5. throw new HelixException("cluster " + clusterName + " is not setup yet");
  6. }
  7. String instanceConfigsPath = PropertyPathBuilder.instanceConfig(clusterName);
  8. String nodeId = instanceConfig.getId();
  9. String instanceConfigPath = instanceConfigsPath + "/" + nodeId;
  10. if (_zkClient.exists(instanceConfigPath)) {
  11. throw new HelixException("Node " + nodeId + " already exists in cluster " + clusterName);
  12. }
  13. ZKUtil.createChildren(_zkClient, instanceConfigsPath, instanceConfig.getRecord());
  14. _zkClient.createPersistent(PropertyPathBuilder.instanceMessage(clusterName, nodeId), true);
  15. _zkClient.createPersistent(PropertyPathBuilder.instanceCurrentState(clusterName, nodeId), true);
  16. _zkClient.createPersistent(PropertyPathBuilder.instanceError(clusterName, nodeId), true);
  17. _zkClient.createPersistent(PropertyPathBuilder.instanceStatusUpdate(clusterName, nodeId), true);
  18. _zkClient.createPersistent(PropertyPathBuilder.instanceHistory(clusterName, nodeId), true);
  19. }

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

  1. @Override
  2. public void addInstance(String clusterName, InstanceConfig instanceConfig) {
  3. logger.info("Add instance {} to cluster {}.", instanceConfig.getInstanceName(), clusterName);
  4. if (!ZKUtil.isClusterSetup(clusterName, _zkClient)) {
  5. throw new HelixException("cluster " + clusterName + " is not setup yet");
  6. }
  7. String instanceConfigsPath = PropertyPathBuilder.instanceConfig(clusterName);
  8. String nodeId = instanceConfig.getId();
  9. String instanceConfigPath = instanceConfigsPath + "/" + nodeId;
  10. if (_zkClient.exists(instanceConfigPath)) {
  11. throw new HelixException("Node " + nodeId + " already exists in cluster " + clusterName);
  12. }
  13. ZKUtil.createChildren(_zkClient, instanceConfigsPath, instanceConfig.getRecord());
  14. _zkClient.createPersistent(PropertyPathBuilder.instanceMessage(clusterName, nodeId), true);
  15. _zkClient.createPersistent(PropertyPathBuilder.instanceCurrentState(clusterName, nodeId), true);
  16. _zkClient.createPersistent(PropertyPathBuilder.instanceError(clusterName, nodeId), true);
  17. _zkClient.createPersistent(PropertyPathBuilder.instanceStatusUpdate(clusterName, nodeId), true);
  18. _zkClient.createPersistent(PropertyPathBuilder.instanceHistory(clusterName, nodeId), true);
  19. }

相关文章