djordje-mijatovic commented on code in PR #4209:
URL: https://github.com/apache/ozone/pull/4209#discussion_r1093642072


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMClientProtocolServer.java:
##########
@@ -1103,11 +1104,24 @@ public List<HddsProtos.DatanodeUsageInfoProto> 
getDatanodeUsageInfo(
 
     // return count number of DatanodeUsageInfoProto
     return datanodeUsageInfoList.stream()
-        .map(each -> each.toProto(clientVersion))
+        .map(each -> each.toProto(clientVersion,
+                getContainerCount(each.getDatanodeDetails())))
         .limit(count)
         .collect(Collectors.toList());
   }
 
+  private long getContainerCount(DatanodeDetails datanodeDetails) {
+    long containerCount = -1;
+    try {
+      Set<ContainerID> containers = scm.getScmNodeManager()
+              .getContainers(datanodeDetails);
+      containerCount = containers.size();
+    } catch (NodeNotFoundException e) {
+      LOG.error("Node not found, error: ", e);
+    }
+    return containerCount;
+  }

Review Comment:
   @adoroszlai Done. But maybe we could go even one more step further. What 
about adding containerCount into DatanodeDetails, or even better... we could 
add a Set of ContainerID into DatanodeDetails?



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to