-
Notifications
You must be signed in to change notification settings - Fork 615
HDDS-12617. Use DatanodeID as keys in NodeStateMap. #8100
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
Merged
Changes from 1 commit
Commits
Show all changes
2 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,6 +43,7 @@ | |
| import java.util.stream.Collectors; | ||
| import org.apache.hadoop.hdds.conf.ConfigurationSource; | ||
| import org.apache.hadoop.hdds.protocol.DatanodeDetails; | ||
| import org.apache.hadoop.hdds.protocol.DatanodeID; | ||
| import org.apache.hadoop.hdds.protocol.proto.HddsProtos; | ||
| import org.apache.hadoop.hdds.protocol.proto.HddsProtos.NodeOperationalState; | ||
| import org.apache.hadoop.hdds.protocol.proto.HddsProtos.NodeState; | ||
|
|
@@ -309,12 +310,11 @@ public void addNode(DatanodeDetails datanodeDetails, | |
| LayoutVersionProto layoutInfo) throws NodeAlreadyExistsException { | ||
| NodeStatus newNodeStatus = newNodeStatus(datanodeDetails, layoutInfo); | ||
| nodeStateMap.addNode(datanodeDetails, newNodeStatus, layoutInfo); | ||
| UUID dnID = datanodeDetails.getUuid(); | ||
| try { | ||
| updateLastKnownLayoutVersion(datanodeDetails, layoutInfo); | ||
| } catch (NodeNotFoundException ex) { | ||
| LOG.error("Inconsistent NodeStateMap! Datanode with ID {} was " + | ||
| "added but not found in map: {}", dnID, nodeStateMap); | ||
| throw new IllegalStateException("Inconsistent NodeStateMap! Datanode " | ||
| + datanodeDetails.getID() + " was added but not found in map: " + nodeStateMap); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -374,11 +374,10 @@ public int getPipelinesCount(DatanodeDetails datanodeDetails) { | |
| */ | ||
| public DatanodeInfo getNode(DatanodeDetails datanodeDetails) | ||
| throws NodeNotFoundException { | ||
| return getNode(datanodeDetails.getUuid()); | ||
| return getNode(datanodeDetails.getID()); | ||
| } | ||
|
|
||
| public DatanodeInfo getNode(UUID uuid) | ||
| throws NodeNotFoundException { | ||
| public DatanodeInfo getNode(DatanodeID uuid) throws NodeNotFoundException { | ||
| return nodeStateMap.getNodeInfo(uuid); | ||
| } | ||
|
|
||
|
|
@@ -389,7 +388,7 @@ public DatanodeInfo getNode(UUID uuid) | |
| */ | ||
| public void updateLastHeartbeatTime(DatanodeDetails datanodeDetails) | ||
| throws NodeNotFoundException { | ||
| nodeStateMap.getNodeInfo(datanodeDetails.getUuid()) | ||
| nodeStateMap.getNodeInfo(datanodeDetails.getID()) | ||
| .updateLastHeartbeatTime(); | ||
| } | ||
|
|
||
|
|
@@ -403,7 +402,7 @@ public void updateLastHeartbeatTime(DatanodeDetails datanodeDetails) | |
| public void updateLastKnownLayoutVersion(DatanodeDetails datanodeDetails, | ||
| LayoutVersionProto layoutInfo) | ||
| throws NodeNotFoundException { | ||
| nodeStateMap.getNodeInfo(datanodeDetails.getUuid()) | ||
| nodeStateMap.getNodeInfo(datanodeDetails.getID()) | ||
| .updateLastKnownLayoutVersion(layoutInfo); | ||
| } | ||
|
|
||
|
|
@@ -417,8 +416,7 @@ public void updateLastKnownLayoutVersion(DatanodeDetails datanodeDetails, | |
| public void updateNode(DatanodeDetails datanodeDetails, | ||
| LayoutVersionProto layoutInfo) | ||
| throws NodeNotFoundException { | ||
| DatanodeInfo datanodeInfo = | ||
| nodeStateMap.getNodeInfo(datanodeDetails.getUuid()); | ||
| final DatanodeInfo datanodeInfo = nodeStateMap.getNodeInfo(datanodeDetails.getID()); | ||
| NodeStatus newNodeStatus = newNodeStatus(datanodeDetails, layoutInfo); | ||
| LOG.info("updating node {} from {} to {} with status {}", | ||
| datanodeDetails.getUuidString(), | ||
|
|
@@ -440,7 +438,7 @@ public void updateNode(DatanodeDetails datanodeDetails, | |
| */ | ||
| public NodeStatus getNodeStatus(DatanodeDetails datanodeDetails) | ||
| throws NodeNotFoundException { | ||
| return nodeStateMap.getNodeStatus(datanodeDetails.getUuid()); | ||
| return nodeStateMap.getNodeStatus(datanodeDetails.getID()); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -582,12 +580,12 @@ public void setNodeOperationalState(DatanodeDetails dn, | |
| public void setNodeOperationalState(DatanodeDetails dn, | ||
| NodeOperationalState newState, | ||
| long stateExpiryEpochSec) throws NodeNotFoundException { | ||
| DatanodeInfo dni = nodeStateMap.getNodeInfo(dn.getUuid()); | ||
| final DatanodeID id = dn.getID(); | ||
| final DatanodeInfo dni = nodeStateMap.getNodeInfo(id); | ||
| NodeStatus oldStatus = dni.getNodeStatus(); | ||
| if (oldStatus.getOperationalState() != newState || | ||
| oldStatus.getOpStateExpiryEpochSeconds() != stateExpiryEpochSec) { | ||
| nodeStateMap.updateNodeOperationalState( | ||
| dn.getUuid(), newState, stateExpiryEpochSec); | ||
| nodeStateMap.updateNodeOperationalState(id, newState, stateExpiryEpochSec); | ||
| // 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 | ||
|
|
@@ -680,56 +678,47 @@ public void removePipeline(Pipeline pipeline) { | |
|
|
||
| /** | ||
| * Adds the given container to the specified datanode. | ||
| * | ||
| * @param uuid - datanode uuid | ||
| * @param containerId - containerID | ||
| * @throws NodeNotFoundException - if datanode is not known. For new datanode | ||
| * use addDatanodeInContainerMap call. | ||
| */ | ||
| public void addContainer(final UUID uuid, | ||
| public void addContainer(final DatanodeID datanodeID, | ||
| final ContainerID containerId) | ||
| throws NodeNotFoundException { | ||
| nodeStateMap.addContainer(uuid, containerId); | ||
| nodeStateMap.addContainer(datanodeID, containerId); | ||
| } | ||
|
|
||
| /** | ||
| * Removes the given container from the specified datanode. | ||
| * | ||
| * @param uuid - datanode uuid | ||
| * @param containerId - containerID | ||
| * @throws NodeNotFoundException - if datanode is not known. For new datanode | ||
| * use addDatanodeInContainerMap call. | ||
| */ | ||
| public void removeContainer(final UUID uuid, | ||
| public void removeContainer(final DatanodeID datanodeID, | ||
| final ContainerID containerId) | ||
| throws NodeNotFoundException { | ||
| nodeStateMap.removeContainer(uuid, containerId); | ||
| nodeStateMap.removeContainer(datanodeID, containerId); | ||
| } | ||
|
|
||
| /** | ||
| * Update set of containers available on a datanode. | ||
| * @param uuid - DatanodeID | ||
| * @param containerIds - Set of containerIDs | ||
| * @throws NodeNotFoundException - if datanode is not known. | ||
| */ | ||
| public void setContainers(UUID uuid, Set<ContainerID> containerIds) | ||
| public void setContainers(DatanodeID datanodeID, Set<ContainerID> containerIds) | ||
| throws NodeNotFoundException { | ||
| nodeStateMap.setContainers(uuid, containerIds); | ||
| nodeStateMap.setContainers(datanodeID, containerIds); | ||
| } | ||
|
|
||
| /** | ||
| * Return set of containerIDs available on a datanode. This is a copy of the | ||
| * set which resides inside NodeStateMap and hence can be modified without | ||
| * synchronization or side effects. | ||
| * @param uuid - DatanodeID | ||
| * @return - set of containerIDs | ||
| */ | ||
| public Set<ContainerID> getContainers(UUID uuid) | ||
| public Set<ContainerID> getContainers(DatanodeID uuid) | ||
|
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. Here. |
||
| throws NodeNotFoundException { | ||
| return nodeStateMap.getContainers(uuid); | ||
| } | ||
|
|
||
| public int getContainerCount(UUID uuid) | ||
| public int getContainerCount(DatanodeID uuid) | ||
|
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. Here as well. |
||
| throws NodeNotFoundException { | ||
| return nodeStateMap.getContainerCount(uuid); | ||
| } | ||
|
|
@@ -792,7 +781,7 @@ public synchronized void forceNodesToHealthyReadOnly() { | |
| try { | ||
| List<DatanodeInfo> nodes = nodeStateMap.getDatanodeInfos(null, HEALTHY); | ||
| for (DatanodeInfo node : nodes) { | ||
| nodeStateMap.updateNodeHealthState(node.getUuid(), | ||
| nodeStateMap.updateNodeHealthState(node.getID(), | ||
| HEALTHY_READONLY); | ||
| if (state2EventMap.containsKey(HEALTHY_READONLY)) { | ||
| // At this point pipeline creation is already frozen and the node's | ||
|
|
@@ -860,7 +849,7 @@ public synchronized void checkNodesHealth() { | |
|
|
||
| try { | ||
| for (DatanodeInfo node : nodeStateMap.getAllDatanodeInfos()) { | ||
| NodeStatus status = nodeStateMap.getNodeStatus(node.getUuid()); | ||
| NodeStatus status = nodeStateMap.getNodeStatus(node.getID()); | ||
| switch (status.getHealth()) { | ||
| case HEALTHY: | ||
| updateNodeLayoutVersionState(node, layoutMisMatchCondition, status, | ||
|
|
@@ -967,7 +956,7 @@ private void updateNodeState(DatanodeInfo node, Predicate<Long> condition, | |
| NodeState newHealthState = nodeHealthSM. | ||
| getNextState(status.getHealth(), lifeCycleEvent); | ||
| NodeStatus newStatus = | ||
| nodeStateMap.updateNodeHealthState(node.getUuid(), newHealthState); | ||
| nodeStateMap.updateNodeHealthState(node.getID(), newHealthState); | ||
| fireHealthStateEvent(newStatus.getHealth(), node); | ||
| } | ||
| } catch (InvalidStateTransitionException e) { | ||
|
|
@@ -1006,7 +995,7 @@ private void updateNodeLayoutVersionState(DatanodeInfo node, | |
| NodeState newHealthState = nodeHealthSM.getNextState(status.getHealth(), | ||
| lifeCycleEvent); | ||
| NodeStatus newStatus = | ||
| nodeStateMap.updateNodeHealthState(node.getUuid(), newHealthState); | ||
| nodeStateMap.updateNodeHealthState(node.getID(), newHealthState); | ||
| fireHealthStateEvent(newStatus.getHealth(), node); | ||
| } | ||
| } catch (InvalidStateTransitionException e) { | ||
|
|
@@ -1086,7 +1075,7 @@ ScheduledFuture unpause() { | |
| return healthCheckFuture; | ||
| } | ||
|
|
||
| protected void removeNode(DatanodeDetails datanodeDetails) { | ||
| nodeStateMap.removeNode(datanodeDetails); | ||
| protected void removeNode(DatanodeID datanodeID) { | ||
| nodeStateMap.removeNode(datanodeID); | ||
| } | ||
| } | ||
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
Oops, something went wrong.
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.
Can we change the variable name from
uuidtodatanodeIDto make it clear?Needs to be changed in 3 places.