You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "adoroszlai (via GitHub)" <gi...@apache.org> on 2023/02/03 07:53:50 UTC

[GitHub] [ozone] adoroszlai commented on a diff in pull request #4209: HDDS-7799. Add container count to datanode usage info

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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org