Source:
<code>private void processCurrentStates(BaseControllerDataProvider cache, Map<String, Resource> resourceMap, Map<String, Resource> resourceToRebalance, Map<String, IdealState> idealStates, boolean isTaskCache) throws StageException { Map<String, LiveInstance> availableInstances = cache.getLiveInstances(); if (availableInstances != null && availableInstances.size() > 0) { for (LiveInstance instance : availableInstances.values()) { String instanceName = instance.getInstanceName(); String clientSessionId = instance.getEphemeralOwner(); <START> processCurrentStateMap(cache.getCurrentState(instanceName, clientSessionId), resourceMap, <END> resourceToRebalance, idealStates, isTaskCache); if (isTaskCache) { Map<String, CurrentState> taskCurrentStateMap = ((WorkflowControllerDataProvider) cache) .getTaskCurrentState(instanceName, clientSessionId); processCurrentStateMap(taskCurrentStateMap, resourceMap, resourceToRebalance, idealStates, true); } } } }</code><technical_language>This is for compatibility, right? create another private method get full task current state smartly? need 2 processCurrentStateMap calls here</technical_language>

Target:
private void processCurrentStates(BaseControllerDataProvider cache, Map<String, Resource> resourceMap, Map<String, Resource> resourceToRebalance, Map<String, IdealState> idealStates, boolean isTaskCache) throws StageException { Map<String, LiveInstance> availableInstances = cache.getLiveInstances(); if (availableInstances != null && availableInstances.size() > 0) { for (LiveInstance instance : availableInstances.values()) { String instanceName = instance.getInstanceName(); String clientSessionId = instance.getEphemeralOwner(); Map<String, CurrentState> currentStateMap = cache.getCurrentState(instanceName, clientSessionId, isTaskCache); for (CurrentState currentState : currentStateMap.values()) { String resourceName = currentState.getResourceName(); Map<String, String> resourceStateMap = currentState.getPartitionStateMap(); if (resourceStateMap.keySet().isEmpty()) { continue; } if (!resourceMap.containsKey(resourceName)) { Resource resource = new Resource(resourceName); resource.setStateModelDefRef(currentState.getStateModelDefRef()); resource.setStateModelFactoryName(currentState.getStateModelFactoryName()); resource.setBucketSize(currentState.getBucketSize()); resource.setBatchMessageMode(currentState.getBatchMessageMode()); if (isTaskCache == TaskConstants.STATE_MODEL_NAME .equals(resource.getStateModelDefRef())) { resourceToRebalance.put(resourceName, resource); } IdealState idealState = idealStates.get(resourceName); if (idealState != null) { resource.setResourceGroupName(idealState.getResourceGroupName()); resource.setResourceTag(idealState.getInstanceGroupTag()); } resourceMap.put(resourceName, resource); } if (currentState.getStateModelDefRef() == null) { LogUtil.logError(LOG, _eventId, "state model def is null." + "resource:" + currentState.getResourceName() + ", partitions: " + currentState.getPartitionStateMap().keySet() + ", states: " + currentState.getPartitionStateMap().values()); throw new StageException( "State model def is null for resource:" + currentState.getResourceName()); } for (String partition : resourceStateMap.keySet()) { addPartition(partition, resourceName, resourceMap); } } } } }