Search in sources :

Example 21 with ProcedureExecutor

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);
}
Also used : HBaseCommonTestingUtil(org.apache.hadoop.hbase.HBaseCommonTestingUtil) NoopProcedureStore(org.apache.hadoop.hbase.procedure2.store.NoopProcedureStore) Before(org.junit.Before)

Example 22 with ProcedureExecutor

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");
    }
}
Also used : HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) RegionProcedureStore(org.apache.hadoop.hbase.procedure2.store.region.RegionProcedureStore) MasterProcedureEnv(org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv) MasterProcedureScheduler(org.apache.hadoop.hbase.master.procedure.MasterProcedureScheduler) ProcedureStoreListener(org.apache.hadoop.hbase.procedure2.store.ProcedureStore.ProcedureStoreListener) RSGroupAdminEndpoint(org.apache.hadoop.hbase.rsgroup.RSGroupAdminEndpoint)

Example 23 with ProcedureExecutor

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());
    }
}
Also used : MasterLock(org.apache.hadoop.hbase.master.locking.LockManager.MasterLock) TableName(org.apache.hadoop.hbase.TableName) AfterClass(org.junit.AfterClass) BeforeClass(org.junit.BeforeClass) HBaseTestingUtil(org.apache.hadoop.hbase.HBaseTestingUtil) MediumTests(org.apache.hadoop.hbase.testclassification.MediumTests) HBaseClassTestRule(org.apache.hadoop.hbase.HBaseClassTestRule) IOException(java.io.IOException) Test(org.junit.Test) MasterProcedureEnv(org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv) Category(org.junit.experimental.categories.Category) LockProcedure(org.apache.hadoop.hbase.master.locking.LockProcedure) LockType(org.apache.hadoop.hbase.procedure2.LockType) UncheckedIOException(java.io.UncheckedIOException) Assert.assertNull(org.junit.Assert.assertNull) ProcedureExecutor(org.apache.hadoop.hbase.procedure2.ProcedureExecutor) ResultScanner(org.apache.hadoop.hbase.client.ResultScanner) MasterTests(org.apache.hadoop.hbase.testclassification.MasterTests) Table(org.apache.hadoop.hbase.client.Table) ClassRule(org.junit.ClassRule) Bytes(org.apache.hadoop.hbase.util.Bytes) LockProcedure(org.apache.hadoop.hbase.master.locking.LockProcedure) Table(org.apache.hadoop.hbase.client.Table) ResultScanner(org.apache.hadoop.hbase.client.ResultScanner) UncheckedIOException(java.io.UncheckedIOException) MasterProcedureEnv(org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException) MasterLock(org.apache.hadoop.hbase.master.locking.LockManager.MasterLock) Test(org.junit.Test)

Example 24 with ProcedureExecutor

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);
}
Also used : BeforeClass(org.junit.BeforeClass) SyncReplicationState(org.apache.hadoop.hbase.replication.SyncReplicationState) HBaseClassTestRule(org.apache.hadoop.hbase.HBaseClassTestRule) ProcedureTestingUtility(org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility) LargeTests(org.apache.hadoop.hbase.testclassification.LargeTests) IOException(java.io.IOException) Test(org.junit.Test) MasterProcedureEnv(org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv) MasterProcedureTestingUtility(org.apache.hadoop.hbase.master.procedure.MasterProcedureTestingUtility) Category(org.junit.experimental.categories.Category) Procedure(org.apache.hadoop.hbase.procedure2.Procedure) UncheckedIOException(java.io.UncheckedIOException) SyncReplicationTestBase(org.apache.hadoop.hbase.replication.SyncReplicationTestBase) ProcedureExecutor(org.apache.hadoop.hbase.procedure2.ProcedureExecutor) MasterTests(org.apache.hadoop.hbase.testclassification.MasterTests) MasterProcedureConstants(org.apache.hadoop.hbase.master.procedure.MasterProcedureConstants) ClassRule(org.junit.ClassRule) HMaster(org.apache.hadoop.hbase.master.HMaster) Assert.assertEquals(org.junit.Assert.assertEquals) HMaster(org.apache.hadoop.hbase.master.HMaster) Procedure(org.apache.hadoop.hbase.procedure2.Procedure) MasterProcedureEnv(org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException) Test(org.junit.Test)

