HBASE-6648 [0.92 UNIT TESTS] TestMasterObserver.testRegionTransitionOperations fails occasionally

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1383797 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2012-09-12 06:24:41 +00:00
parent 078cbdea49
commit b49ffdcda4
1 changed files with 16 additions and 8 deletions

View File

@ -31,6 +31,8 @@ import java.util.Map;
import java.util.NavigableMap;
import java.util.concurrent.CountDownLatch;
import junit.framework.Assert;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
@ -972,6 +974,8 @@ public class TestMasterObserver {
// move half the open regions from RS 0 to RS 1
HRegionServer rs = cluster.getRegionServer(0);
byte[] destRS = Bytes.toBytes(cluster.getRegionServer(1).getServerName().toString());
//Make sure no regions are in transition now
waitForRITtoBeZero(master);
List<HRegionInfo> openRegions = ProtobufUtil.getOnlineRegions(rs);
int moveCnt = openRegions.size()/2;
for (int i=0; i<moveCnt; i++) {
@ -981,24 +985,28 @@ public class TestMasterObserver {
openRegions.get(i).getEncodedNameAsBytes(), destRS));
}
}
// wait for assignments to finish
transRegions = mgr.getRegionStates().getRegionsInTransition().values();
for (RegionState state : transRegions) {
mgr.getRegionStates().waitOnRegionToClearRegionsInTransition(state.getRegion());
}
//Make sure no regions are in transition now
waitForRITtoBeZero(master);
// now trigger a balance
master.balanceSwitch(true);
boolean balanceRun = master.balance();
assertTrue("Coprocessor should be called on region rebalancing",
cp.wasBalanceCalled());
table.close();
} finally {
UTIL.deleteTable(TEST_TABLE);
}
}
private void waitForRITtoBeZero(HMaster master) throws Exception {
// wait for assignments to finish
AssignmentManager mgr = master.getAssignmentManager();
Collection<RegionState> transRegions =
mgr.getRegionStates().getRegionsInTransition().values();
for (RegionState state : transRegions) {
mgr.getRegionStates().waitOnRegionToClearRegionsInTransition(state.getRegion());
}
}
@org.junit.Rule
public org.apache.hadoop.hbase.ResourceCheckerJUnitRule cu =
new org.apache.hadoop.hbase.ResourceCheckerJUnitRule();