nwangtw commented on a change in pull request #3195: 2D(RAM, CPU) Vector 
Binpacking (FirstFit Decreasing) Packing
URL: https://github.com/apache/incubator-heron/pull/3195#discussion_r258298510
 
 

 ##########
 File path: heron/spi/src/java/org/apache/heron/spi/packing/PackingPlan.java
 ##########
 @@ -324,4 +390,39 @@ public String toString() {
       return str + "}";
     }
   }
+
+  public static class ResourceUtility implements Comparable<ResourceUtility> {
+    private final double ramUtility;
+    private final double cpuUtility;
+
+    public ResourceUtility(double ramUtility, double cpuUtility) {
+      this.ramUtility = ramUtility;
+      this.cpuUtility = cpuUtility;
+    }
+
+    public double getRamUtility() {
+      return ramUtility;
+    }
+
+    public double getCpuUtility() {
+      return cpuUtility;
+    }
+
+    @Override
+    public String toString() {
+      return String.format("RAM Utility=%.3f%%, CPU Utility=%.3f%%",
+          ramUtility * 100, cpuUtility * 100);
+    }
+
+    @Override
+    public int compareTo(ResourceUtility o) {
+      if (ramUtility > o.ramUtility && cpuUtility > o.cpuUtility) {
+        return 1;
+      } else if (ramUtility < o.ramUtility && cpuUtility < o.cpuUtility) {
+        return -1;
+      } else {
+        return 0;
 
 Review comment:
   hmm. So if ramUtil is greater and cpuUtil is less, the function would return 
0? Seems strange. Maybe give ram and cpu different priorities. Like only 
compare cpu utils when the ram utils equal.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to