HDFS-10987. Make Decommission less expensive when lot of blocks present. Contributed by Brahma Reddy Battula.
(cherry picked from commit 332a61fd74
)
Conflicts:
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/DecommissionManager.java
This commit is contained in:
parent
2e153bc8ab
commit
c5a1303704
|
@ -388,23 +388,22 @@ public class DecommissionManager {
|
||||||
*/
|
*/
|
||||||
private final int numBlocksPerCheck;
|
private final int numBlocksPerCheck;
|
||||||
/**
|
/**
|
||||||
<<<<<<< HEAD
|
|
||||||
* The maximum number of nodes to check per tick.
|
* The maximum number of nodes to check per tick.
|
||||||
*/
|
*/
|
||||||
private final int numNodesPerCheck;
|
private final int numNodesPerCheck;
|
||||||
/**
|
/**
|
||||||
* The maximum number of nodes to track in decomNodeBlocks. A value of 0
|
* The maximum number of nodes to track in decomNodeBlocks. A value of 0
|
||||||
* means no limit.
|
* means no limit.
|
||||||
=======
|
|
||||||
* The maximum number of nodes to track in outOfServiceNodeBlocks.
|
|
||||||
* A value of 0 means no limit.
|
|
||||||
>>>>>>> 9dcbdbd... HDFS-9392. Admins support for maintenance state. Contributed by Ming Ma.
|
|
||||||
*/
|
*/
|
||||||
private final int maxConcurrentTrackedNodes;
|
private final int maxConcurrentTrackedNodes;
|
||||||
/**
|
/**
|
||||||
* The number of blocks that have been checked on this tick.
|
* The number of blocks that have been checked on this tick.
|
||||||
*/
|
*/
|
||||||
private int numBlocksChecked = 0;
|
private int numBlocksChecked = 0;
|
||||||
|
/**
|
||||||
|
* The number of blocks checked after (re)holding lock.
|
||||||
|
*/
|
||||||
|
private int numBlocksCheckedPerLock = 0;
|
||||||
/**
|
/**
|
||||||
* The number of nodes that have been checked on this tick. Used for
|
* The number of nodes that have been checked on this tick. Used for
|
||||||
* testing.
|
* testing.
|
||||||
|
@ -443,6 +442,7 @@ public class DecommissionManager {
|
||||||
}
|
}
|
||||||
// Reset the checked count at beginning of each iteration
|
// Reset the checked count at beginning of each iteration
|
||||||
numBlocksChecked = 0;
|
numBlocksChecked = 0;
|
||||||
|
numBlocksCheckedPerLock = 0;
|
||||||
numNodesChecked = 0;
|
numNodesChecked = 0;
|
||||||
// Check decom progress
|
// Check decom progress
|
||||||
namesystem.writeLock();
|
namesystem.writeLock();
|
||||||
|
@ -478,7 +478,8 @@ public class DecommissionManager {
|
||||||
|
|
||||||
while (it.hasNext()
|
while (it.hasNext()
|
||||||
&& !exceededNumBlocksPerCheck()
|
&& !exceededNumBlocksPerCheck()
|
||||||
&& !exceededNumNodesPerCheck()) {
|
&& !exceededNumNodesPerCheck()
|
||||||
|
&& namesystem.isRunning()) {
|
||||||
numNodesChecked++;
|
numNodesChecked++;
|
||||||
final Map.Entry<DatanodeDescriptor, AbstractList<BlockInfo>>
|
final Map.Entry<DatanodeDescriptor, AbstractList<BlockInfo>>
|
||||||
entry = it.next();
|
entry = it.next();
|
||||||
|
@ -608,7 +609,28 @@ public class DecommissionManager {
|
||||||
int decommissionOnlyReplicas = 0;
|
int decommissionOnlyReplicas = 0;
|
||||||
int underReplicatedInOpenFiles = 0;
|
int underReplicatedInOpenFiles = 0;
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
|
if (insufficientlyReplicated == null
|
||||||
|
&& numBlocksCheckedPerLock >= numBlocksPerCheck) {
|
||||||
|
// During fullscan insufficientlyReplicated will NOT be null, iterator
|
||||||
|
// will be DN's iterator. So should not yield lock, otherwise
|
||||||
|
// ConcurrentModificationException could occur.
|
||||||
|
// Once the fullscan done, iterator will be a copy. So can yield the
|
||||||
|
// lock.
|
||||||
|
// Yielding is required in case of block number is greater than the
|
||||||
|
// configured per-iteration-limit.
|
||||||
|
namesystem.writeUnlock();
|
||||||
|
try {
|
||||||
|
LOG.debug("Yielded lock during decommission check");
|
||||||
|
Thread.sleep(0, 500);
|
||||||
|
} catch (InterruptedException ignored) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// reset
|
||||||
|
numBlocksCheckedPerLock = 0;
|
||||||
|
namesystem.writeLock();
|
||||||
|
}
|
||||||
numBlocksChecked++;
|
numBlocksChecked++;
|
||||||
|
numBlocksCheckedPerLock++;
|
||||||
final BlockInfo block = it.next();
|
final BlockInfo block = it.next();
|
||||||
// Remove the block from the list if it's no longer in the block map,
|
// Remove the block from the list if it's no longer in the block map,
|
||||||
// e.g. the containing file has been deleted
|
// e.g. the containing file has been deleted
|
||||||
|
|
Loading…
Reference in New Issue