This is an automated email from the ASF dual-hosted git repository.
chungen0126 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new 9d1fc42952f HDDS-16718. Include node health state counts in
NodeStateMap.toString() (#11487)
9d1fc42952f is described below
commit 9d1fc42952f7be19dca88c4cc6cfca562c587b6a
Author: L Pavan Venkat <[email protected]>
AuthorDate: Wed Oct 14 06:58:50 2026 +0530
HDDS-16718. Include node health state counts in NodeStateMap.toString()
(#11487)
---
.../apache/hadoop/hdds/scm/node/states/NodeStateMap.java | 8 +++-----
.../hadoop/hdds/scm/node/states/TestNodeStateMap.java | 13 +++++++++++++
2 files changed, 16 insertions(+), 5 deletions(-)
diff --git
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/states/NodeStateMap.java
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/states/NodeStateMap.java
index 67c487e3ba1..feb83e6d219 100644
---
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/states/NodeStateMap.java
+++
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/states/NodeStateMap.java
@@ -322,13 +322,11 @@ public void removeContainer(DatanodeID datanodeID,
ContainerID containerID) thro
*/
@Override
public String toString() {
- // TODO - fix this method to include the commented out values
StringBuilder builder = new StringBuilder();
builder.append("Total number of nodes: ").append(getTotalNodeCount());
- // for (NodeState state : NodeState.values()) {
- // builder.append("Number of nodes in ").append(state).append(" state: ")
- // .append(getNodeCount(state));
- // }
+ for (NodeState state : NodeState.values()) {
+ builder.append(", ").append(state).append(":
").append(getNodeCount(null, state));
+ }
return builder.toString();
}
diff --git
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/node/states/TestNodeStateMap.java
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/node/states/TestNodeStateMap.java
index d0b9c53d0e7..7a665e4d9df 100644
---
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/node/states/TestNodeStateMap.java
+++
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/node/states/TestNodeStateMap.java
@@ -154,6 +154,19 @@ private void runTestGetNode(long opExpiryEpochSeconds)
map.getNodeCount(NodeOperationalState.DECOMMISSIONING, null));
}
+ @Test
+ public void testToString() throws NodeAlreadyExistsException {
+ assertEquals("Total number of nodes: 0, HEALTHY: 0, STALE: 0, DEAD: 0,
HEALTHY_READONLY: 0", map.toString());
+
+ addRandomNodeWithState(NodeOperationalState.IN_SERVICE, NodeState.HEALTHY,
0);
+ addRandomNodeWithState(NodeOperationalState.IN_SERVICE, NodeState.HEALTHY,
0);
+ addRandomNodeWithState(NodeOperationalState.DECOMMISSIONING,
NodeState.HEALTHY, 0);
+ addRandomNodeWithState(NodeOperationalState.IN_SERVICE, NodeState.STALE,
0);
+ addRandomNodeWithState(NodeOperationalState.IN_MAINTENANCE,
NodeState.DEAD, 0);
+
+ assertEquals("Total number of nodes: 5, HEALTHY: 3, STALE: 1, DEAD: 1,
HEALTHY_READONLY: 0", map.toString());
+ }
+
/**
* Test if container list is iterable even if it's modified from other
thread.
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]