|
@@ -938,19 +938,37 @@ public class TestBalancer {
|
|
throws Exception {
|
|
throws Exception {
|
|
waitForHeartBeat(totalUsedSpace, totalCapacity, client, cluster);
|
|
waitForHeartBeat(totalUsedSpace, totalCapacity, client, cluster);
|
|
|
|
|
|
- // start rebalancing
|
|
|
|
- Collection<URI> namenodes = DFSUtil.getInternalNsRpcUris(conf);
|
|
|
|
- final int r = runBalancer(namenodes, p, conf);
|
|
|
|
- if (conf.getInt(DFSConfigKeys.DFS_DATANODE_BALANCE_MAX_NUM_CONCURRENT_MOVES_KEY,
|
|
|
|
- DFSConfigKeys.DFS_DATANODE_BALANCE_MAX_NUM_CONCURRENT_MOVES_DEFAULT) ==0) {
|
|
|
|
- assertEquals(ExitStatus.NO_MOVE_PROGRESS.getExitCode(), r);
|
|
|
|
- return;
|
|
|
|
- } else {
|
|
|
|
- assertEquals(ExitStatus.SUCCESS.getExitCode(), r);
|
|
|
|
|
|
+ int retry = 5;
|
|
|
|
+ while (retry > 0) {
|
|
|
|
+ // start rebalancing
|
|
|
|
+ Collection<URI> namenodes = DFSUtil.getInternalNsRpcUris(conf);
|
|
|
|
+ final int run = runBalancer(namenodes, p, conf);
|
|
|
|
+ if (conf.getInt(
|
|
|
|
+ DFSConfigKeys.DFS_DATANODE_BALANCE_MAX_NUM_CONCURRENT_MOVES_KEY,
|
|
|
|
+ DFSConfigKeys.DFS_DATANODE_BALANCE_MAX_NUM_CONCURRENT_MOVES_DEFAULT)
|
|
|
|
+ == 0) {
|
|
|
|
+ assertEquals(ExitStatus.NO_MOVE_PROGRESS.getExitCode(), run);
|
|
|
|
+ return;
|
|
|
|
+ } else {
|
|
|
|
+ assertEquals(ExitStatus.SUCCESS.getExitCode(), run);
|
|
|
|
+ }
|
|
|
|
+ waitForHeartBeat(totalUsedSpace, totalCapacity, client, cluster);
|
|
|
|
+ LOG.info(" .");
|
|
|
|
+ try {
|
|
|
|
+ waitForBalancer(totalUsedSpace, totalCapacity, client, cluster, p,
|
|
|
|
+ excludedNodes);
|
|
|
|
+ } catch (TimeoutException e) {
|
|
|
|
+ // See HDFS-11682. NN may not get heartbeat to reflect the newest
|
|
|
|
+ // block changes.
|
|
|
|
+ retry--;
|
|
|
|
+ if (retry == 0) {
|
|
|
|
+ throw e;
|
|
|
|
+ }
|
|
|
|
+ LOG.warn("The cluster has not balanced yet, retry...");
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
- waitForHeartBeat(totalUsedSpace, totalCapacity, client, cluster);
|
|
|
|
- LOG.info(" .");
|
|
|
|
- waitForBalancer(totalUsedSpace, totalCapacity, client, cluster, p, excludedNodes);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
private static int runBalancer(Collection<URI> namenodes,
|
|
private static int runBalancer(Collection<URI> namenodes,
|
|
@@ -1942,7 +1960,7 @@ public class TestBalancer {
|
|
doTestBalancerWithStripedFile(conf);
|
|
doTestBalancerWithStripedFile(conf);
|
|
}
|
|
}
|
|
|
|
|
|
- @Test(timeout = 100000)
|
|
|
|
|
|
+ @Test(timeout = 200000)
|
|
public void testBalancerWithStripedFile() throws Exception {
|
|
public void testBalancerWithStripedFile() throws Exception {
|
|
Configuration conf = new Configuration();
|
|
Configuration conf = new Configuration();
|
|
initConfWithStripe(conf);
|
|
initConfWithStripe(conf);
|