use of org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv in project hbase by apache.
the class TestRegionSplitAndSeparateChildren method testSplitTableRegionAndSeparateChildRegions.
@Test
public void testSplitTableRegionAndSeparateChildRegions() throws Exception {
final TableName tableName = TableName.valueOf(name.getMethodName());
final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
RegionInfo[] regions = MasterProcedureTestingUtility.createTable(procExec, tableName, null, columnFamilyName);
insertData(UTIL, tableName, rowCount, startRowNum, columnFamilyName);
int splitRowNum = startRowNum + rowCount / 2;
byte[] splitKey = Bytes.toBytes("" + splitRowNum);
assertTrue("not able to find a splittable region", regions != null);
assertTrue("not able to find a splittable region", regions.length == 1);
// Split region of the table
long procId = procExec.submitProcedure(new SplitTableRegionProcedure(procExec.getEnvironment(), regions[0], splitKey));
// Wait the completion
ProcedureTestingUtility.waitProcedure(procExec, procId);
ProcedureTestingUtility.assertProcNotFailed(procExec, procId);
assertTrue("not able to split table", UTIL.getHBaseCluster().getRegions(tableName).size() == 2);
// disable table
UTIL.getAdmin().disableTable(tableName);
Thread.sleep(500);
// stop master
UTIL.getHBaseCluster().stopMaster(0);
UTIL.getHBaseCluster().waitOnMaster(0);
Thread.sleep(500);
// restart master
JVMClusterUtil.MasterThread t = UTIL.getHBaseCluster().startMaster();
Thread.sleep(500);
UTIL.invalidateConnection();
// enable table
UTIL.getAdmin().enableTable(tableName);
Thread.sleep(500);
List<HRegion> tableRegions = UTIL.getHBaseCluster().getRegions(tableName);
assertEquals("Table region not correct.", 2, tableRegions.size());
Map<RegionInfo, ServerName> regionInfoMap = UTIL.getHBaseCluster().getMaster().getAssignmentManager().getRegionStates().getRegionAssignments();
assertNotEquals(regionInfoMap.get(tableRegions.get(0).getRegionInfo()), regionInfoMap.get(tableRegions.get(1).getRegionInfo()));
}
use of org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv in project hbase by apache.
the class TestCloseRegionWhileRSCrash method testRetryBackoff.
@Test
public void testRetryBackoff() throws IOException, InterruptedException {
HRegionServer srcRs = UTIL.getRSForFirstRegionInTable(TABLE_NAME);
RegionInfo region = srcRs.getRegions(TABLE_NAME).get(0).getRegionInfo();
HRegionServer dstRs = UTIL.getOtherRegionServer(srcRs);
ProcedureExecutor<MasterProcedureEnv> procExec = UTIL.getMiniHBaseCluster().getMaster().getMasterProcedureExecutor();
procExec.submitProcedure(new DummyServerProcedure(srcRs.getServerName()));
ARRIVE.await();
UTIL.getMiniHBaseCluster().killRegionServer(srcRs.getServerName());
UTIL.waitFor(30000, () -> procExec.getProcedures().stream().anyMatch(p -> p instanceof ServerCrashProcedure));
Thread t = new Thread(() -> {
try {
UTIL.getAdmin().move(region.getEncodedNameAsBytes(), dstRs.getServerName());
} catch (IOException e) {
LOG.info("Failed move of {}", region.getRegionNameAsString(), e);
}
});
t.start();
// wait until we enter the WAITING_TIMEOUT state
ProcedureTestUtil.waitUntilProcedureWaitingTimeout(UTIL, TransitRegionStateProcedure.class, 30000);
// wait until the timeout value increase three times
ProcedureTestUtil.waitUntilProcedureTimeoutIncrease(UTIL, TransitRegionStateProcedure.class, 3);
// close connection to make sure that we can not finish the TRSP
final HMaster master = UTIL.getMiniHBaseCluster().getMaster();
master.getConnection().close();
RESUME.countDown();
UTIL.waitFor(30000, () -> !master.isAlive());
// here we start a new master
HMaster master2 = UTIL.getMiniHBaseCluster().startMaster().getMaster();
LOG.info("Master2 {}, joining move thread", master2.getServerName());
t.join();
// forceNewPlan to true if there is a server crash
try (Table table = UTIL.getConnection().getTable(TABLE_NAME)) {
table.put(new Put(Bytes.toBytes(1)).addColumn(CF, Bytes.toBytes("cq"), Bytes.toBytes(1)));
}
// set forceNewPlan to true if there is a server crash.
try (Table table = UTIL.getConnection().getTable(TABLE_NAME)) {
table.put(new Put(Bytes.toBytes(1)).addColumn(CF, Bytes.toBytes("cq"), Bytes.toBytes(1)));
}
}
use of org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv in project hbase by apache.
the class TestModifyTableWhileMerging method test.
@Test
public void test() throws Exception {
TableDescriptor tableDescriptor = client.getDescriptor();
ProcedureExecutor<MasterProcedureEnv> executor = UTIL.getMiniHBaseCluster().getMaster().getMasterProcedureExecutor();
MasterProcedureEnv env = executor.getEnvironment();
List<RegionInfo> regionInfos = admin.getRegions(TABLE_NAME);
MergeTableRegionsProcedure mergeTableRegionsProcedure = new MergeTableRegionsProcedure(UTIL.getMiniHBaseCluster().getMaster().getMasterProcedureExecutor().getEnvironment(), new RegionInfo[] { regionInfos.get(0), regionInfos.get(1) }, false);
ModifyTableProcedure modifyTableProcedure = new ModifyTableProcedure(env, tableDescriptor);
long procModify = executor.submitProcedure(modifyTableProcedure);
UTIL.waitFor(30000, () -> executor.getProcedures().stream().filter(p -> p instanceof ModifyTableProcedure).map(p -> (ModifyTableProcedure) p).anyMatch(p -> TABLE_NAME.equals(p.getTableName())));
long proc = executor.submitProcedure(mergeTableRegionsProcedure);
UTIL.waitFor(3000000, () -> UTIL.getMiniHBaseCluster().getMaster().getMasterProcedureExecutor().isFinished(procModify));
Assert.assertEquals("Modify Table procedure should success!", ProcedureProtos.ProcedureState.SUCCESS, modifyTableProcedure.getState());
}
use of org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv in project hbase by apache.
the class TestServerCrashProcedureCarryingMetaStuck method test.
@Test
public void test() throws Exception {
RegionServerThread rsThread = null;
for (RegionServerThread t : UTIL.getMiniHBaseCluster().getRegionServerThreads()) {
if (!t.getRegionServer().getRegions(TableName.META_TABLE_NAME).isEmpty()) {
rsThread = t;
break;
}
}
HRegionServer rs = rsThread.getRegionServer();
RegionInfo hri = rs.getRegions(TableName.META_TABLE_NAME).get(0).getRegionInfo();
HMaster master = UTIL.getMiniHBaseCluster().getMaster();
ProcedureExecutor<MasterProcedureEnv> executor = master.getMasterProcedureExecutor();
DummyRegionProcedure proc = new DummyRegionProcedure(executor.getEnvironment(), hri);
long procId = master.getMasterProcedureExecutor().submitProcedure(proc);
proc.waitUntilArrive();
try (AsyncConnection conn = ConnectionFactory.createAsyncConnection(UTIL.getConfiguration()).get()) {
AsyncAdmin admin = conn.getAdmin();
CompletableFuture<Void> future = admin.move(hri.getRegionName());
rs.abort("For testing!");
UTIL.waitFor(30000, () -> executor.getProcedures().stream().filter(p -> p instanceof TransitRegionStateProcedure).map(p -> (TransitRegionStateProcedure) p).anyMatch(p -> Bytes.equals(hri.getRegionName(), p.getRegion().getRegionName())));
proc.resume();
UTIL.waitFor(30000, () -> executor.isFinished(procId));
// see whether the move region procedure can finish properly
future.get(30, TimeUnit.SECONDS);
}
}
use of org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv in project hbase by apache.
the class TestRegionBypass method testBypass.
@Test
public void testBypass() throws IOException, InterruptedException {
Admin admin = TEST_UTIL.getAdmin();
MasterProcedureEnv env = TEST_UTIL.getHBaseCluster().getMaster().getMasterProcedureExecutor().getEnvironment();
List<RegionInfo> regions = admin.getRegions(this.tableName);
for (RegionInfo ri : regions) {
admin.unassign(ri.getRegionName(), false);
}
List<Long> pids = new ArrayList<>(regions.size());
for (RegionInfo ri : regions) {
Procedure<MasterProcedureEnv> p = new StallingAssignProcedure(env, ri, null, false, TransitionType.ASSIGN);
pids.add(TEST_UTIL.getHBaseCluster().getMaster().getMasterProcedureExecutor().submitProcedure(p));
}
for (Long pid : pids) {
while (!TEST_UTIL.getHBaseCluster().getMaster().getMasterProcedureExecutor().isStarted(pid)) {
Thread.sleep(100);
}
}
List<Procedure<MasterProcedureEnv>> ps = TEST_UTIL.getHBaseCluster().getMaster().getMasterProcedureExecutor().getProcedures();
for (Procedure<MasterProcedureEnv> p : ps) {
if (p instanceof StallingAssignProcedure) {
List<Boolean> bs = TEST_UTIL.getHbck().bypassProcedure(Arrays.asList(p.getProcId()), 1000, true, false);
for (Boolean b : bs) {
LOG.info("BYPASSED {} {}", p.getProcId(), b);
}
}
}
// Try and assign WITHOUT override flag. Should fail!.
for (RegionInfo ri : regions) {
try {
admin.assign(ri.getRegionName());
} catch (Throwable dnrioe) {
// Expected
LOG.info("Expected {}", dnrioe);
}
}
while (!TEST_UTIL.getHBaseCluster().getMaster().getMasterProcedureExecutor().getActiveProcIds().isEmpty()) {
Thread.sleep(100);
}
// Now assign with the override flag.
for (RegionInfo ri : regions) {
TEST_UTIL.getHbck().assigns(Arrays.<String>asList(ri.getEncodedName()), true);
}
while (!TEST_UTIL.getHBaseCluster().getMaster().getMasterProcedureExecutor().getActiveProcIds().isEmpty()) {
Thread.sleep(100);
}
for (RegionInfo ri : regions) {
assertTrue(ri.toString(), TEST_UTIL.getMiniHBaseCluster().getMaster().getAssignmentManager().getRegionStates().isRegionOnline(ri));
}
}
Aggregations