Example 25 with ProcedureExecutor

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);
}
Also used : Arrays(java.util.Arrays) TableNotFoundException(org.apache.hadoop.hbase.TableNotFoundException) FileSystem(org.apache.hadoop.fs.FileSystem) ModifyRegionUtils(org.apache.hadoop.hbase.util.ModifyRegionUtils) LoggerFactory(org.slf4j.LoggerFactory) MasterFileSystem(org.apache.hadoop.hbase.master.MasterFileSystem) TableDescriptorBuilder(org.apache.hadoop.hbase.client.TableDescriptorBuilder) ProcedureExecutor(org.apache.hadoop.hbase.procedure2.ProcedureExecutor) ColumnFamilyDescriptorBuilder(org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder) TestName(org.junit.rules.TestName) Configuration(org.apache.hadoop.conf.Configuration) Path(org.apache.hadoop.fs.Path) Assert.fail(org.junit.Assert.fail) ClassRule(org.junit.ClassRule) MasterProcedureProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos) Bytes(org.apache.hadoop.hbase.util.Bytes) TableName(org.apache.hadoop.hbase.TableName) CommonFSUtils(org.apache.hadoop.hbase.util.CommonFSUtils) Logger(org.slf4j.Logger) Assert.assertTrue(org.junit.Assert.assertTrue) HBaseClassTestRule(org.apache.hadoop.hbase.HBaseClassTestRule) ProcedureTestingUtility(org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility) LargeTests(org.apache.hadoop.hbase.testclassification.LargeTests) IOException(java.io.IOException) Test(org.junit.Test) Category(org.junit.experimental.categories.Category) Collectors(java.util.stream.Collectors) Procedure(org.apache.hadoop.hbase.procedure2.Procedure) Rule(org.junit.Rule) TableNotDisabledException(org.apache.hadoop.hbase.TableNotDisabledException) MasterTests(org.apache.hadoop.hbase.testclassification.MasterTests) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) TableDescriptor(org.apache.hadoop.hbase.client.TableDescriptor) FSUtils(org.apache.hadoop.hbase.util.FSUtils) Assert.assertEquals(org.junit.Assert.assertEquals) TableName(org.apache.hadoop.hbase.TableName) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) TableDescriptor(org.apache.hadoop.hbase.client.TableDescriptor) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)25 ProcedureExecutor (org.apache.hadoop.hbase.procedure2.ProcedureExecutor)24 TableName (org.apache.hadoop.hbase.TableName)22 MasterProcedureEnv (org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv)22 HBaseClassTestRule (org.apache.hadoop.hbase.HBaseClassTestRule)17 MasterTests (org.apache.hadoop.hbase.testclassification.MasterTests)17 Bytes (org.apache.hadoop.hbase.util.Bytes)17 ClassRule (org.junit.ClassRule)17 Category (org.junit.experimental.categories.Category)17 RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)16 IOException (java.io.IOException)15 HBaseTestingUtil (org.apache.hadoop.hbase.HBaseTestingUtil)15 Procedure (org.apache.hadoop.hbase.procedure2.Procedure)14 BeforeClass (org.junit.BeforeClass)14 MediumTests (org.apache.hadoop.hbase.testclassification.MediumTests)12 AfterClass (org.junit.AfterClass)12 HMaster (org.apache.hadoop.hbase.master.HMaster)11 Configuration (org.apache.hadoop.conf.Configuration)10 Logger (org.slf4j.Logger)10 LoggerFactory (org.slf4j.LoggerFactory)10