jianghuazhu commented on code in PR #5882:
URL: https://github.com/apache/ozone/pull/5882#discussion_r1443609849


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/SCMNodeManager.java:
##########
@@ -1109,6 +1112,23 @@ public Map<String, Map<String, String>> 
getNodeStatusInfo() {
         map.put(httpsPort.getName().toString(),
                   httpsPort.getValue().toString());
       }
+      List<StorageReportProto> storageReports = dni.getStorageReports();
+      if (storageReports != null && !storageReports.isEmpty()) {
+        long capacity = 0;
+        long scmUsed = 0;
+        for (StorageReportProto storageReport : storageReports) {
+          capacity = capacity + storageReport.getCapacity();
+          scmUsed = scmUsed + storageReport.getScmUsed();
+        }
+        double percent = (double) scmUsed / capacity;
+        percent = percent > 100.0 ? 100.0 : percent;
+        DecimalFormat decimalFormat = new DecimalFormat("#0.0000");
+        decimalFormat.setRoundingMode(RoundingMode.HALF_UP);
+        double usedPec = Double.valueOf(decimalFormat.format(percent)) * 100;
+        map.put(usedPercent, usedPec + "%");
+      } else {
+        map.put(usedPercent, "0%");

Review Comment:
   Thanks @xBis7  for the comment.
   I'll update soon.



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