Search in sources :

Example 16 with AsyncConnection

use of org.apache.hadoop.hbase.client.AsyncConnection 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);
    }
}
Also used : 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) RegionServerThread(org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread) AsyncAdmin(org.apache.hadoop.hbase.client.AsyncAdmin) HBaseClassTestRule(org.apache.hadoop.hbase.HBaseClassTestRule) CompletableFuture(java.util.concurrent.CompletableFuture) Test(org.junit.Test) MasterProcedureEnv(org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv) Category(org.junit.experimental.categories.Category) ConnectionFactory(org.apache.hadoop.hbase.client.ConnectionFactory) TimeUnit(java.util.concurrent.TimeUnit) HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer) AsyncConnection(org.apache.hadoop.hbase.client.AsyncConnection) ProcedureExecutor(org.apache.hadoop.hbase.procedure2.ProcedureExecutor) TransitRegionStateProcedure(org.apache.hadoop.hbase.master.assignment.TransitRegionStateProcedure) MasterTests(org.apache.hadoop.hbase.testclassification.MasterTests) ClassRule(org.junit.ClassRule) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) Bytes(org.apache.hadoop.hbase.util.Bytes) AsyncAdmin(org.apache.hadoop.hbase.client.AsyncAdmin) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) MasterProcedureEnv(org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv) HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer) TransitRegionStateProcedure(org.apache.hadoop.hbase.master.assignment.TransitRegionStateProcedure) AsyncConnection(org.apache.hadoop.hbase.client.AsyncConnection) RegionServerThread(org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread) Test(org.junit.Test)

Aggregations

AsyncConnection (org.apache.hadoop.hbase.client.AsyncConnection)16 Test (org.junit.Test)11 AsyncAdmin (org.apache.hadoop.hbase.client.AsyncAdmin)7 ExecutionException (java.util.concurrent.ExecutionException)5 Get (org.apache.hadoop.hbase.client.Get)5 Put (org.apache.hadoop.hbase.client.Put)5 HRegionServer (org.apache.hadoop.hbase.regionserver.HRegionServer)5 MediumTests (org.apache.hadoop.hbase.testclassification.MediumTests)5 ClassRule (org.junit.ClassRule)5 Category (org.junit.experimental.categories.Category)5 IOException (java.io.IOException)4 Configuration (org.apache.hadoop.conf.Configuration)4 TableName (org.apache.hadoop.hbase.TableName)4 RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)4 Table (org.apache.hadoop.hbase.client.Table)4 Optional (java.util.Optional)3 CompletableFuture (java.util.concurrent.CompletableFuture)3 ExecutorService (java.util.concurrent.ExecutorService)3 ConnectionFactory (org.apache.hadoop.hbase.client.ConnectionFactory)3 ShellExecRequest (org.apache.hadoop.hbase.coprocessor.protobuf.generated.ShellExecEndpoint.ShellExecRequest)3