/** * Get the path associated with this property * @return absolute path to the property */ public String getPath() { String clusterName = _params[0]; String[] subKeys = Arrays.copyOfRange(_params, 1, _params.length); String path = PropertyPathBuilder.getPath(_type, clusterName, subKeys); if (path == null) { LOG.error("Invalid property key with type:" + _type + "subKeys:" + Arrays.toString(_params)); } return path; }
/** * Get the path associated with this property * @return absolute path to the property */ public String getPath() { String clusterName = _params[0]; String[] subKeys = Arrays.copyOfRange(_params, 1, _params.length); String path = PropertyPathBuilder.getPath(_type, clusterName, subKeys); if (path == null) { LOG.error("Invalid property key with type:" + _type + "subKeys:" + Arrays.toString(_params)); } return path; }
@Override public boolean setInstanceConfig(String clusterName, String instanceName, InstanceConfig newInstanceConfig) { logger.info("Set instance config for instance {} to cluster {} with new InstanceConfig {}.", instanceName, clusterName, newInstanceConfig == null ? "NULL" : newInstanceConfig.toString()); String instanceConfigPath = PropertyPathBuilder.getPath(PropertyType.CONFIGS, clusterName, HelixConfigScope.ConfigScopeProperty.PARTICIPANT.toString(), instanceName); if (!_zkClient.exists(instanceConfigPath)) { throw new HelixException( "instance" + instanceName + " does not exist in cluster " + clusterName); } HelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_zkClient)); PropertyKey instanceConfigPropertyKey = accessor.keyBuilder().instanceConfig(instanceName); InstanceConfig currentInstanceConfig = accessor.getProperty(instanceConfigPropertyKey); if (!newInstanceConfig.getHostName().equals(currentInstanceConfig.getHostName()) || !newInstanceConfig.getPort().equals(currentInstanceConfig.getPort())) { throw new HelixException( "Hostname and port cannot be changed, current hostname: " + currentInstanceConfig .getHostName() + " and port: " + currentInstanceConfig.getPort() + " is different from new hostname: " + newInstanceConfig.getHostName() + "and new port: " + newInstanceConfig.getPort()); } return accessor.setProperty(instanceConfigPropertyKey, newInstanceConfig); }
@Override public boolean setInstanceConfig(String clusterName, String instanceName, InstanceConfig newInstanceConfig) { logger.info("Set instance config for instance {} to cluster {} with new InstanceConfig {}.", instanceName, clusterName, newInstanceConfig == null ? "NULL" : newInstanceConfig.toString()); String instanceConfigPath = PropertyPathBuilder.getPath(PropertyType.CONFIGS, clusterName, HelixConfigScope.ConfigScopeProperty.PARTICIPANT.toString(), instanceName); if (!_zkClient.exists(instanceConfigPath)) { throw new HelixException( "instance" + instanceName + " does not exist in cluster " + clusterName); } HelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_zkClient)); PropertyKey instanceConfigPropertyKey = accessor.keyBuilder().instanceConfig(instanceName); InstanceConfig currentInstanceConfig = accessor.getProperty(instanceConfigPropertyKey); if (!newInstanceConfig.getHostName().equals(currentInstanceConfig.getHostName()) || !newInstanceConfig.getPort().equals(currentInstanceConfig.getPort())) { throw new HelixException( "Hostname and port cannot be changed, current hostname: " + currentInstanceConfig .getHostName() + " and port: " + currentInstanceConfig.getPort() + " is different from new hostname: " + newInstanceConfig.getHostName() + "and new port: " + newInstanceConfig.getPort()); } return accessor.setProperty(instanceConfigPropertyKey, newInstanceConfig); }
tool.addInstance(clusterName, config); tool.enableInstance(clusterName, instanceName, true); String path = PropertyPathBuilder.getPath(PropertyType.INSTANCES, clusterName, instanceName); AssertJUnit.assertTrue(_gZkClient.exists(path));