-
Notifications
You must be signed in to change notification settings - Fork 591
HDDS-2607 DeadNodeHandler should not remove replica for a dead maintenance node #343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
adoroszlai
merged 3 commits into
apache:HDDS-1880-Decom
from
sodonnel:HDDS-2607-dead-handling
Dec 17, 2019
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,23 +80,13 @@ private enum NodeLifeCycleEvent { | |
| TIMEOUT, RESTORE, RESURRECT | ||
| } | ||
|
|
||
| private enum NodeOperationStateEvent { | ||
| START_DECOMMISSION, COMPLETE_DECOMMISSION, START_MAINTENANCE, | ||
| ENTER_MAINTENANCE, RETURN_TO_SERVICE | ||
| } | ||
|
|
||
| private static final Logger LOG = LoggerFactory | ||
| .getLogger(NodeStateManager.class); | ||
|
|
||
| /** | ||
| * StateMachine for node lifecycle. | ||
| */ | ||
| private final StateMachine<NodeState, NodeLifeCycleEvent> nodeHealthSM; | ||
| /** | ||
| * StateMachine for node operational state. | ||
| */ | ||
| private final StateMachine<HddsProtos.NodeOperationalState, | ||
| NodeOperationStateEvent> nodeOpStateSM; | ||
| /** | ||
| * This is the map which maintains the current state of all datanodes. | ||
| */ | ||
|
|
@@ -112,7 +102,7 @@ private enum NodeOperationStateEvent { | |
| /** | ||
| * Maps the event to be triggered when a node state us updated. | ||
| */ | ||
| private final Map<NodeStatus, Event<DatanodeDetails>> state2EventMap; | ||
| private final Map<NodeState, Event<DatanodeDetails>> state2EventMap; | ||
| /** | ||
| * ExecutorService used for scheduling heartbeat processing thread. | ||
| */ | ||
|
|
@@ -162,10 +152,7 @@ public NodeStateManager(Configuration conf, EventPublisher eventPublisher) { | |
| this.state2EventMap = new HashMap<>(); | ||
| initialiseState2EventMap(); | ||
| Set<NodeState> finalStates = new HashSet<>(); | ||
| Set<HddsProtos.NodeOperationalState> opStateFinalStates = new HashSet<>(); | ||
| this.nodeHealthSM = new StateMachine<>(NodeState.HEALTHY, finalStates); | ||
| this.nodeOpStateSM = new StateMachine<>( | ||
| NodeOperationalState.IN_SERVICE, opStateFinalStates); | ||
| initializeStateMachines(); | ||
| heartbeatCheckerIntervalMs = HddsServerUtil | ||
| .getScmheartbeatCheckerInterval(conf); | ||
|
|
@@ -190,12 +177,10 @@ public NodeStateManager(Configuration conf, EventPublisher eventPublisher) { | |
| * Populates state2event map. | ||
| */ | ||
| private void initialiseState2EventMap() { | ||
| state2EventMap.put(NodeStatus.inServiceStale(), SCMEvents.STALE_NODE); | ||
| state2EventMap.put(NodeStatus.inServiceDead(), SCMEvents.DEAD_NODE); | ||
| state2EventMap.put(NodeStatus.inServiceHealthy(), | ||
| state2EventMap.put(NodeState.STALE, SCMEvents.STALE_NODE); | ||
| state2EventMap.put(NodeState.DEAD, SCMEvents.DEAD_NODE); | ||
| state2EventMap.put(NodeState.HEALTHY, | ||
| SCMEvents.NON_HEALTHY_TO_HEALTHY_NODE); | ||
| // TODO - add whatever events are needed for decomm / maint to stale, dead, | ||
| // healthy | ||
| } | ||
|
|
||
| /* | ||
|
|
@@ -238,36 +223,6 @@ private void initializeStateMachines() { | |
| NodeState.STALE, NodeState.HEALTHY, NodeLifeCycleEvent.RESTORE); | ||
| nodeHealthSM.addTransition( | ||
| NodeState.DEAD, NodeState.HEALTHY, NodeLifeCycleEvent.RESURRECT); | ||
|
|
||
| nodeOpStateSM.addTransition( | ||
| NodeOperationalState.IN_SERVICE, NodeOperationalState.DECOMMISSIONING, | ||
| NodeOperationStateEvent.START_DECOMMISSION); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct, this can be removed. I have made this change. |
||
| nodeOpStateSM.addTransition( | ||
| NodeOperationalState.DECOMMISSIONING, NodeOperationalState.IN_SERVICE, | ||
| NodeOperationStateEvent.RETURN_TO_SERVICE); | ||
| nodeOpStateSM.addTransition( | ||
| NodeOperationalState.DECOMMISSIONING, | ||
| NodeOperationalState.DECOMMISSIONED, | ||
| NodeOperationStateEvent.COMPLETE_DECOMMISSION); | ||
| nodeOpStateSM.addTransition( | ||
| NodeOperationalState.DECOMMISSIONED, NodeOperationalState.IN_SERVICE, | ||
| NodeOperationStateEvent.RETURN_TO_SERVICE); | ||
|
|
||
| nodeOpStateSM.addTransition( | ||
| NodeOperationalState.IN_SERVICE, | ||
| NodeOperationalState.ENTERING_MAINTENANCE, | ||
| NodeOperationStateEvent.START_MAINTENANCE); | ||
| nodeOpStateSM.addTransition( | ||
| NodeOperationalState.ENTERING_MAINTENANCE, | ||
| NodeOperationalState.IN_SERVICE, | ||
| NodeOperationStateEvent.RETURN_TO_SERVICE); | ||
| nodeOpStateSM.addTransition( | ||
| NodeOperationalState.ENTERING_MAINTENANCE, | ||
| NodeOperationalState.IN_MAINTENANCE, | ||
| NodeOperationStateEvent.ENTER_MAINTENANCE); | ||
| nodeOpStateSM.addTransition( | ||
| NodeOperationalState.IN_MAINTENANCE, NodeOperationalState.IN_SERVICE, | ||
| NodeOperationStateEvent.RETURN_TO_SERVICE); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -280,7 +235,7 @@ private void initializeStateMachines() { | |
| public void addNode(DatanodeDetails datanodeDetails) | ||
| throws NodeAlreadyExistsException { | ||
| nodeStateMap.addNode(datanodeDetails, new NodeStatus( | ||
| nodeOpStateSM.getInitialState(), nodeHealthSM.getInitialState())); | ||
| NodeOperationalState.IN_SERVICE, nodeHealthSM.getInitialState())); | ||
| eventPublisher.fireEvent(SCMEvents.NEW_NODE, datanodeDetails); | ||
| } | ||
|
|
||
|
|
@@ -404,8 +359,18 @@ public List<DatanodeInfo> getAllNodes() { | |
| public void setNodeOperationalState(DatanodeDetails dn, | ||
| NodeOperationalState newState) throws NodeNotFoundException { | ||
| DatanodeInfo dni = nodeStateMap.getNodeInfo(dn.getUuid()); | ||
| if (dni.getNodeStatus().getOperationalState() != newState) { | ||
| NodeStatus oldStatus = dni.getNodeStatus(); | ||
| if (oldStatus.getOperationalState() != newState) { | ||
| nodeStateMap.updateNodeOperationalState(dn.getUuid(), newState); | ||
| // This will trigger an event based on the nodes health when the | ||
| // operational state changes. Eg a node that was IN_MAINTENANCE goes | ||
| // to IN_SERVICE + HEALTHY. This will trigger the HEALTHY node event to | ||
| // create new pipelines. OTH, if the nodes goes IN_MAINTENANCE to | ||
| // IN_SERVICE + DEAD, it will trigger the dead node handler to remove its | ||
| // container replicas. Sometimes the event will do nothing, but it will | ||
| // not do any harm either. Eg DECOMMISSIONING -> DECOMMISSIONED + HEALTHY | ||
| // but the pipeline creation logic will ignore decommissioning nodes. | ||
| fireHealthStateEvent(oldStatus.getHealth(), dn); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -706,9 +671,7 @@ private void updateNodeState(DatanodeInfo node, Predicate<Long> condition, | |
| getNextState(status.getHealth(), lifeCycleEvent); | ||
| NodeStatus newStatus = | ||
| nodeStateMap.updateNodeHealthState(node.getUuid(), newHealthState); | ||
| if (state2EventMap.containsKey(newStatus)) { | ||
| eventPublisher.fireEvent(state2EventMap.get(newStatus), node); | ||
| } | ||
| fireHealthStateEvent(newStatus.getHealth(), node); | ||
| } | ||
| } catch (InvalidStateTransitionException e) { | ||
| LOG.warn("Invalid state transition of node {}." + | ||
|
|
@@ -717,6 +680,14 @@ private void updateNodeState(DatanodeInfo node, Predicate<Long> condition, | |
| } | ||
| } | ||
|
|
||
| private void fireHealthStateEvent(HddsProtos.NodeState health, | ||
| DatanodeDetails node) { | ||
| Event<DatanodeDetails> event = state2EventMap.get(health); | ||
| if (event != null) { | ||
| eventPublisher.fireEvent(event, node); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void close() { | ||
| executorService.shutdown(); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to get this message for a node
ENTERING_MAINTENANCE? If so, shouldn't it be ignored here as well?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a node goes dead while "entering maintenance" then it should be handled as a dead node. The reason, is that we have not yet determine if all the containers on the host are sufficiently replicated. If it goes dead before that check has completed and the node has moved into IN_MAINTENANCE, then it must be handled as a dead node as normal.
This is the same for a node which is DECOMMISSIONING and not yet reached DECOMMISSIONED.
Unless the node has reached its end state (IN_MAINTENANCE or DECOMMISSIONED), if it goes dead the workflow is aborted and it is handled just like any other dead node.