use of org.apache.hadoop.hbase.procedure2.ProcedureExecutor in project hbase by apache.
the class TestProcedureSuspended method setUp.
@Before
public void setUp() throws IOException {
htu = new HBaseCommonTestingUtil();
procStore = new NoopProcedureStore();
procExecutor = new ProcedureExecutor<>(htu.getConfiguration(), new TestProcEnv(), procStore);
procStore.start(PROCEDURE_EXECUTOR_SLOTS);
ProcedureTestingUtility.initAndStartWorkers(procExecutor, PROCEDURE_EXECUTOR_SLOTS, true);
}
use of org.apache.hadoop.hbase.procedure2.ProcedureExecutor in project hbase by apache.
the class HMaster method createProcedureExecutor.
private void createProcedureExecutor() throws IOException {
MasterProcedureEnv procEnv = new MasterProcedureEnv(this);
procedureStore = new RegionProcedureStore(this, masterRegion, new MasterProcedureEnv.FsUtilsLeaseRecovery(this));
procedureStore.registerListener(new ProcedureStoreListener() {
@Override
public void abortProcess() {
abort("The Procedure Store lost the lease", null);
}
});
MasterProcedureScheduler procedureScheduler = procEnv.getProcedureScheduler();
procedureExecutor = new ProcedureExecutor<>(conf, procEnv, procedureStore, procedureScheduler);
configurationManager.registerObserver(procEnv);
int cpus = Runtime.getRuntime().availableProcessors();
final int numThreads = conf.getInt(MasterProcedureConstants.MASTER_PROCEDURE_THREADS, Math.max((cpus > 0 ? cpus / 4 : 0), MasterProcedureConstants.DEFAULT_MIN_MASTER_PROCEDURE_THREADS));
final boolean abortOnCorruption = conf.getBoolean(MasterProcedureConstants.EXECUTOR_ABORT_ON_CORRUPTION, MasterProcedureConstants.DEFAULT_EXECUTOR_ABORT_ON_CORRUPTION);
procedureStore.start(numThreads);
// Just initialize it but do not start the workers, we will start the workers later by calling
// startProcedureExecutor. See the javadoc for finishActiveMasterInitialization for more
// details.
procedureExecutor.init(numThreads, abortOnCorruption);
if (!procEnv.getRemoteDispatcher().start()) {
throw new HBaseIOException("Failed start of remote dispatcher");
}
}
use of org.apache.hadoop.hbase.procedure2.ProcedureExecutor in project hbase by apache.
the class TestSnapshotWhileRSCrashes method test.
@Test
public void test() throws InterruptedException, IOException {
String snName = "sn";
MasterLock lock = UTIL.getMiniHBaseCluster().getMaster().getLockManager().createMasterLock(NAME, LockType.EXCLUSIVE, "for testing");
lock.acquire();
Thread t = new Thread(() -> {
try {
UTIL.getAdmin().snapshot(snName, NAME);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
});
t.setDaemon(true);
t.start();
ProcedureExecutor<MasterProcedureEnv> procExec = UTIL.getMiniHBaseCluster().getMaster().getMasterProcedureExecutor();
UTIL.waitFor(10000, () -> procExec.getProcedures().stream().filter(p -> !p.isFinished()).filter(p -> p instanceof LockProcedure).map(p -> (LockProcedure) p).filter(p -> NAME.equals(p.getTableName())).anyMatch(p -> !p.isLocked()));
UTIL.getMiniHBaseCluster().stopRegionServer(0);
lock.release();
// sure that the regions could online
try (Table table = UTIL.getConnection().getTable(NAME);
ResultScanner scanner = table.getScanner(CF)) {
assertNull(scanner.next());
}
}
use of org.apache.hadoop.hbase.procedure2.ProcedureExecutor in project hbase by apache.
the class TestTransitPeerSyncReplicationStateProcedureRetry method testRecoveryAndDoubleExecution.
@Test
public void testRecoveryAndDoubleExecution() throws Exception {
UTIL2.getAdmin().transitReplicationPeerSyncReplicationState(PEER_ID, SyncReplicationState.STANDBY);
UTIL1.getAdmin().transitReplicationPeerSyncReplicationState(PEER_ID, SyncReplicationState.ACTIVE);
UTIL1.getAdmin().disableReplicationPeer(PEER_ID);
write(UTIL1, 0, 100);
Thread.sleep(2000);
// peer is disabled so no data have been replicated
verifyNotReplicatedThroughRegion(UTIL2, 0, 100);
// transit the A to DA first to avoid too many error logs.
UTIL1.getAdmin().transitReplicationPeerSyncReplicationState(PEER_ID, SyncReplicationState.DOWNGRADE_ACTIVE);
HMaster master = UTIL2.getHBaseCluster().getMaster();
ProcedureExecutor<MasterProcedureEnv> procExec = master.getMasterProcedureExecutor();
// Enable test flags and then queue the procedure.
ProcedureTestingUtility.waitNoProcedureRunning(procExec);
ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, true);
Thread t = new Thread() {
@Override
public void run() {
try {
UTIL2.getAdmin().transitReplicationPeerSyncReplicationState(PEER_ID, SyncReplicationState.DOWNGRADE_ACTIVE);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
};
t.start();
UTIL2.waitFor(30000, () -> procExec.getProcedures().stream().anyMatch(p -> p instanceof TransitPeerSyncReplicationStateProcedure && !p.isFinished()));
long procId = procExec.getProcedures().stream().filter(p -> p instanceof TransitPeerSyncReplicationStateProcedure && !p.isFinished()).mapToLong(Procedure::getProcId).min().getAsLong();
MasterProcedureTestingUtility.testRecoveryAndDoubleExecution(procExec, procId);
ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, false);
assertEquals(SyncReplicationState.DOWNGRADE_ACTIVE, UTIL2.getAdmin().getReplicationPeerSyncReplicationState(PEER_ID));
verify(UTIL2, 0, 100);
}
use of org.apache.hadoop.hbase.procedure2.ProcedureExecutor in project hbase by apache.
the class TestTruncateTableProcedure method testTruncatePreserveWithReplicaRegionAfterSplit.
@Test
public void testTruncatePreserveWithReplicaRegionAfterSplit() throws Exception {
String[] families = new String[] { "f1", "f2" };
byte[][] splitKeys = new byte[][] { Bytes.toBytes("a"), Bytes.toBytes("b"), Bytes.toBytes("c") };
TableName tableName = TableName.valueOf(name.getMethodName());
// create a table with region replications
TableDescriptor htd = TableDescriptorBuilder.newBuilder(tableName).setRegionReplication(3).setColumnFamilies(Arrays.stream(families).map(fam -> ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes(fam)).build()).collect(Collectors.toList())).build();
RegionInfo[] regions = ModifyRegionUtils.createRegionInfos(htd, splitKeys);
ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
long procId = ProcedureTestingUtility.submitAndWait(procExec, new CreateTableProcedure(procExec.getEnvironment(), htd, regions));
ProcedureTestingUtility.assertProcNotFailed(procExec.getResult(procId));
splitAndTruncate(tableName, regions, 3);
}
Aggregations