public void dropInstanceFromCluster(String clusterName, String instanceId) {
ZKHelixDataAccessor accessor =
new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_zkClient));
Builder keyBuilder = accessor.keyBuilder();
InstanceConfig instanceConfig = toInstanceConfig(instanceId);
instanceId = instanceConfig.getInstanceName();
// ensure node is stopped
LiveInstance liveInstance = accessor.getProperty(keyBuilder.liveInstance(instanceId));
if (liveInstance != null) {
throw new HelixException("Can't drop " + instanceId + ", please stop " + instanceId
+ " before drop it");
}
InstanceConfig config = accessor.getProperty(keyBuilder.instanceConfig(instanceId));
if (config == null) {
String error = "Node " + instanceId + " does not exist, cannot drop";
_logger.warn(error);
throw new HelixException(error);
}
// ensure node is disabled, otherwise fail
if (config.getInstanceEnabled()) {
String error = "Node " + instanceId + " is enabled, cannot drop";
_logger.warn(error);
throw new HelixException(error);
}
_admin.dropInstance(clusterName, config);