You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "djordje-mijatovic (via GitHub)" <gi...@apache.org> on 2023/02/01 19:24:00 UTC

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

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. Bu maybe we could go even one more step further. What about adding containerCount into DatanodeDetails, or even adding a Set<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: 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