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 { throws Exception {
waitForHeartBeat(totalUsedSpace, totalCapacity, client, cluster); waitForHeartBeat(totalUsedSpace, totalCapacity, client, cluster);
int retry = 5;
while (retry > 0) {
// start rebalancing // start rebalancing
Collection<URI> namenodes = DFSUtil.getInternalNsRpcUris(conf); Collection<URI> namenodes = DFSUtil.getInternalNsRpcUris(conf);
final int r = runBalancer(namenodes, p, conf); final int run = runBalancer(namenodes, p, conf);
if (conf.getInt(DFSConfigKeys.DFS_DATANODE_BALANCE_MAX_NUM_CONCURRENT_MOVES_KEY, if (conf.getInt(
DFSConfigKeys.DFS_DATANODE_BALANCE_MAX_NUM_CONCURRENT_MOVES_DEFAULT) ==0) { DFSConfigKeys.DFS_DATANODE_BALANCE_MAX_NUM_CONCURRENT_MOVES_KEY,
assertEquals(ExitStatus.NO_MOVE_PROGRESS.getExitCode(), r); DFSConfigKeys.DFS_DATANODE_BALANCE_MAX_NUM_CONCURRENT_MOVES_DEFAULT)
== 0) {
assertEquals(ExitStatus.NO_MOVE_PROGRESS.getExitCode(), run);
return; return;
} else { } else {
assertEquals(ExitStatus.SUCCESS.getExitCode(), r); assertEquals(ExitStatus.SUCCESS.getExitCode(), run);
} }
waitForHeartBeat(totalUsedSpace, totalCapacity, client, cluster); waitForHeartBeat(totalUsedSpace, totalCapacity, client, cluster);
LOG.info(" ."); LOG.info(" .");
waitForBalancer(totalUsedSpace, totalCapacity, client, cluster, p, excludedNodes); 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;
}
} }
private static int runBalancer(Collection<URI> namenodes, private static int runBalancer(Collection<URI> namenodes,
@ -1942,7 +1960,7 @@ public void integrationTestWithStripedFile(Configuration conf) throws Exception
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);