HDFS-11682. TestBalancer.testBalancerWithStripedFile is flaky. (lei)

This commit is contained in:
Lei Xu 2017-06-15 11:04:50 -07:00
parent 5e7cfdca7b
commit 3f5108723c

View File

@ -938,19 +938,37 @@ private void runBalancer(Configuration conf, long totalUsedSpace,
throws Exception {
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,
@ -1942,7 +1960,7 @@ public void integrationTestWithStripedFile(Configuration conf) throws Exception
doTestBalancerWithStripedFile(conf);
}
@Test(timeout = 100000)
@Test(timeout = 200000)
public void testBalancerWithStripedFile() throws Exception {
Configuration conf = new Configuration();
initConfWithStripe(conf);