ZanderXu commented on code in PR #4606: URL: https://github.com/apache/hadoop/pull/4606#discussion_r927154231
########## hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/metrics/RBFMetrics.java: ########## @@ -544,28 +548,30 @@ public String getNodeUsage() { final Map<String, Map<String, Object>> info = new HashMap<>(); try { - RouterRpcServer rpcServer = this.router.getRpcServer(); - DatanodeInfo[] live = rpcServer.getDatanodeReport( - DatanodeReportType.LIVE, false, timeOut); - - if (live.length > 0) { - float totalDfsUsed = 0; - float[] usages = new float[live.length]; - int i = 0; - for (DatanodeInfo dn : live) { - usages[i++] = dn.getDfsUsedPercent(); - totalDfsUsed += dn.getDfsUsedPercent(); - } - totalDfsUsed /= live.length; - Arrays.sort(usages); - median = usages[usages.length / 2]; - max = usages[usages.length - 1]; - min = usages[0]; - - for (i = 0; i < usages.length; i++) { - dev += (usages[i] - totalDfsUsed) * (usages[i] - totalDfsUsed); + if (this.enableGetDNUsage) { + RouterRpcServer rpcServer = this.router.getRpcServer(); + DatanodeInfo[] live = rpcServer.getDatanodeReport( + DatanodeReportType.LIVE, false, timeOut); + + if (live.length > 0) { + float totalDfsUsed = 0; + float[] usages = new float[live.length]; + int i = 0; + for (DatanodeInfo dn : live) { + usages[i++] = dn.getDfsUsedPercent(); Review Comment: Yes, `rpcServer.getDatanodeReport()` is expensive. As the number of DNs or downstream nameservices in the cluster increases, it will become more and more expensive. such as 1w+ DNs, 5w+ DNs, 20+ NSs, 50+ NSs. -- 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-unsubscr...@hadoop.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-issues-h...@hadoop.apache.org