pkuwm commented on a change in pull request #686: Add resource partition weight
gauge
URL: https://github.com/apache/helix/pull/686#discussion_r369219486
##########
File path:
helix-core/src/main/java/org/apache/helix/controller/rebalancer/util/ResourceUsageCalculator.java
##########
@@ -142,4 +142,97 @@ public static double
measureBaselineDivergence(Map<String, ResourceAssignment> b
return numTotalBestPossibleReplicas == 0 ? 1.0d
: (1.0d - (double) numMatchedReplicas / (double)
numTotalBestPossibleReplicas);
}
+
+ /**
+ * Calculates average partition weight per capacity key for a resource
config. Example as below:
+ * Input =
+ * {
+ * "partition1": {
+ * "capacity1": 20,
+ * "capacity2": 40
+ * },
+ * "partition2": {
+ * "capacity1": 30,
+ * "capacity2": 50
+ * },
+ * "partition3": {
+ * "capacity1": 16,
+ * "capacity2": 30
+ * }
+ * }
+ *
+ * Total weight for key "capacity1" = 20 + 30 + 16 = 66;
+ * Total weight for key "capacity2" = 40 + 50 + 30 = 120;
+ * Total partitions = 3;
+ * Average partition weight for "capacity1" = 66 / 3 = 22;
+ * Average partition weight for "capacity2" = 120 / 3 = 40;
+ *
+ * Output =
+ * {
+ * "capacity1": 22,
+ * "capacity2": 40
+ * }
+ *
+ * @param partitionCapacityMap A map of partition capacity:
+ * <PartitionName or DEFAULT_PARTITION_KEY, <Capacity Key, Capacity
Number>>
+ * @return A map of partition weight: capacity key -> average partition
weight
+ */
+ public static Map<String, Integer> calculateAveragePartitionWeight(
Review comment:
Done
----------------------------------------------------------------
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]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]