bipinprasad commented on a change in pull request #3379:
URL: https://github.com/apache/storm/pull/3379#discussion_r583810797
##########
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) {
+ this.otherResources[i] = -this.otherResources[i]; // make
positive
+ }
+ }
+ }
+
+ /**
+ * If the resource is negative, then make that resource positive.
+ * This will undo effects of {@link
#updateForRareResourceAffinity(NormalizedResources)}.
+ */
+ public void revertUpdatesForRareResourceAffinity() {
Review comment:
Will remove from this PR.
----------------------------------------------------------------
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:
[email protected]