|
@@ -138,6 +138,8 @@ public class Dispatcher {
|
|
private final boolean connectToDnViaHostname;
|
|
private final boolean connectToDnViaHostname;
|
|
private BlockPlacementPolicies placementPolicies;
|
|
private BlockPlacementPolicies placementPolicies;
|
|
|
|
|
|
|
|
+ private long maxIterationTime;
|
|
|
|
+
|
|
static class Allocator {
|
|
static class Allocator {
|
|
private final int max;
|
|
private final int max;
|
|
private int count = 0;
|
|
private int count = 0;
|
|
@@ -346,13 +348,19 @@ public class Dispatcher {
|
|
|
|
|
|
/** Dispatch the move to the proxy source & wait for the response. */
|
|
/** Dispatch the move to the proxy source & wait for the response. */
|
|
private void dispatch() {
|
|
private void dispatch() {
|
|
- LOG.info("Start moving " + this);
|
|
|
|
- assert !(reportedBlock instanceof DBlockStriped);
|
|
|
|
-
|
|
|
|
Socket sock = new Socket();
|
|
Socket sock = new Socket();
|
|
DataOutputStream out = null;
|
|
DataOutputStream out = null;
|
|
DataInputStream in = null;
|
|
DataInputStream in = null;
|
|
try {
|
|
try {
|
|
|
|
+ if (source.isIterationOver()){
|
|
|
|
+ LOG.info("Cancel moving " + this +
|
|
|
|
+ " as iteration is already cancelled due to" +
|
|
|
|
+ " dfs.balancer.max-iteration-time is passed.");
|
|
|
|
+ throw new IOException("Block move cancelled.");
|
|
|
|
+ }
|
|
|
|
+ LOG.info("Start moving " + this);
|
|
|
|
+ assert !(reportedBlock instanceof DBlockStriped);
|
|
|
|
+
|
|
sock.connect(
|
|
sock.connect(
|
|
NetUtils.createSocketAddr(target.getDatanodeInfo().
|
|
NetUtils.createSocketAddr(target.getDatanodeInfo().
|
|
getXferAddr(Dispatcher.this.connectToDnViaHostname)),
|
|
getXferAddr(Dispatcher.this.connectToDnViaHostname)),
|
|
@@ -760,7 +768,10 @@ public class Dispatcher {
|
|
* Check if the iteration is over
|
|
* Check if the iteration is over
|
|
*/
|
|
*/
|
|
public boolean isIterationOver() {
|
|
public boolean isIterationOver() {
|
|
- return (Time.monotonicNow()-startTime > MAX_ITERATION_TIME);
|
|
|
|
|
|
+ if (maxIterationTime < 0){
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ return (Time.monotonicNow()-startTime > maxIterationTime);
|
|
}
|
|
}
|
|
|
|
|
|
/** Add a task */
|
|
/** Add a task */
|
|
@@ -908,8 +919,6 @@ public class Dispatcher {
|
|
return blocksToReceive > 0;
|
|
return blocksToReceive > 0;
|
|
}
|
|
}
|
|
|
|
|
|
- private static final long MAX_ITERATION_TIME = 20 * 60 * 1000L; // 20 mins
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* This method iteratively does the following: it first selects a block to
|
|
* This method iteratively does the following: it first selects a block to
|
|
* move, then sends a request to the proxy source to start the block move
|
|
* move, then sends a request to the proxy source to start the block move
|
|
@@ -990,7 +999,7 @@ public class Dispatcher {
|
|
}
|
|
}
|
|
|
|
|
|
if (isIterationOver()) {
|
|
if (isIterationOver()) {
|
|
- LOG.info("The maximum iteration time (" + MAX_ITERATION_TIME/1000
|
|
|
|
|
|
+ LOG.info("The maximum iteration time (" + maxIterationTime/1000
|
|
+ " seconds) has been reached. Stopping " + this);
|
|
+ " seconds) has been reached. Stopping " + this);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1013,14 +1022,14 @@ public class Dispatcher {
|
|
int maxNoMoveInterval, Configuration conf) {
|
|
int maxNoMoveInterval, Configuration conf) {
|
|
this(nnc, includedNodes, excludedNodes, movedWinWidth,
|
|
this(nnc, includedNodes, excludedNodes, movedWinWidth,
|
|
moverThreads, dispatcherThreads, maxConcurrentMovesPerNode,
|
|
moverThreads, dispatcherThreads, maxConcurrentMovesPerNode,
|
|
- 0L, 0L, 0, maxNoMoveInterval, conf);
|
|
|
|
|
|
+ 0L, 0L, 0, maxNoMoveInterval, -1, conf);
|
|
}
|
|
}
|
|
|
|
|
|
Dispatcher(NameNodeConnector nnc, Set<String> includedNodes,
|
|
Dispatcher(NameNodeConnector nnc, Set<String> includedNodes,
|
|
Set<String> excludedNodes, long movedWinWidth, int moverThreads,
|
|
Set<String> excludedNodes, long movedWinWidth, int moverThreads,
|
|
int dispatcherThreads, int maxConcurrentMovesPerNode,
|
|
int dispatcherThreads, int maxConcurrentMovesPerNode,
|
|
- long getBlocksSize, long getBlocksMinBlockSize,
|
|
|
|
- int blockMoveTimeout, int maxNoMoveInterval, Configuration conf) {
|
|
|
|
|
|
+ long getBlocksSize, long getBlocksMinBlockSize, int blockMoveTimeout,
|
|
|
|
+ int maxNoMoveInterval, long maxIterationTime, Configuration conf) {
|
|
this.nnc = nnc;
|
|
this.nnc = nnc;
|
|
this.excludedNodes = excludedNodes;
|
|
this.excludedNodes = excludedNodes;
|
|
this.includedNodes = includedNodes;
|
|
this.includedNodes = includedNodes;
|
|
@@ -1047,6 +1056,7 @@ public class Dispatcher {
|
|
HdfsClientConfigKeys.DFS_CLIENT_USE_DN_HOSTNAME,
|
|
HdfsClientConfigKeys.DFS_CLIENT_USE_DN_HOSTNAME,
|
|
HdfsClientConfigKeys.DFS_CLIENT_USE_DN_HOSTNAME_DEFAULT);
|
|
HdfsClientConfigKeys.DFS_CLIENT_USE_DN_HOSTNAME_DEFAULT);
|
|
placementPolicies = new BlockPlacementPolicies(conf, null, cluster, null);
|
|
placementPolicies = new BlockPlacementPolicies(conf, null, cluster, null);
|
|
|
|
+ this.maxIterationTime = maxIterationTime;
|
|
}
|
|
}
|
|
|
|
|
|
public DistributedFileSystem getDistributedFileSystem() {
|
|
public DistributedFileSystem getDistributedFileSystem() {
|