-
Notifications
You must be signed in to change notification settings - Fork 9.2k
HDFS-16303. Improve handling of datanode lost while decommissioning #3675
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 all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b77f043
HDFS-16303. Improve handling of datanode lost while decommissioning
54ba1cb
HDFS-16303. Improve handling of datanode lost while decommissioning r…
43f1c01
HDFS-16303. Improve handling of datanode lost while decommissioning r…
44cd931
HDFS-16303. Improve handling of datanode lost while decommissioning r…
b57cbef
HDFS-16303. Improve handling of datanode lost while decommissioning r…
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 |
|---|---|---|
|
|
@@ -24,8 +24,11 @@ | |
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| import java.util.ArrayDeque; | ||
| import java.util.Comparator; | ||
| import java.util.List; | ||
| import java.util.PriorityQueue; | ||
| import java.util.Queue; | ||
| import java.util.stream.Stream; | ||
|
|
||
| /** | ||
| * This abstract class provides some base methods which are inherited by | ||
|
|
@@ -35,12 +38,20 @@ | |
| public abstract class DatanodeAdminMonitorBase | ||
| implements DatanodeAdminMonitorInterface, Configurable { | ||
|
|
||
| /** | ||
| * Sort by lastUpdate time descending order, such that unhealthy | ||
| * nodes are de-prioritized given they cannot be decommissioned. | ||
| */ | ||
| static final Comparator<DatanodeDescriptor> PENDING_NODES_QUEUE_COMPARATOR = | ||
| (dn1, dn2) -> Long.compare(dn2.getLastUpdate(), dn1.getLastUpdate()); | ||
|
|
||
| protected BlockManager blockManager; | ||
| protected Namesystem namesystem; | ||
| protected DatanodeAdminManager dnAdmin; | ||
| protected Configuration conf; | ||
|
|
||
| protected final Queue<DatanodeDescriptor> pendingNodes = new ArrayDeque<>(); | ||
| private final PriorityQueue<DatanodeDescriptor> pendingNodes = new PriorityQueue<>( | ||
|
Member
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. This change increases the time complexity of adding an element from O(1) to O(logN), however, the N is bounded to the number of DNs decommissioning (i.e. about several hundreds even in the large cluster). Therefore I think the performance effect is not critical. |
||
| PENDING_NODES_QUEUE_COMPARATOR); | ||
|
|
||
| /** | ||
| * The maximum number of nodes to track in outOfServiceNodeBlocks. | ||
|
|
@@ -151,4 +162,34 @@ public int getPendingNodeCount() { | |
| public Queue<DatanodeDescriptor> getPendingNodes() { | ||
| return pendingNodes; | ||
| } | ||
|
|
||
| /** | ||
| * If node "is dead while in Decommission In Progress", it cannot be decommissioned | ||
| * until it becomes healthy again. If there are more pendingNodes than can be tracked | ||
| * & some unhealthy tracked nodes, then re-queue the unhealthy tracked nodes | ||
| * to avoid blocking decommissioning of healthy nodes. | ||
| * | ||
| * @param unhealthyDns The unhealthy datanodes which may be re-queued | ||
| * @param numDecommissioningNodes The total number of nodes being decommissioned | ||
| * @return Stream of unhealthy nodes to be re-queued | ||
| */ | ||
| Stream<DatanodeDescriptor> getUnhealthyNodesToRequeue( | ||
| final List<DatanodeDescriptor> unhealthyDns, int numDecommissioningNodes) { | ||
| if (!unhealthyDns.isEmpty()) { | ||
| // Compute the number of unhealthy nodes to re-queue | ||
| final int numUnhealthyNodesToRequeue = | ||
| Math.min(numDecommissioningNodes - maxConcurrentTrackedNodes, unhealthyDns.size()); | ||
|
|
||
| LOG.warn("{} limit has been reached, re-queueing {} " | ||
| + "nodes which are dead while in Decommission In Progress.", | ||
| DFSConfigKeys.DFS_NAMENODE_DECOMMISSION_MAX_CONCURRENT_TRACKED_NODES, | ||
| numUnhealthyNodesToRequeue); | ||
|
|
||
| // Order unhealthy nodes by lastUpdate descending such that nodes | ||
| // which have been unhealthy the longest are preferred to be re-queued | ||
| return unhealthyDns.stream().sorted(PENDING_NODES_QUEUE_COMPARATOR.reversed()) | ||
| .limit(numUnhealthyNodesToRequeue); | ||
| } | ||
| return Stream.empty(); | ||
| } | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.