adoroszlai commented on code in PR #4209:
URL: https://github.com/apache/ozone/pull/4209#discussion_r1099134607
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMClientProtocolServer.java:
##########
@@ -1048,18 +1047,15 @@ public List<HddsProtos.DatanodeUsageInfoProto>
getDatanodeUsageInfo(
*/
private HddsProtos.DatanodeUsageInfoProto getUsageInfoFromDatanodeDetails(
DatanodeDetails node, int clientVersion) {
- SCMNodeStat stat = scm.getScmNodeManager().getNodeStat(node).get();
-
- long capacity = stat.getCapacity().get();
- long used = stat.getScmUsed().get();
- long remaining = stat.getRemaining().get();
-
- return HddsProtos.DatanodeUsageInfoProto.newBuilder()
- .setCapacity(capacity)
- .setUsed(used)
- .setRemaining(remaining)
- .setNode(node.toProto(clientVersion))
- .build();
+ DatanodeUsageInfo usageInfo = scm.getScmNodeManager().getUsageInfo(node);
+ try {
+ int containerCount = scm.getScmNodeManager().getContainers(node).size();
+ usageInfo.setContainerCount(containerCount);
+ } catch (NodeNotFoundException ex) {
+ LOG.error("Received container report from unknown datanode {}.",
+ node, ex);
+ }
Review Comment:
Please move this code to `SCMNodeManager.getUsageInfo`.
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/SCMNodeManager.java:
##########
@@ -827,7 +827,14 @@ public List<DatanodeUsageInfo> getMostOrLeastUsedDatanodes(
// list
for (DatanodeDetails node : healthyNodes) {
SCMNodeStat stat = getNodeStatInternal(node);
- datanodeUsageInfoList.add(new DatanodeUsageInfo(node, stat));
+ DatanodeUsageInfo datanodeUsageInfo = new DatanodeUsageInfo(node, stat);
+ try {
+ datanodeUsageInfo.setContainerCount(getContainers(node).size());
+ } catch (NodeNotFoundException ex) {
+ LOG.error("Received container report from unknown datanode {}.",
+ node, ex);
+ }
Review Comment:
Please call `getUsageInfo`.
--
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]