lpavanvenkat opened a new pull request, #11487:
URL: https://github.com/apache/ozone/pull/11487

   ## What changes were proposed in this pull request?
   `NodeStateMap.toString()` in SCM currently prints only the total number of 
datanodes, for example:
   `Total number of nodes: 5`
   This patch adds the number of datanodes in each health state (`NodeState`), 
so the output becomes:
   `Total number of nodes: 5, HEALTHY: 3, STALE: 1, DEAD: 1, HEALTHY_READONLY: 
0`
   **Background:** the per-state counts were part of the original 
implementation in HDDS-212. When HDDS-1982 split a node's status into an 
operational state and a health state for decommission and maintenance support, 
it removed `getNodeCount(NodeState)`. The loop in `toString()` stopped 
compiling, so it was commented out with a TODO and never restored.
   **Approach:** the loop now goes through `NodeState.values()` and calls the 
existing `getNodeCount(NodeOperationalState, NodeState)` with a `null` 
operational state. That counts nodes in each health state regardless of their 
operational state (IN_SERVICE, DECOMMISSIONING, IN_MAINTENANCE, etc.), the same 
thing the removed method did. No new helpers or locking were added. Each count 
takes the map's read lock separately, as `getTotalNodeCount()` already does. 
The method's Javadoc already says the string is for logging only and may be 
slightly inconsistent if node states change while it is being built.
   `toString()` is used only in two error messages in `NodeStateManager` (an 
`IllegalStateException` in `addNode()` and a `LOG.error` in the heartbeat 
check). No code parses the output, so changing the format is safe.
   ## What is the link to the Apache JIRA
   https://issues.apache.org/jira/browse/HDDS-16718
   ## How was this patch tested?
   - Added `TestNodeStateMap#testToString`, which checks the output for an 
empty map and for five nodes across mixed health and operational states (3 
HEALTHY, 1 STALE, 1 DEAD).
   - Ran `mvn -pl :hdds-server-scm test -Dtest=TestNodeStateMap`: all 8 tests 
pass.
   - Ran `./hadoop-ozone/dev-support/checks/checkstyle.sh`: 0 violations.


-- 
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]

Reply via email to