HBASE-4492 TestRollingRestart Fails Intermittently(Ted yu and Ram)

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1177175 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
ramkrishna 2011-09-29 06:29:16 +00:00
parent f3cda40473
commit aaa8c0e38e
2 changed files with 13 additions and 4 deletions

View File

@ -1461,6 +1461,7 @@ public class AssignmentManager extends ZooKeeperListener {
LOG.error(errorMsg, t); LOG.error(errorMsg, t);
return; return;
} }
}
LOG.warn("Failed assignment of " + LOG.warn("Failed assignment of " +
state.getRegion().getRegionNameAsString() + " to " + state.getRegion().getRegionNameAsString() + " to " +
plan.getDestination() + ", trying to assign elsewhere instead; " + plan.getDestination() + ", trying to assign elsewhere instead; " +
@ -1477,7 +1478,6 @@ public class AssignmentManager extends ZooKeeperListener {
} }
} }
} }
}
} }
private void debugLog(HRegionInfo region, String string) { private void debugLog(HRegionInfo region, String string) {

View File

@ -210,7 +210,11 @@ public class TestRollingRestart {
waitForRSShutdownToStartAndFinish(activeMaster, waitForRSShutdownToStartAndFinish(activeMaster,
metaServer.getRegionServer().getServerName()); metaServer.getRegionServer().getServerName());
log("Waiting for no more RIT"); log("Waiting for no more RIT");
blockUntilNoRIT(zkw, master); long start = System.currentTimeMillis();
do {
blockUntilNoRIT(zkw, master);
} while (getNumberOfOnlineRegions(cluster) < numRegions
&& System.currentTimeMillis()-start < 60000);
log("Verifying there are " + numRegions + " assigned on cluster"); log("Verifying there are " + numRegions + " assigned on cluster");
assertRegionsAssigned(cluster, regions); assertRegionsAssigned(cluster, regions);
assertEquals(expectedNumRS, cluster.getRegionServerThreads().size()); assertEquals(expectedNumRS, cluster.getRegionServerThreads().size());
@ -345,12 +349,17 @@ public class TestRollingRestart {
return null; return null;
} }
private void assertRegionsAssigned(MiniHBaseCluster cluster, private int getNumberOfOnlineRegions(MiniHBaseCluster cluster) {
Set<String> expectedRegions) throws IOException {
int numFound = 0; int numFound = 0;
for (RegionServerThread rst : cluster.getLiveRegionServerThreads()) { for (RegionServerThread rst : cluster.getLiveRegionServerThreads()) {
numFound += rst.getRegionServer().getNumberOfOnlineRegions(); numFound += rst.getRegionServer().getNumberOfOnlineRegions();
} }
return numFound;
}
private void assertRegionsAssigned(MiniHBaseCluster cluster,
Set<String> expectedRegions) throws IOException {
int numFound = getNumberOfOnlineRegions(cluster);
if (expectedRegions.size() > numFound) { if (expectedRegions.size() > numFound) {
log("Expected to find " + expectedRegions.size() + " but only found" log("Expected to find " + expectedRegions.size() + " but only found"
+ " " + numFound); + " " + numFound);