use of org.apache.hadoop.hbase.procedure2.ProcedureExecutor 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.procedure2.ProcedureExecutor 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.procedure2.ProcedureExecutor in project hbase by apache.
the class TestRaceBetweenSCPAndTRSP method test.
@Test
public void test() throws Exception {
RegionInfo region = UTIL.getMiniHBaseCluster().getRegions(NAME).get(0).getRegionInfo();
AssignmentManager am = UTIL.getMiniHBaseCluster().getMaster().getAssignmentManager();
ServerName sn = am.getRegionStates().getRegionState(region).getServerName();
// Assign the CountDownLatches that get nulled in background threads else we NPE checking
// the static.
ARRIVE_REGION_OPENING = new CountDownLatch(1);
CountDownLatch arriveRegionOpening = ARRIVE_REGION_OPENING;
RESUME_REGION_OPENING = new CountDownLatch(1);
ARRIVE_GET_REGIONS_ON_SERVER = new CountDownLatch(1);
CountDownLatch arriveGetRegionsOnServer = ARRIVE_GET_REGIONS_ON_SERVER;
RESUME_GET_REGIONS_ON_SERVER = new CountDownLatch(1);
Future<byte[]> moveFuture = am.moveAsync(new RegionPlan(region, sn, sn));
arriveRegionOpening.await();
UTIL.getMiniHBaseCluster().killRegionServer(sn);
arriveGetRegionsOnServer.await();
RESUME_REGION_OPENING.countDown();
moveFuture.get();
ProcedureExecutor<?> procExec = UTIL.getMiniHBaseCluster().getMaster().getMasterProcedureExecutor();
long scpProcId = procExec.getProcedures().stream().filter(p -> p instanceof ServerCrashProcedure).map(p -> (ServerCrashProcedure) p).findAny().get().getProcId();
RESUME_GET_REGIONS_ON_SERVER.countDown();
UTIL.waitFor(60000, () -> procExec.isFinished(scpProcId));
}
use of org.apache.hadoop.hbase.procedure2.ProcedureExecutor 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.procedure2.ProcedureExecutor in project hbase by apache.
the class MockMasterServices method startProcedureExecutor.
private void startProcedureExecutor(final RSProcedureDispatcher remoteDispatcher) throws IOException {
final Configuration conf = getConfiguration();
this.procedureStore = new NoopProcedureStore();
this.procedureStore.registerListener(new ProcedureStoreListener() {
@Override
public void abortProcess() {
abort("The Procedure Store lost the lease", null);
}
});
this.procedureEnv = new MasterProcedureEnv(this, remoteDispatcher != null ? remoteDispatcher : new RSProcedureDispatcher(this));
this.procedureExecutor = new ProcedureExecutor<>(conf, procedureEnv, procedureStore, procedureEnv.getProcedureScheduler());
final int numThreads = conf.getInt(MasterProcedureConstants.MASTER_PROCEDURE_THREADS, Math.max(Runtime.getRuntime().availableProcessors(), MasterProcedureConstants.DEFAULT_MIN_MASTER_PROCEDURE_THREADS));
final boolean abortOnCorruption = conf.getBoolean(MasterProcedureConstants.EXECUTOR_ABORT_ON_CORRUPTION, MasterProcedureConstants.DEFAULT_EXECUTOR_ABORT_ON_CORRUPTION);
this.procedureStore.start(numThreads);
ProcedureTestingUtility.initAndStartWorkers(procedureExecutor, numThreads, abortOnCorruption);
this.procedureEnv.getRemoteDispatcher().start();
}
Aggregations