Source:
public static boolean isInstanceStable(HelixDataAccessor dataAccessor, String instanceName) { PropertyKey.Builder keyBuilder = dataAccessor.keyBuilder(); ClusterConfig clusterConfig = dataAccessor.getProperty(keyBuilder.clusterConfig()); if (clusterConfig == null) { throw new HelixException("Missing cluster config!"); } if (!clusterConfig.isPersistIntermediateAssignment()) { throw new HelixException("isInstanceStable needs persist assignment on!"); } List<String> idealStateNames = dataAccessor.getChildNames(keyBuilder.idealStates()); for (String idealStateName : idealStateNames) { IdealState idealState = dataAccessor.getProperty(keyBuilder.idealStates(idealStateName)); if (idealState == null || !idealState.isEnabled() || !idealState.isValid() || TaskConstants.STATE_MODEL_NAME.equals(idealState.getStateModelDefRef())) { _logger.warn( "idealState is either null, not enabled, not valid, or has Task as stateModelDefRef. IdealState: {}", instanceName); continue; } ExternalView externalView = dataAccessor.getProperty(keyBuilder.externalView(idealStateName)); if (externalView == null) { throw new HelixException( String.format("Resource %s does not have external view!", idealStateName)); } for (String partition : idealState.getPartitionSet()) { Map<String, String> isPartitionMap = idealState.getInstanceStateMap(partition); if (isPartitionMap == null) { throw new HelixException(String .format("Partition %s of resource %s does not have an ideal state partition map", partition, idealStateName)); } Map<String, String> evPartitionMap = externalView.getStateMap(partition); if (evPartitionMap == null) { throw new HelixException(String .format("Partition %s of resource %s does not have an external view partition map", partition, idealStateName)); } if (isPartitionMap.containsKey(instanceName) && (!evPartitionMap.containsKey(instanceName) || !evPartitionMap.get(instanceName).equals(isPartitionMap.get(instanceName)))) { return false; } } } return true; }

Target:
public static boolean isInstanceStable(HelixDataAccessor dataAccessor, String instanceName) { PropertyKey.Builder keyBuilder = dataAccessor.keyBuilder(); ClusterConfig clusterConfig = dataAccessor.getProperty(keyBuilder.clusterConfig()); if (clusterConfig == null) { throw new HelixException("Missing cluster config!"); } if (!clusterConfig.isPersistIntermediateAssignment()) { throw new HelixException("isInstanceStable needs persist assignment on!"); } List<String> idealStateNames = dataAccessor.getChildNames(keyBuilder.idealStates()); for (String idealStateName : idealStateNames) { IdealState idealState = dataAccessor.getProperty(keyBuilder.idealStates(idealStateName)); if (idealState == null || !idealState.isEnabled() || !idealState.isValid() || TaskConstants.STATE_MODEL_NAME.equals(idealState.getStateModelDefRef())) { continue; } ExternalView externalView = dataAccessor.getProperty(keyBuilder.externalView(idealStateName)); if (externalView == null) { throw new HelixException( String.format("Resource %s does not have external view!", idealStateName)); } for (String partition : idealState.getPartitionSet()) { Map<String, String> isPartitionMap = idealState.getInstanceStateMap(partition); if (isPartitionMap == null) { throw new HelixException(String .format("Partition %s of resource %s does not have an ideal state partition map", partition, idealStateName)); } Map<String, String> evPartitionMap = externalView.getStateMap(partition); if (evPartitionMap == null) { throw new HelixException(String .format("Partition %s of resource %s does not have an external view partition map", partition, idealStateName)); } if (isPartitionMap.containsKey(instanceName) && (!evPartitionMap.containsKey(instanceName) || !evPartitionMap.get(instanceName).equals(isPartitionMap.get(instanceName)))) { return false; } } } return true; }