bipinprasad commented on a change in pull request #3379: URL: https://github.com/apache/storm/pull/3379#discussion_r581617481
########## File path: storm-server/src/main/java/org/apache/storm/scheduler/resource/normalization/NormalizedResources.java ########## @@ -384,14 +391,29 @@ public double calculateMinPercentageUsedBy(NormalizedResources used, double tota /** * If a node or rack has a kind of resource not in a request, make that resource negative so when sorting that node or rack will - * be less likely to be selected. + * be less likely to be selected. If the resource is in the request, make that resource positive. * @param request the requested resources. */ public void updateForRareResourceAffinity(NormalizedResources request) { int length = Math.min(this.otherResources.length, request.otherResources.length); for (int i = 0; i < length; i++) { - if (request.getResourceAt(i) == 0.0) { - this.otherResources[i] = -1 * this.otherResources[i]; + if (request.getResourceAt(i) == 0.0 && this.otherResources[i] > 0.0) { + this.otherResources[i] = -this.otherResources[i]; // make negative + } else if (request.getResourceAt(i) > 0.0 && this.otherResources[i] < 0.0) { Review comment: The goal in this code is to make unrequested resource negative (but also requested resource positive). So when processing a new executor with different resource requirements, it can be reapplied and re-sort resulting elements. With earlier code, this was a "use-once-only" method on the "otherResource". With the change above, the object can be reused. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org