kishorvpatil commented on a change in pull request #3213: [STORM-3588] add 
GenericResourceAwareSchedulingPriorityStrategy to accommodate generic resource 
in grading topologies
URL: https://github.com/apache/storm/pull/3213#discussion_r387629493
 
 

 ##########
 File path: storm-server/src/main/java/org/apache/storm/scheduler/Cluster.java
 ##########
 @@ -889,6 +889,20 @@ public double getClusterTotalMemoryResource() {
         return sum;
     }
 
+    @Override
+    public Map<String, Double> getClusterTotalGenericResource() {
+        Map<String, Double> ret = new HashMap<>();
+        for (SupervisorDetails sup : supervisors.values()) {
+            Map<String, Double> supGenericResources = 
sup.getTotalGenericResources();
+            for (Map.Entry<String, Double> entry : 
supGenericResources.entrySet()) {
+                String resourceName = entry.getKey();
+                Double amount = entry.getValue();
+                ret.put(resourceName, ret.getOrDefault(resourceName, 0.0) + 
amount);
 
 Review comment:
   A stream API could make it simpler to represent aggregation of maps:.
   `return supervisors.values().stream().flatMap(m -> 
m.getTotalGenericResources().entrySet().stream()).collect(Collectors.toMap(Map.Entry::getKey,
 Map.Entry::getValue, Double::sum));`

----------------------------------------------------------------
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

Reply via email to