Github user Ethanlm commented on a diff in the pull request:
https://github.com/apache/storm/pull/2551#discussion_r166755231
--- Diff:
storm-client/src/jvm/org/apache/storm/grouping/LoadAwareShuffleGrouping.java ---
@@ -85,6 +85,7 @@ public void prepare(WorkerTopologyContext context,
GlobalStreamId stream, List<I
sourceNodeInfo = new NodeInfo(context.getThisWorkerHost(),
Sets.newHashSet((long) context.getThisWorkerPort()));
taskToNodePort = context.getTaskToNodePort();
this.targetTasks = targetTasks;
+ CAPACITY = targetTasks.size() == 1 ? 1 : targetTasks.size() *
MAX_WEIGHT;
--- End diff --
`targetTasks.size() == 1` is just for performance enhancement. Since there
is only one target task, there is no need to compose a choice array and choose
the target from the elements of the choice array; Set CAPACITY to 1 can avoid
this.
For the particular equation,
`int count = (int) ((indexAndWeights.weight / (double) weightSum) *
CAPACITY);`
because there is only one target, so `indexAndWeights.weight / (double)
weightSum` must be 1 and count must be 1 if there is any load on that target
task.
---