@Test() public void testCreateOrReplace() { String path = PropertyPathBuilder.instanceConfig(clusterName, "id8"); ZNRecord record = new ZNRecord("id8"); ZKUtil.createOrReplace(_gZkClient, path, record, true); record = _gZkClient.readData(path); AssertJUnit.assertEquals("id8", record.getId()); record = new ZNRecord("id9"); ZKUtil.createOrReplace(_gZkClient, path, record, true); record = _gZkClient.readData(path); AssertJUnit.assertEquals("id9", record.getId()); }
private void updateClusterConfig(String clusterName, ClusterConfig clusterConfig, boolean overwrite) { if (!ZKUtil.isClusterSetup(clusterName, zkClient)) { throw new HelixException("fail to update config. cluster: " + clusterName + " is NOT setup."); } HelixConfigScope scope = new HelixConfigScopeBuilder(ConfigScopeProperty.CLUSTER).forCluster(clusterName).build(); String zkPath = scope.getZkPath(); if (overwrite) { ZKUtil.createOrReplace(zkClient, zkPath, clusterConfig.getRecord(), true); } else { ZKUtil.createOrUpdate(zkClient, zkPath, clusterConfig.getRecord(), true, true); } }
private void updateClusterConfig(String clusterName, ClusterConfig clusterConfig, boolean overwrite) { if (!ZKUtil.isClusterSetup(clusterName, zkClient)) { throw new HelixException("fail to update config. cluster: " + clusterName + " is NOT setup."); } HelixConfigScope scope = new HelixConfigScopeBuilder(ConfigScopeProperty.CLUSTER).forCluster(clusterName).build(); String zkPath = scope.getZkPath(); if (overwrite) { ZKUtil.createOrReplace(zkClient, zkPath, clusterConfig.getRecord(), true); } else { ZKUtil.createOrUpdate(zkClient, zkPath, clusterConfig.getRecord(), true, true); } }
private void updateInstanceConfig(String clusterName, String instanceName, InstanceConfig instanceConfig, boolean overwrite) { if (!ZKUtil.isClusterSetup(clusterName, zkClient)) { throw new HelixException("fail to setup config. cluster: " + clusterName + " is NOT setup."); } HelixConfigScope scope = new HelixConfigScopeBuilder(ConfigScopeProperty.PARTICIPANT).forCluster(clusterName) .forParticipant(instanceName).build(); String zkPath = scope.getZkPath(); if (overwrite) { ZKUtil.createOrReplace(zkClient, zkPath, instanceConfig.getRecord(), true); } else { ZKUtil.createOrUpdate(zkClient, zkPath, instanceConfig.getRecord(), true, true); } } }
private void updateResourceConfig(String clusterName, String resourceName, ResourceConfig resourceConfig, boolean overwrite) { if (!ZKUtil.isClusterSetup(clusterName, zkClient)) { throw new HelixException("fail to setup config. cluster: " + clusterName + " is NOT setup."); } HelixConfigScope scope = new HelixConfigScopeBuilder(ConfigScopeProperty.RESOURCE).forCluster(clusterName) .forResource(resourceName).build(); String zkPath = scope.getZkPath(); if (overwrite) { ZKUtil.createOrReplace(zkClient, zkPath, resourceConfig.getRecord(), true); } else { ZKUtil.createOrUpdate(zkClient, zkPath, resourceConfig.getRecord(), true, true); } }
private void updateResourceConfig(String clusterName, String resourceName, ResourceConfig resourceConfig, boolean overwrite) { if (!ZKUtil.isClusterSetup(clusterName, zkClient)) { throw new HelixException("fail to setup config. cluster: " + clusterName + " is NOT setup."); } HelixConfigScope scope = new HelixConfigScopeBuilder(ConfigScopeProperty.RESOURCE).forCluster(clusterName) .forResource(resourceName).build(); String zkPath = scope.getZkPath(); if (overwrite) { ZKUtil.createOrReplace(zkClient, zkPath, resourceConfig.getRecord(), true); } else { ZKUtil.createOrUpdate(zkClient, zkPath, resourceConfig.getRecord(), true, true); } }
private void updateInstanceConfig(String clusterName, String instanceName, InstanceConfig instanceConfig, boolean overwrite) { if (!ZKUtil.isClusterSetup(clusterName, zkClient)) { throw new HelixException("fail to setup config. cluster: " + clusterName + " is NOT setup."); } HelixConfigScope scope = new HelixConfigScopeBuilder(ConfigScopeProperty.PARTICIPANT).forCluster(clusterName) .forParticipant(instanceName).build(); String zkPath = scope.getZkPath(); if (!zkClient.exists(zkPath)) { throw new HelixException( "updateInstanceConfig failed. Given InstanceConfig does not already exist. instance: " + instanceName); } if (overwrite) { ZKUtil.createOrReplace(zkClient, zkPath, instanceConfig.getRecord(), true); } else { ZKUtil.createOrUpdate(zkClient, zkPath, instanceConfig.getRecord(), true, true); } } }