HBASE-15864 Reuse the testing helper to wait regions in transition
This commit is contained in:
parent
a27504c701
commit
7a84ee262f
|
@ -3887,13 +3887,20 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility {
|
|||
/**
|
||||
* Wait until no regions in transition.
|
||||
* @param timeout How long to wait.
|
||||
* @throws Exception
|
||||
* @throws IOException
|
||||
*/
|
||||
public void waitUntilNoRegionsInTransition(
|
||||
final long timeout) throws Exception {
|
||||
public void waitUntilNoRegionsInTransition(final long timeout) throws IOException {
|
||||
waitFor(timeout, predicateNoRegionsInTransition());
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait until no regions in transition. (time limit 15min)
|
||||
* @throws IOException
|
||||
*/
|
||||
public void waitUntilNoRegionsInTransition() throws IOException {
|
||||
waitUntilNoRegionsInTransition(15 * 60000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait until labels is ready in VisibilityLabelsCache.
|
||||
* @param timeoutMillis
|
||||
|
|
|
@ -253,10 +253,7 @@ public class TestRegionRebalancing {
|
|||
Thread.sleep(200);
|
||||
} catch (InterruptedException e) {}
|
||||
}
|
||||
RegionStates regionStates = UTIL.getHBaseCluster().getMaster().getAssignmentManager().getRegionStates();
|
||||
while (!regionStates.getRegionsInTransition().isEmpty()) {
|
||||
Threads.sleep(100);
|
||||
}
|
||||
UTIL.waitUntilNoRegionsInTransition();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -250,20 +250,14 @@ public class TestHCM {
|
|||
|
||||
Table t = TEST_UTIL.createTable(tn, cf);
|
||||
TEST_UTIL.waitTableAvailable(tn);
|
||||
TEST_UTIL.waitUntilNoRegionsInTransition();
|
||||
|
||||
while(TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager().
|
||||
getRegionStates().isRegionsInTransition()){
|
||||
Thread.sleep(1);
|
||||
}
|
||||
final ConnectionImplementation hci = (ConnectionImplementation)TEST_UTIL.getConnection();
|
||||
try (RegionLocator l = TEST_UTIL.getConnection().getRegionLocator(tn)) {
|
||||
while (l.getRegionLocation(rk).getPort() != sn.getPort()) {
|
||||
TEST_UTIL.getHBaseAdmin().move(l.getRegionLocation(rk).getRegionInfo().
|
||||
getEncodedNameAsBytes(), Bytes.toBytes(sn.toString()));
|
||||
while (TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager().
|
||||
getRegionStates().isRegionsInTransition()) {
|
||||
Thread.sleep(1);
|
||||
}
|
||||
TEST_UTIL.waitUntilNoRegionsInTransition();
|
||||
hci.clearRegionCache(tn);
|
||||
}
|
||||
Assert.assertNotNull(hci.clusterStatusListener);
|
||||
|
@ -741,9 +735,7 @@ public class TestHCM {
|
|||
HMaster master = TEST_UTIL.getMiniHBaseCluster().getMaster();
|
||||
|
||||
// We can wait for all regions to be online, that makes log reading easier when debugging
|
||||
while (master.getAssignmentManager().getRegionStates().isRegionsInTransition()) {
|
||||
Thread.sleep(1);
|
||||
}
|
||||
TEST_UTIL.waitUntilNoRegionsInTransition();
|
||||
|
||||
// Now moving the region to the second server
|
||||
HRegionLocation toMove = conn.getCachedLocation(TABLE_NAME, ROW).getRegionLocation();
|
||||
|
@ -1034,9 +1026,7 @@ public class TestHCM {
|
|||
HMaster master = TEST_UTIL.getMiniHBaseCluster().getMaster();
|
||||
|
||||
// We can wait for all regions to be online, that makes log reading easier when debugging
|
||||
while (master.getAssignmentManager().getRegionStates().isRegionsInTransition()) {
|
||||
Thread.sleep(1);
|
||||
}
|
||||
TEST_UTIL.waitUntilNoRegionsInTransition();
|
||||
|
||||
Put put = new Put(ROW_X);
|
||||
put.addColumn(FAM_NAM, ROW_X, ROW_X);
|
||||
|
|
|
@ -51,11 +51,9 @@ import org.apache.hadoop.hbase.client.ConnectionFactory;
|
|||
import org.apache.hadoop.hbase.client.MasterSwitchType;
|
||||
import org.apache.hadoop.hbase.client.RegionLocator;
|
||||
import org.apache.hadoop.hbase.client.Table;
|
||||
import org.apache.hadoop.hbase.master.AssignmentManager;
|
||||
import org.apache.hadoop.hbase.master.HMaster;
|
||||
import org.apache.hadoop.hbase.master.MasterCoprocessorHost;
|
||||
import org.apache.hadoop.hbase.master.RegionPlan;
|
||||
import org.apache.hadoop.hbase.master.RegionState;
|
||||
import org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv;
|
||||
import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
|
||||
import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
|
||||
|
@ -1915,17 +1913,13 @@ public class TestMasterObserver {
|
|||
master.balanceSwitch(false);
|
||||
|
||||
// wait for assignments to finish, if any
|
||||
AssignmentManager mgr = master.getAssignmentManager();
|
||||
Set<RegionState> transRegions = mgr.getRegionStates().getRegionsInTransition();
|
||||
for (RegionState state : transRegions) {
|
||||
mgr.getRegionStates().waitOnRegionToClearRegionsInTransition(state.getRegion());
|
||||
}
|
||||
UTIL.waitUntilNoRegionsInTransition();
|
||||
|
||||
// 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);
|
||||
UTIL.waitUntilNoRegionsInTransition();
|
||||
List<HRegionInfo> openRegions = ProtobufUtil.getOnlineRegions(rs.getRSRpcServices());
|
||||
int moveCnt = openRegions.size()/2;
|
||||
for (int i=0; i<moveCnt; i++) {
|
||||
|
@ -1936,7 +1930,7 @@ public class TestMasterObserver {
|
|||
}
|
||||
}
|
||||
//Make sure no regions are in transition now
|
||||
waitForRITtoBeZero(master);
|
||||
UTIL.waitUntilNoRegionsInTransition();
|
||||
// now trigger a balance
|
||||
master.balanceSwitch(true);
|
||||
boolean balanceRun = master.balance();
|
||||
|
@ -1949,15 +1943,6 @@ public class TestMasterObserver {
|
|||
}
|
||||
}
|
||||
|
||||
private void waitForRITtoBeZero(HMaster master) throws Exception {
|
||||
// wait for assignments to finish
|
||||
AssignmentManager mgr = master.getAssignmentManager();
|
||||
Set<RegionState> transRegions = mgr.getRegionStates().getRegionsInTransition();
|
||||
for (RegionState state : transRegions) {
|
||||
mgr.getRegionStates().waitOnRegionToClearRegionsInTransition(state.getRegion());
|
||||
}
|
||||
}
|
||||
|
||||
@Test (timeout=180000)
|
||||
public void testTableDescriptorsEnumeration() throws Exception {
|
||||
MiniHBaseCluster cluster = UTIL.getHBaseCluster();
|
||||
|
|
|
@ -515,11 +515,8 @@ public class TestHFileOutputFormat2 {
|
|||
if (shouldChangeRegions) {
|
||||
LOG.info("Changing regions in table");
|
||||
admin.disableTable(table.getName());
|
||||
while(util.getMiniHBaseCluster().getMaster().getAssignmentManager().
|
||||
getRegionStates().isRegionsInTransition()) {
|
||||
Threads.sleep(200);
|
||||
LOG.info("Waiting on table to finish disabling");
|
||||
}
|
||||
util.waitUntilNoRegionsInTransition();
|
||||
|
||||
util.deleteTable(table.getName());
|
||||
byte[][] newSplitKeys = generateRandomSplitKeys(14);
|
||||
table = util.createTable(TABLE_NAME, FAMILIES, newSplitKeys);
|
||||
|
|
|
@ -80,15 +80,8 @@ public class TestTableDeleteFamilyHandler {
|
|||
// Create a table of three families. This will assign a region.
|
||||
TEST_UTIL.createTable(TABLENAME, FAMILIES);
|
||||
Table t = TEST_UTIL.getConnection().getTable(TABLENAME);
|
||||
while(TEST_UTIL.getMiniHBaseCluster().getMaster().getAssignmentManager()
|
||||
.getRegionStates().getRegionsInTransition().size() > 0) {
|
||||
Thread.sleep(100);
|
||||
}
|
||||
// Create multiple regions in all the three column families
|
||||
while(TEST_UTIL.getMiniHBaseCluster().getMaster().getAssignmentManager()
|
||||
.getRegionStates().getRegionsInTransition().size() > 0) {
|
||||
Thread.sleep(100);
|
||||
}
|
||||
TEST_UTIL.waitUntilNoRegionsInTransition();
|
||||
|
||||
// Load the table with data for all families
|
||||
TEST_UTIL.loadTable(t, FAMILIES);
|
||||
|
||||
|
|
|
@ -149,29 +149,12 @@ public class TestSplitTransactionOnCluster {
|
|||
this.admin.close();
|
||||
}
|
||||
|
||||
private HRegionInfo getAndCheckSingleTableRegion(final List<HRegion> regions) {
|
||||
private HRegionInfo getAndCheckSingleTableRegion(final List<HRegion> regions)
|
||||
throws IOException, InterruptedException {
|
||||
assertEquals(1, regions.size());
|
||||
HRegionInfo hri = regions.get(0).getRegionInfo();
|
||||
return waitOnRIT(hri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Often region has not yet fully opened. If we try to use it -- do a move for instance -- it
|
||||
* will fail silently if the region is not yet opened.
|
||||
* @param hri Region to check if in Regions In Transition... wait until out of transition before
|
||||
* returning
|
||||
* @return Passed in <code>hri</code>
|
||||
*/
|
||||
private HRegionInfo waitOnRIT(final HRegionInfo hri) {
|
||||
// Close worked but we are going to open the region elsewhere. Before going on, make sure
|
||||
// this completes.
|
||||
while (TESTING_UTIL.getHBaseCluster().getMaster().getAssignmentManager().
|
||||
getRegionStates().isRegionInTransition(hri)) {
|
||||
LOG.info("Waiting on region in transition: " +
|
||||
TESTING_UTIL.getHBaseCluster().getMaster().getAssignmentManager().getRegionStates().
|
||||
getRegionTransitionState(hri));
|
||||
Threads.sleep(10);
|
||||
}
|
||||
TESTING_UTIL.getMiniHBaseCluster().getMaster().getAssignmentManager()
|
||||
.waitOnRegionToClearRegionsInTransition(hri, 600000);
|
||||
return hri;
|
||||
}
|
||||
|
||||
|
@ -210,13 +193,7 @@ public class TestSplitTransactionOnCluster {
|
|||
observer.latch.await();
|
||||
|
||||
LOG.info("Waiting for region to come out of RIT");
|
||||
TESTING_UTIL.waitFor(60000, 1000, new Waiter.Predicate<Exception>() {
|
||||
@Override
|
||||
public boolean evaluate() throws Exception {
|
||||
RegionStates regionStates = cluster.getMaster().getAssignmentManager().getRegionStates();
|
||||
return !regionStates.isRegionInTransition(hri.getEncodedName());
|
||||
}
|
||||
});
|
||||
cluster.getMaster().getAssignmentManager().waitOnRegionToClearRegionsInTransition(hri, 60000);
|
||||
} finally {
|
||||
admin.setBalancerRunning(true, false);
|
||||
cluster.getMaster().setCatalogJanitorEnabled(true);
|
||||
|
|
|
@ -1683,8 +1683,7 @@ public class TestHBaseFsckOneRS extends BaseTestHBaseFsck {
|
|||
st.prepare();
|
||||
st.stepsBeforePONR(regionServer, regionServer, false);
|
||||
AssignmentManager am = cluster.getMaster().getAssignmentManager();
|
||||
Set<RegionState> regionsInTransition = am.getRegionStates().getRegionsInTransition();
|
||||
for (RegionState state : regionsInTransition) {
|
||||
for (RegionState state : am.getRegionStates().getRegionsInTransition()) {
|
||||
am.regionOffline(state.getRegion());
|
||||
}
|
||||
Map<HRegionInfo, ServerName> regionsMap = new HashMap<HRegionInfo, ServerName>();
|
||||
|
|
|
@ -75,15 +75,6 @@ public class TestOfflineMetaRebuildHole extends OfflineMetaRebuildTestCore {
|
|||
|
||||
LOG.info("Waiting for no more RIT");
|
||||
TEST_UTIL.waitUntilNoRegionsInTransition(60000);
|
||||
LOG.info("No more RIT in ZK, now doing final test verification");
|
||||
int tries = 60;
|
||||
while(TEST_UTIL.getHBaseCluster()
|
||||
.getMaster().getAssignmentManager().getRegionStates().getRegionsInTransition().size() > 0 &&
|
||||
tries-- > 0) {
|
||||
LOG.info("Waiting for RIT: "+TEST_UTIL.getHBaseCluster()
|
||||
.getMaster().getAssignmentManager().getRegionStates().getRegionsInTransition());
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
|
||||
// Meta still messed up.
|
||||
assertEquals(1, scanMeta());
|
||||
|
|
|
@ -84,14 +84,6 @@ public class TestOfflineMetaRebuildOverlap extends OfflineMetaRebuildTestCore {
|
|||
LOG.info("Waiting for no more RIT");
|
||||
TEST_UTIL.waitUntilNoRegionsInTransition(60000);
|
||||
LOG.info("No more RIT in ZK, now doing final test verification");
|
||||
int tries = 60;
|
||||
while(TEST_UTIL.getHBaseCluster()
|
||||
.getMaster().getAssignmentManager().getRegionStates().getRegionsInTransition().size() > 0 &&
|
||||
tries-- > 0) {
|
||||
LOG.info("Waiting for RIT: "+TEST_UTIL.getHBaseCluster()
|
||||
.getMaster().getAssignmentManager().getRegionStates().getRegionsInTransition());
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
|
||||
// Meta still messed up.
|
||||
assertEquals(1, scanMeta());
|
||||
|
|
Loading…
Reference in New Issue