jianghuazhu commented on code in PR #5882:
URL: https://github.com/apache/ozone/pull/5882#discussion_r1448534677
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/SCMNodeManager.java:
##########
@@ -1113,11 +1117,78 @@ public Map<String, Map<String, String>>
getNodeStatusInfo() {
map.put(httpsPort.getName().toString(),
httpsPort.getValue().toString());
}
+ String capacity = calculateStorageCapacity(dni);
+ map.put(totalCapacity, capacity);
+ double usedPec = calculateStoragePercentage(dni);
+ map.put(usedSpacePercent, usedPec + "%");
nodes.put(hostName, map);
}
return nodes;
}
+ /**
+ * Calculate the storage capacity of the DataNode node.
+ * @param dni DataNode node that needs to be calculated.
+ * @return
+ */
+ public String calculateStorageCapacity(DatanodeInfo dni) {
+ long capacityByte = 0;
+ List<StorageReportProto> storageReports = dni.getStorageReports();
+ if (storageReports != null && !storageReports.isEmpty()) {
+ for (StorageReportProto storageReport : storageReports) {
+ capacityByte += storageReport.getCapacity();
+ }
+ }
+
+ double ua = capacityByte;
+ String unit = "B";
+ if (ua > 1024) {
+ ua = ua / 1024;
+ unit = "KB";
Review Comment:
Thanks to @xBis7 for your patient guidance.
I will update later.
--
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]