sodonnel commented on a change in pull request #1344: HDDS-1982 Extend
SCMNodeManager to support decommission and maintenance states
URL: https://github.com/apache/hadoop/pull/1344#discussion_r321198662
##########
File path:
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/NodeStateManager.java
##########
@@ -578,39 +587,33 @@ private void checkNodesHealth() {
Predicate<Long> deadNodeCondition =
(lastHbTime) -> lastHbTime < staleNodeDeadline;
try {
- for (NodeState state : NodeState.values()) {
- List<UUID> nodes = nodeStateMap.getNodes(state);
- for (UUID id : nodes) {
- DatanodeInfo node = nodeStateMap.getNodeInfo(id);
- switch (state) {
- case HEALTHY:
- // Move the node to STALE if the last heartbeat time is less than
- // configured stale-node interval.
- updateNodeState(node, staleNodeCondition, state,
- NodeLifeCycleEvent.TIMEOUT);
- break;
- case STALE:
- // Move the node to DEAD if the last heartbeat time is less than
- // configured dead-node interval.
- updateNodeState(node, deadNodeCondition, state,
- NodeLifeCycleEvent.TIMEOUT);
- // Restore the node if we have received heartbeat before configured
- // stale-node interval.
- updateNodeState(node, healthyNodeCondition, state,
- NodeLifeCycleEvent.RESTORE);
- break;
- case DEAD:
- // Resurrect the node if we have received heartbeat before
- // configured stale-node interval.
- updateNodeState(node, healthyNodeCondition, state,
- NodeLifeCycleEvent.RESURRECT);
- break;
- // We don't do anything for DECOMMISSIONING and DECOMMISSIONED in
- // heartbeat processing.
- case DECOMMISSIONING:
- case DECOMMISSIONED:
- default:
- }
+ for(DatanodeInfo node : nodeStateMap.getAllDatanodeInfos()) {
+ NodeState state =
+ nodeStateMap.getNodeStatus(node.getUuid()).getHealth();
+ switch (state) {
+ case HEALTHY:
+ // Move the node to STALE if the last heartbeat time is less than
+ // configured stale-node interval.
+ updateNodeState(node, staleNodeCondition, state,
+ NodeLifeCycleEvent.TIMEOUT);
+ break;
+ case STALE:
+ // Move the node to DEAD if the last heartbeat time is less than
+ // configured dead-node interval.
+ updateNodeState(node, deadNodeCondition, state,
+ NodeLifeCycleEvent.TIMEOUT);
+ // Restore the node if we have received heartbeat before configured
+ // stale-node interval.
+ updateNodeState(node, healthyNodeCondition, state,
+ NodeLifeCycleEvent.RESTORE);
+ break;
+ case DEAD:
+ // Resurrect the node if we have received heartbeat before
+ // configured stale-node interval.
+ updateNodeState(node, healthyNodeCondition, state,
+ NodeLifeCycleEvent.RESURRECT);
+ break;
+ default:
}
Review comment:
This loop didn't need to change for this change, but it seemed to be a
double loop when it didn't really need to be, and was doing extra lookups from
the NodeStateMap, so this makes it cleaner to read and slightly more efficient
too.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]