xBis7 commented on code in PR #5882:
URL: https://github.com/apache/ozone/pull/5882#discussion_r1446074048
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/SCMNodeManager.java:
##########
@@ -1113,11 +1116,37 @@ public Map<String, Map<String, String>>
getNodeStatusInfo() {
map.put(httpsPort.getName().toString(),
httpsPort.getValue().toString());
}
+ double usedPec = calculateStoragePercentage(dni);
+ map.put(usedSpacePercent, usedPec + "%");
nodes.put(hostName, map);
}
return nodes;
}
+ /**
+ * Calculate the storage usage percentage of a DataNode node.
+ * @param dni DataNode node that needs to be calculated
+ * @return
+ */
+ public double calculateStoragePercentage(DatanodeInfo dni) {
+ double usedPec = 0;
+ 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();
Review Comment:
This can be simplified
```suggestion
capacity += storageReport.getCapacity();
scmUsed += storageReport.getScmUsed();
```
--
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]