You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by GitBox <gi...@apache.org> on 2021/09/10 12:46:01 UTC
[GitHub] [hadoop] ferhui commented on a change in pull request #3366: HDFS-16203. Discover datanodes with unbalanced block pool usage by th…
ferhui commented on a change in pull request #3366:
URL: https://github.com/apache/hadoop/pull/3366#discussion_r706137278
##########
File path: hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
##########
@@ -6537,14 +6537,45 @@ public String getLiveNodes() {
if (node.getUpgradeDomain() != null) {
innerinfo.put("upgradeDomain", node.getUpgradeDomain());
}
+ StorageReport[] storageReports = node.getStorageReports();
+ innerinfo.put("blockPoolUsedPercentStdDev",
+ getBlockPoolUsedPercentStdDev(storageReports));
info.put(node.getXferAddrWithHostname(), innerinfo.build());
}
return JSON.toString(info);
}
+ /**
+ * Return the standard deviation of storage block pool usage.
+ */
+ @VisibleForTesting
+ public float getBlockPoolUsedPercentStdDev(StorageReport[] storageReports) {
+ ArrayList<Float> usagePercentList = new ArrayList<>();
+ float totalUsagePercent = 0.0f;
+ float dev = 0.0f;
+
+ if (storageReports.length == 0) {
+ return dev;
+ }
+
+ for (StorageReport s : storageReports) {
+ usagePercentList.add(s.getBlockPoolUsagePercent());
+ totalUsagePercent += s.getBlockPoolUsagePercent();
+ }
+
+ totalUsagePercent /= storageReports.length;
+ Collections.sort(usagePercentList);
Review comment:
Unnecessary sort
--
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: common-issues-unsubscribe@hadoop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org