use of org.apache.hadoop.hbase.master.assignment.TransitRegionStateProcedure in project hbase by apache.
the class TestServerCrashProcedureStuck method test.
@Test
public void test() throws Exception {
RegionServerThread rsThread = null;
for (RegionServerThread t : UTIL.getMiniHBaseCluster().getRegionServerThreads()) {
if (!t.getRegionServer().getRegions(TABLE_NAME).isEmpty()) {
rsThread = t;
break;
}
}
HRegionServer rs = rsThread.getRegionServer();
RegionInfo hri = rs.getRegions(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.assignment.TransitRegionStateProcedure in project hbase by apache.
the class TestSplitRegionWhileRSCrash method test.
@Test
public void test() throws Exception {
MasterProcedureEnv env = UTIL.getMiniHBaseCluster().getMaster().getMasterProcedureExecutor().getEnvironment();
final ProcedureExecutor<MasterProcedureEnv> executor = UTIL.getMiniHBaseCluster().getMaster().getMasterProcedureExecutor();
List<RegionInfo> regionInfos = ADMIN.getRegions(TABLE_NAME);
// Since a flush request will be sent while initializing SplitTableRegionProcedure
// Create SplitTableRegionProcedure first before put data
SplitTableRegionProcedure splitProcedure = new SplitTableRegionProcedure(env, regionInfos.get(0), Bytes.toBytes("row5"));
// write some rows to the table
LOG.info("Begin to put data");
for (int i = 0; i < 10; i++) {
byte[] row = Bytes.toBytes("row" + i);
Put put = new Put(row);
put.addColumn(CF, CF, CF);
TABLE.put(put);
}
executor.submitProcedure(splitProcedure);
LOG.info("SplitProcedure submitted");
UTIL.waitFor(30000, () -> executor.getProcedures().stream().filter(p -> p instanceof TransitRegionStateProcedure).map(p -> (TransitRegionStateProcedure) p).anyMatch(p -> TABLE_NAME.equals(p.getTableName())));
UTIL.getMiniHBaseCluster().killRegionServer(UTIL.getMiniHBaseCluster().getRegionServer(0).getServerName());
UTIL.getMiniHBaseCluster().startRegionServer();
UTIL.waitUntilNoRegionsInTransition();
Scan scan = new Scan();
ResultScanner results = TABLE.getScanner(scan);
int count = 0;
while (results.next() != null) {
count++;
}
Assert.assertEquals("There should be 10 rows!", 10, count);
}
use of org.apache.hadoop.hbase.master.assignment.TransitRegionStateProcedure in project hbase by apache.
the class TestReopenTableRegionsProcedureInfiniteLoop method testInfiniteLoop.
@Test
public void testInfiniteLoop() throws IOException {
HMaster master = UTIL.getMiniHBaseCluster().getMaster();
AssignmentManager am = master.getAssignmentManager();
ProcedureExecutor<MasterProcedureEnv> exec = master.getMasterProcedureExecutor();
RegionInfo regionInfo = UTIL.getAdmin().getRegions(TABLE_NAME).get(0);
RegionStateNode regionNode = am.getRegionStates().getRegionStateNode(regionInfo);
long procId;
ReopenTableRegionsProcedure proc = new ReopenTableRegionsProcedure(TABLE_NAME);
regionNode.lock();
try {
procId = exec.submitProcedure(proc);
UTIL.waitFor(30000, () -> proc.hasLock());
TransitRegionStateProcedure trsp = TransitRegionStateProcedure.reopen(exec.getEnvironment(), regionInfo);
regionNode.setProcedure(trsp);
exec.submitProcedure(trsp);
} finally {
regionNode.unlock();
}
UTIL.waitFor(60000, () -> exec.isFinished(procId));
}
use of org.apache.hadoop.hbase.master.assignment.TransitRegionStateProcedure in project hbase by apache.
the class TestServerRemoteProcedure method testRegionOpenProcedureIsNotHandledByDispatcher.
@Test
public void testRegionOpenProcedureIsNotHandledByDispatcher() throws Exception {
TableName tableName = TableName.valueOf("testRegionOpenProcedureIsNotHandledByDisPatcher");
RegionInfo hri = RegionInfoBuilder.newBuilder(tableName).setStartKey(Bytes.toBytes(1)).setEndKey(Bytes.toBytes(2)).setSplit(false).setRegionId(0).build();
MasterProcedureEnv env = master.getMasterProcedureExecutor().getEnvironment();
env.getAssignmentManager().getRegionStates().getOrCreateRegionStateNode(hri);
TransitRegionStateProcedure proc = TransitRegionStateProcedure.assign(env, hri, null);
ServerName worker = master.getServerManager().getOnlineServersList().get(0);
OpenRegionProcedure openRegionProcedure = new OpenRegionProcedure(proc, hri, worker);
Future<byte[]> future = submitProcedure(openRegionProcedure);
Thread.sleep(2000);
rsDispatcher.removeNode(worker);
try {
future.get(2000, TimeUnit.MILLISECONDS);
fail();
} catch (TimeoutException e) {
LOG.info("timeout is expected");
}
Assert.assertFalse(openRegionProcedure.isFinished());
}
use of org.apache.hadoop.hbase.master.assignment.TransitRegionStateProcedure in project hbase by apache.
the class TestMasterAbortAndRSGotKilled method test.
@Test
public void test() throws Exception {
JVMClusterUtil.RegionServerThread rsThread = null;
for (JVMClusterUtil.RegionServerThread t : UTIL.getMiniHBaseCluster().getRegionServerThreads()) {
if (!t.getRegionServer().getRegions(TABLE_NAME).isEmpty()) {
rsThread = t;
break;
}
}
// find the rs and hri of the table
HRegionServer rs = rsThread.getRegionServer();
RegionInfo hri = rs.getRegions(TABLE_NAME).get(0).getRegionInfo();
TransitRegionStateProcedure moveRegionProcedure = TransitRegionStateProcedure.reopen(UTIL.getMiniHBaseCluster().getMaster().getMasterProcedureExecutor().getEnvironment(), hri);
RegionStateNode regionNode = UTIL.getMiniHBaseCluster().getMaster().getAssignmentManager().getRegionStates().getOrCreateRegionStateNode(hri);
regionNode.setProcedure(moveRegionProcedure);
UTIL.getMiniHBaseCluster().getMaster().getMasterProcedureExecutor().submitProcedure(moveRegionProcedure);
countDownLatch.await();
UTIL.getMiniHBaseCluster().stopMaster(0);
UTIL.getMiniHBaseCluster().startMaster();
// wait until master initialized
UTIL.waitFor(30000, () -> UTIL.getMiniHBaseCluster().getMaster() != null && UTIL.getMiniHBaseCluster().getMaster().isInitialized());
Assert.assertTrue("Should be 3 RS after master restart", UTIL.getMiniHBaseCluster().getLiveRegionServerThreads().size() == 3);
}
Aggregations