adoroszlai commented on code in PR #4209:
URL: https://github.com/apache/ozone/pull/4209#discussion_r1095450528


##########
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:
   > What about adding containerCount into DatanodeDetails, or even better... 
we could add a Set of ContainerID into DatanodeDetails?
   
   I don't think we should add either of those extra pieces of info in 
`DatanodeDetails`.  It contains static information, while container count or 
container IDs are dynamically changing.  The latter could also grow too large.



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