Source:
void updateTopologyHandler(String topologyName, String newParallelism) throws TopologyRuntimeManagementException, PackingException, UpdateDryRunResponse { LOG.fine(String.format("updateTopologyHandler called for %s with %s", topologyName, newParallelism)); SchedulerStateManagerAdaptor manager = Runtime.schedulerStateManagerAdaptor(runtime); TopologyAPI.Topology topology = manager.getTopology(topologyName); Map<String, Integer> changeRequests = parseNewParallelismParam(newParallelism); PackingPlans.PackingPlan currentPlan = manager.getPackingPlan(topologyName); if (!changeDetected(currentPlan, changeRequests)) { throw new TopologyRuntimeManagementException( String.format("The component parallelism request (%s) is the same as the " + "current topology parallelism. Not taking action.", newParallelism)); } PackingPlans.PackingPlan proposedPlan = buildNewPackingPlan(currentPlan, changeRequests, topology); if (Context.dryRun(config)) { PackingPlanProtoDeserializer deserializer = new PackingPlanProtoDeserializer(); PackingPlan oldPlan = deserializer.fromProto(currentPlan); PackingPlan newPlan = deserializer.fromProto(proposedPlan); throw new UpdateDryRunResponse(topology, config, newPlan, oldPlan, changeRequests); } int newContainerCount = proposedPlan.getContainerPlansCount(); int oldContainerCount = currentPlan.getContainerPlansCount(); if (newContainerCount > oldContainerCount) { if (!consolePrompt(oldContainerCount, newContainerCount)) { LOG.fine("Scheduler updated topology canceled."); return; } } Scheduler.UpdateTopologyRequest updateTopologyRequest = Scheduler.UpdateTopologyRequest.newBuilder() .setCurrentPackingPlan(currentPlan) .setProposedPackingPlan(proposedPlan) .build(); LOG.fine("Sending Updating topology request: " + updateTopologyRequest); if (!schedulerClient.updateTopology(updateTopologyRequest)) { throw new TopologyRuntimeManagementException( "Failed to update topology with Scheduler, updateTopologyRequest=" + updateTopologyRequest + "The topology can be in a strange stage. " + "Please check carefully or redeploy the topology !!"); } LOG.fine("Scheduler updated topology successfully."); }

Target:
void updateTopologyHandler(String topologyName, String newParallelism) throws TopologyRuntimeManagementException, PackingException, UpdateDryRunResponse { LOG.fine(String.format("updateTopologyHandler called for %s with %s", topologyName, newParallelism)); SchedulerStateManagerAdaptor manager = Runtime.schedulerStateManagerAdaptor(runtime); TopologyAPI.Topology topology = manager.getTopology(topologyName); Map<String, Integer> changeRequests = parseNewParallelismParam(newParallelism); PackingPlans.PackingPlan currentPlan = manager.getPackingPlan(topologyName); if (!changeDetected(currentPlan, changeRequests)) { throw new TopologyRuntimeManagementException( String.format("The component parallelism request (%s) is the same as the " + "current topology parallelism. Not taking action.", newParallelism)); } PackingPlans.PackingPlan proposedPlan = buildNewPackingPlan(currentPlan, changeRequests, topology); if (Context.dryRun(config)) { PackingPlanProtoDeserializer deserializer = new PackingPlanProtoDeserializer(); PackingPlan oldPlan = deserializer.fromProto(currentPlan); PackingPlan newPlan = deserializer.fromProto(proposedPlan); throw new UpdateDryRunResponse(topology, config, newPlan, oldPlan, changeRequests); } int newContainerCount = proposedPlan.getContainerPlansCount(); int oldContainerCount = currentPlan.getContainerPlansCount(); if (newContainerCount > oldContainerCount && "prompt".equalsIgnoreCase(Context.updatePrompt(config))) { if (!confirmWithUser(oldContainerCount, newContainerCount)) { LOG.warning("Scheduler updated topology canceled."); return; } } Scheduler.UpdateTopologyRequest updateTopologyRequest = Scheduler.UpdateTopologyRequest.newBuilder() .setCurrentPackingPlan(currentPlan) .setProposedPackingPlan(proposedPlan) .build(); LOG.fine("Sending Updating topology request: " + updateTopologyRequest); if (!schedulerClient.updateTopology(updateTopologyRequest)) { throw new TopologyRuntimeManagementException( "Failed to update topology with Scheduler, updateTopologyRequest=" + updateTopologyRequest + "The topology can be in a strange stage. " + "Please check carefully or redeploy the topology !!"); } LOG.fine("Scheduler updated topology successfully."); }