public InstanceConfig toInstanceConfig() { final InstanceConfig iConfig = new InstanceConfig(toInstanceId()); iConfig.setHostName(_host); iConfig.setPort(_port); iConfig.setInstanceEnabled(true); iConfig.addTag(getTagOrDefaultTag()); return iConfig; }
@Override public void addInstanceTag(String clusterName, String instanceName, String tag) { logger .info("Add instance tag {} for instance {} in cluster {}.", tag, instanceName, clusterName); if (!ZKUtil.isClusterSetup(clusterName, _zkClient)) { throw new HelixException("cluster " + clusterName + " is not setup yet"); } if (!ZKUtil.isInstanceSetup(_zkClient, clusterName, instanceName, InstanceType.PARTICIPANT)) { throw new HelixException("cluster " + clusterName + " instance " + instanceName + " is not setup yet"); } HelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_zkClient)); Builder keyBuilder = accessor.keyBuilder(); InstanceConfig config = accessor.getProperty(keyBuilder.instanceConfig(instanceName)); config.addTag(tag); accessor.setProperty(keyBuilder.instanceConfig(instanceName), config); }
@Override public void addInstanceTag(String clusterName, String instanceName, String tag) { logger .info("Add instance tag {} for instance {} in cluster {}.", tag, instanceName, clusterName); if (!ZKUtil.isClusterSetup(clusterName, _zkClient)) { throw new HelixException("cluster " + clusterName + " is not setup yet"); } if (!ZKUtil.isInstanceSetup(_zkClient, clusterName, instanceName, InstanceType.PARTICIPANT)) { throw new HelixException( "cluster " + clusterName + " instance " + instanceName + " is not setup yet"); } HelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_zkClient)); Builder keyBuilder = accessor.keyBuilder(); InstanceConfig config = accessor.getProperty(keyBuilder.instanceConfig(instanceName)); config.addTag(tag); accessor.setProperty(keyBuilder.instanceConfig(instanceName), config); }
config.addTag(TEST_TAG);