Github user revans2 commented on a diff in the pull request:
https://github.com/apache/storm/pull/2385#discussion_r149162413
--- Diff:
storm-server/src/main/java/org/apache/storm/scheduler/Cluster.java ---
@@ -993,6 +1045,31 @@ public WorkerResources getWorkerResources(WorkerSlot
ws) {
}
@Override
+ public Map<String, Double> getAllScheduledResourcesForNode(String
nodeId) {
+ Map<String, Double> totalScheduledResources = new HashMap<>();
+ for (SchedulerAssignmentImpl assignment : assignments.values()) {
+ for (Entry<WorkerSlot, WorkerResources> entry :
+ assignment.getScheduledResources().entrySet()) {
+ if (nodeId.equals(entry.getKey().getNodeId())) {
+ WorkerResources resources = entry.getValue();
+ for (Map.Entry<String, Double> resourceEntry :
resources.get_resources().entrySet()) {
+ Double currentResourceValue =
totalScheduledResources.containsKey(resourceEntry.getKey()) ?
totalScheduledResources.get(resourceEntry.getKey()) : 0.0;
+
totalScheduledResources.put(resourceEntry.getKey().toString(),
currentResourceValue + ObjectReader.getDouble(resourceEntry.getValue()));
+ }
+
+ }
+ }
+ Double sharedOffHeap =
assignment.getNodeIdToTotalSharedOffHeapMemory().get(nodeId);
+ if (sharedOffHeap != null) {
+ String resourceName =
Constants.COMMON_OFFHEAP_MEMORY_RESOURCE_NAME;
+ Double currentResourceValue =
totalScheduledResources.containsKey(resourceName) ?
totalScheduledResources.get(resourceName) : 0.0;
--- End diff --
Here also getOrDefault.
---