Source:
<code>public void process(ClusterEvent event) throws Exception { _eventId = event.getEventId(); BaseControllerDataProvider cache = event.getAttribute(AttributeName.ControllerDataProvider.name()); if (cache instanceof WorkflowControllerDataProvider) { _isTaskFrameworkPipeline = true; } <START> <END> final Map<String, Resource> resourceMap = event.getAttribute(AttributeName.RESOURCES.name()); final Map<String, Resource> resourceToRebalance = event.getAttribute(AttributeName.RESOURCES_TO_REBALANCE.name()); if (cache == null || resourceMap == null) { throw new StageException("Missing attributes in event:" + event + ". Requires DataCache|RESOURCE"); } Map<String, LiveInstance> liveInstances = cache.getLiveInstances(); final CurrentStateOutput currentStateOutput = new CurrentStateOutput(); for (LiveInstance instance : liveInstances.values()) { String instanceName = instance.getInstanceName(); String instanceSessionId = instance.getEphemeralOwner(); Map<String, CurrentState> currentStateMap = cache.getCurrentState(instanceName, instanceSessionId); updateCurrentStates(instance, currentStateMap.values(), currentStateOutput, resourceMap); Map<String, Map<String, Message>> existingStaleMessages = cache.getStaleMessages(); currentStateOutput.setStaleMessageMap(existingStaleMessages); Map<String, Message> messages = cache.getMessages(instanceName); Map<String, Message> relayMessages = cache.getRelayMessages(instanceName); updatePendingMessages(instance, messages.values(), currentStateOutput, relayMessages.values(), resourceMap, existingStaleMessages); cache.setStaleMessages(currentStateOutput.getStaleMessageMap()); } event.addAttribute(AttributeName.CURRENT_STATE.name(), currentStateOutput); final ClusterStatusMonitor clusterStatusMonitor = event.getAttribute(AttributeName.clusterStatusMonitor.name()); if (clusterStatusMonitor != null && cache instanceof ResourceControllerDataProvider) { final ResourceControllerDataProvider dataProvider = (ResourceControllerDataProvider) cache; reportInstanceCapacityMetrics(clusterStatusMonitor, dataProvider, resourceToRebalance, currentStateOutput); reportResourcePartitionCapacityMetrics(dataProvider.getAsyncTasksThreadPool(), clusterStatusMonitor, dataProvider.getResourceConfigMap().values()); } }</code><technical_language>This potentially increase future work split pipeline. need a more centralized pipeline type. Otherwise, need more types messy. For example aggregation pipeline. Please add a TODO avoid this hacky style</technical_language>

Target:
public void process(ClusterEvent event) throws Exception { _eventId = event.getEventId(); BaseControllerDataProvider cache = event.getAttribute(AttributeName.ControllerDataProvider.name()); if (cache instanceof WorkflowControllerDataProvider) { _isTaskFrameworkPipeline = true; } final Map<String, Resource> resourceMap = event.getAttribute(AttributeName.RESOURCES.name()); final Map<String, Resource> resourceToRebalance = event.getAttribute(AttributeName.RESOURCES_TO_REBALANCE.name()); if (cache == null || resourceMap == null) { throw new StageException("Missing attributes in event:" + event + ". Requires DataCache|RESOURCE"); } Map<String, LiveInstance> liveInstances = cache.getLiveInstances(); final CurrentStateOutput currentStateOutput = new CurrentStateOutput(); for (LiveInstance instance : liveInstances.values()) { String instanceName = instance.getInstanceName(); String instanceSessionId = instance.getEphemeralOwner(); Map<String, CurrentState> currentStateMap = cache.getCurrentState(instanceName, instanceSessionId); updateCurrentStates(instance, currentStateMap.values(), currentStateOutput, resourceMap); Set<Message> existingStaleMessages = cache.getStaleMessagesByInstance(instanceName); Map<String, Message> messages = cache.getMessages(instanceName); Map<String, Message> relayMessages = cache.getRelayMessages(instanceName); updatePendingMessages(instance, cache, messages.values(), relayMessages.values(), existingStaleMessages, currentStateOutput, resourceMap); } event.addAttribute(AttributeName.CURRENT_STATE.name(), currentStateOutput); final ClusterStatusMonitor clusterStatusMonitor = event.getAttribute(AttributeName.clusterStatusMonitor.name()); if (clusterStatusMonitor != null && cache instanceof ResourceControllerDataProvider) { final ResourceControllerDataProvider dataProvider = (ResourceControllerDataProvider) cache; reportInstanceCapacityMetrics(clusterStatusMonitor, dataProvider, resourceToRebalance, currentStateOutput); reportResourcePartitionCapacityMetrics(dataProvider.getAsyncTasksThreadPool(), clusterStatusMonitor, dataProvider.getResourceConfigMap().values()); } }