Source:
public void dropInstance(String clusterName, InstanceConfig instanceConfig) { logger.info("Drop instance from cluster {}.", instanceConfig.getInstanceName(), clusterName); String instanceName = instanceConfig.getInstanceName(); String instanceConfigPath = PropertyPathBuilder.instanceConfig(clusterName, instanceName); if (!_zkClient.exists(instanceConfigPath)) { throw new HelixException( "Node " + instanceName + " does not exist in config for cluster " + clusterName); } String instancePath = PropertyPathBuilder.instance(clusterName, instanceName); if (!_zkClient.exists(instancePath)) { throw new HelixException( "Node " + instanceName + " does not exist in instances for cluster " + clusterName); } String liveInstancePath = PropertyPathBuilder.liveInstance(clusterName, instanceName); if (_zkClient.exists(liveInstancePath)) { throw new HelixException( "Node " + instanceName + " is still alive for cluster " + clusterName + ", can't drop."); } String instanceConfigsPath = PropertyPathBuilder.instanceConfig(clusterName); ZKUtil.dropChildren(_zkClient, instanceConfigsPath, instanceConfig.getRecord()); int retryCnt = 0; while (true) { try { _zkClient.deleteRecursively(instancePath); return; } catch (ZkClientException e) { if (retryCnt < 3 && e.getCause() instanceof ZkException && e.getCause() .getCause() instanceof KeeperException.NotEmptyException) { logger.warn("Retrying dropping instance with exception {}", instanceConfig.getInstanceName(), e.getCause().getMessage()); retryCnt++; } else { String errorMessage = "Failed to drop instance: " + instanceConfig.getInstanceName() + ". Retry times: " + retryCnt; logger.error(errorMessage, retryCnt, e.getCause()); throw new HelixException(errorMessage, e); } } } }

Target:
public void dropInstance(String clusterName, InstanceConfig instanceConfig) { logger.info("Drop instance from cluster {}.", instanceConfig.getInstanceName(), clusterName); String instanceName = instanceConfig.getInstanceName(); String instanceConfigPath = PropertyPathBuilder.instanceConfig(clusterName, instanceName); if (!_zkClient.exists(instanceConfigPath)) { throw new HelixException( "Node " + instanceName + " does not exist in config for cluster " + clusterName); } String instancePath = PropertyPathBuilder.instance(clusterName, instanceName); if (!_zkClient.exists(instancePath)) { throw new HelixException( "Node " + instanceName + " does not exist in instances for cluster " + clusterName); } String liveInstancePath = PropertyPathBuilder.liveInstance(clusterName, instanceName); if (_zkClient.exists(liveInstancePath)) { throw new HelixException( "Node " + instanceName + " is still alive for cluster " + clusterName + ", can't drop."); } String instanceConfigsPath = PropertyPathBuilder.instanceConfig(clusterName); ZKUtil.dropChildren(_zkClient, instanceConfigsPath, instanceConfig.getRecord()); int retryCnt = 0; while (true) { try { _zkClient.deleteRecursively(instancePath); return; } catch (ZkClientException e) { if (retryCnt < 3 && e.getCause() instanceof ZkException && e.getCause() .getCause() instanceof KeeperException.NotEmptyException) { logger.warn("Retrying dropping instance with exception {}", instanceConfig.getInstanceName(), e.getCause().getMessage()); retryCnt++; } else { String errorMessage = "Failed to drop instance: " + instanceConfig.getInstanceName() + ". Retry times: " + retryCnt; logger.error(errorMessage, e); throw new HelixException(errorMessage, e); } } } }