@Override public void process(ClusterEvent event) throws Exception { _eventId = event.getEventId(); CurrentStateOutput currentStateOutput = event.getAttribute(AttributeName.CURRENT_STATE.name()); BestPossibleStateOutput bestPossibleStateOutput = event.getAttribute(AttributeName.BEST_POSSIBLE_STATE.name()); Map<String, Resource> resourceMap = event.getAttribute(AttributeName.RESOURCES.name()); ClusterDataCache cache = event.getAttribute(AttributeName.ClusterDataCache.name()); if (currentStateOutput == null || bestPossibleStateOutput == null || resourceMap == null || cache == null) { throw new StageException(String.format("Missing attributes in event: %s. " + "Requires CURRENT_STATE (%s) |BEST_POSSIBLE_STATE (%s) |RESOURCES (%s) |DataCache (%s)", event, currentStateOutput, bestPossibleStateOutput, resourceMap, cache)); } IntermediateStateOutput intermediateStateOutput = compute(event, resourceMap, currentStateOutput, bestPossibleStateOutput); event.addAttribute(AttributeName.INTERMEDIATE_STATE.name(), intermediateStateOutput); // Make sure no instance has more replicas/partitions assigned than maxPartitionPerInstance. If // it does, pause the rebalance and put the cluster on maintenance mode int maxPartitionPerInstance = cache.getClusterConfig().getMaxPartitionsPerInstance(); if (maxPartitionPerInstance > 0) { validateMaxPartitionsPerInstance(event, cache, intermediateStateOutput, maxPartitionPerInstance); } }
@Override public void process(ClusterEvent event) throws Exception { _eventId = event.getEventId(); CurrentStateOutput currentStateOutput = event.getAttribute(AttributeName.CURRENT_STATE.name()); BestPossibleStateOutput bestPossibleStateOutput = event.getAttribute(AttributeName.BEST_POSSIBLE_STATE.name()); Map<String, Resource> resourceToRebalance = event.getAttribute(AttributeName.RESOURCES_TO_REBALANCE.name()); ClusterDataCache cache = event.getAttribute(AttributeName.ClusterDataCache.name()); if (currentStateOutput == null || bestPossibleStateOutput == null || resourceToRebalance == null || cache == null) { throw new StageException(String.format("Missing attributes in event: %s. " + "Requires CURRENT_STATE (%s) |BEST_POSSIBLE_STATE (%s) |RESOURCES (%s) |DataCache (%s)", event, currentStateOutput, bestPossibleStateOutput, resourceToRebalance, cache)); } IntermediateStateOutput intermediateStateOutput = compute(event, resourceToRebalance, currentStateOutput, bestPossibleStateOutput); event.addAttribute(AttributeName.INTERMEDIATE_STATE.name(), intermediateStateOutput); // Make sure no instance has more replicas/partitions assigned than maxPartitionPerInstance. If // it does, pause the rebalance and put the cluster on maintenance mode int maxPartitionPerInstance = cache.getClusterConfig().getMaxPartitionsPerInstance(); if (maxPartitionPerInstance > 0) { validateMaxPartitionsPerInstance(event, cache, intermediateStateOutput, maxPartitionPerInstance); } }