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

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

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

ZKUtil.createOrReplace介绍

暂无

代码示例

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

  1. @Test()
  2. public void testCreateOrReplace() {
  3. String path = PropertyPathBuilder.instanceConfig(clusterName, "id8");
  4. ZNRecord record = new ZNRecord("id8");
  5. ZKUtil.createOrReplace(_gZkClient, path, record, true);
  6. record = _gZkClient.readData(path);
  7. AssertJUnit.assertEquals("id8", record.getId());
  8. record = new ZNRecord("id9");
  9. ZKUtil.createOrReplace(_gZkClient, path, record, true);
  10. record = _gZkClient.readData(path);
  11. AssertJUnit.assertEquals("id9", record.getId());
  12. }

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

  1. private void updateClusterConfig(String clusterName, ClusterConfig clusterConfig, boolean overwrite) {
  2. if (!ZKUtil.isClusterSetup(clusterName, zkClient)) {
  3. throw new HelixException("fail to update config. cluster: " + clusterName + " is NOT setup.");
  4. }
  5. HelixConfigScope scope =
  6. new HelixConfigScopeBuilder(ConfigScopeProperty.CLUSTER).forCluster(clusterName).build();
  7. String zkPath = scope.getZkPath();
  8. if (overwrite) {
  9. ZKUtil.createOrReplace(zkClient, zkPath, clusterConfig.getRecord(), true);
  10. } else {
  11. ZKUtil.createOrUpdate(zkClient, zkPath, clusterConfig.getRecord(), true, true);
  12. }
  13. }

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

  1. private void updateClusterConfig(String clusterName, ClusterConfig clusterConfig, boolean overwrite) {
  2. if (!ZKUtil.isClusterSetup(clusterName, zkClient)) {
  3. throw new HelixException("fail to update config. cluster: " + clusterName + " is NOT setup.");
  4. }
  5. HelixConfigScope scope =
  6. new HelixConfigScopeBuilder(ConfigScopeProperty.CLUSTER).forCluster(clusterName).build();
  7. String zkPath = scope.getZkPath();
  8. if (overwrite) {
  9. ZKUtil.createOrReplace(zkClient, zkPath, clusterConfig.getRecord(), true);
  10. } else {
  11. ZKUtil.createOrUpdate(zkClient, zkPath, clusterConfig.getRecord(), true, true);
  12. }
  13. }

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

  1. private void updateInstanceConfig(String clusterName, String instanceName,
  2. InstanceConfig instanceConfig, boolean overwrite) {
  3. if (!ZKUtil.isClusterSetup(clusterName, zkClient)) {
  4. throw new HelixException("fail to setup config. cluster: " + clusterName + " is NOT setup.");
  5. }
  6. HelixConfigScope scope =
  7. new HelixConfigScopeBuilder(ConfigScopeProperty.PARTICIPANT).forCluster(clusterName)
  8. .forParticipant(instanceName).build();
  9. String zkPath = scope.getZkPath();
  10. if (overwrite) {
  11. ZKUtil.createOrReplace(zkClient, zkPath, instanceConfig.getRecord(), true);
  12. } else {
  13. ZKUtil.createOrUpdate(zkClient, zkPath, instanceConfig.getRecord(), true, true);
  14. }
  15. }
  16. }

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

  1. private void updateResourceConfig(String clusterName, String resourceName,
  2. ResourceConfig resourceConfig, boolean overwrite) {
  3. if (!ZKUtil.isClusterSetup(clusterName, zkClient)) {
  4. throw new HelixException("fail to setup config. cluster: " + clusterName + " is NOT setup.");
  5. }
  6. HelixConfigScope scope =
  7. new HelixConfigScopeBuilder(ConfigScopeProperty.RESOURCE).forCluster(clusterName)
  8. .forResource(resourceName).build();
  9. String zkPath = scope.getZkPath();
  10. if (overwrite) {
  11. ZKUtil.createOrReplace(zkClient, zkPath, resourceConfig.getRecord(), true);
  12. } else {
  13. ZKUtil.createOrUpdate(zkClient, zkPath, resourceConfig.getRecord(), true, true);
  14. }
  15. }

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

  1. private void updateResourceConfig(String clusterName, String resourceName,
  2. ResourceConfig resourceConfig, boolean overwrite) {
  3. if (!ZKUtil.isClusterSetup(clusterName, zkClient)) {
  4. throw new HelixException("fail to setup config. cluster: " + clusterName + " is NOT setup.");
  5. }
  6. HelixConfigScope scope =
  7. new HelixConfigScopeBuilder(ConfigScopeProperty.RESOURCE).forCluster(clusterName)
  8. .forResource(resourceName).build();
  9. String zkPath = scope.getZkPath();
  10. if (overwrite) {
  11. ZKUtil.createOrReplace(zkClient, zkPath, resourceConfig.getRecord(), true);
  12. } else {
  13. ZKUtil.createOrUpdate(zkClient, zkPath, resourceConfig.getRecord(), true, true);
  14. }
  15. }

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

  1. private void updateInstanceConfig(String clusterName, String instanceName,
  2. InstanceConfig instanceConfig, boolean overwrite) {
  3. if (!ZKUtil.isClusterSetup(clusterName, zkClient)) {
  4. throw new HelixException("fail to setup config. cluster: " + clusterName + " is NOT setup.");
  5. }
  6. HelixConfigScope scope =
  7. new HelixConfigScopeBuilder(ConfigScopeProperty.PARTICIPANT).forCluster(clusterName)
  8. .forParticipant(instanceName).build();
  9. String zkPath = scope.getZkPath();
  10. if (!zkClient.exists(zkPath)) {
  11. throw new HelixException(
  12. "updateInstanceConfig failed. Given InstanceConfig does not already exist. instance: "
  13. + instanceName);
  14. }
  15. if (overwrite) {
  16. ZKUtil.createOrReplace(zkClient, zkPath, instanceConfig.getRecord(), true);
  17. } else {
  18. ZKUtil.createOrUpdate(zkClient, zkPath, instanceConfig.getRecord(), true, true);
  19. }
  20. }
  21. }

相关文章