sreejasahithi commented on code in PR #8520:
URL: https://github.com/apache/ozone/pull/8520#discussion_r2198064210


##########
hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/hdds/scm/cli/datanode/ListInfoSubcommand.java:
##########
@@ -135,6 +149,37 @@ public void execute(ScmClient scmClient) throws 
IOException {
 
   private List<DatanodeWithAttributes> getAllNodes(ScmClient scmClient)
       throws IOException {
+
+    // If sorting is requested
+    if (usageSortingOptions != null && (usageSortingOptions.mostUsed || 
usageSortingOptions.leastUsed)) {
+      boolean sortByMostUsed = usageSortingOptions.mostUsed;
+      List<HddsProtos.DatanodeUsageInfoProto> usageInfos = 
scmClient.getDatanodeUsageInfo(sortByMostUsed, 
+          Integer.MAX_VALUE);
+
+      return usageInfos.stream()
+          .map(p -> {
+            String uuidStr = p.getNode().getUuid();
+            UUID parsedUuid = UUID.fromString(uuidStr);
+
+            try {
+              HddsProtos.Node node = scmClient.queryNode(parsedUuid);
+              long capacity = p.getCapacity();
+              long used = capacity - p.getRemaining();
+              double percentUsed = (capacity > 0) ? (used * 100.0) / capacity 
: 0.0;
+              return new DatanodeWithAttributes(
+                  DatanodeDetails.getFromProtoBuf(node.getNodeID()),
+                  node.getNodeOperationalStates(0),
+                  node.getNodeStates(0),
+                  used,
+                  capacity,
+                  percentUsed);
+            } catch (IOException e) {
+              return null;

Review Comment:
   Adding a log message here will not show up in any of the service logs unless 
we explicitly set OZONE_ROOT_LOGGER.



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