Search in sources :

Example 1 with DeleteTableProcedure

use of org.apache.hadoop.hbase.master.procedure.DeleteTableProcedure in project hbase by apache.

the class TestSplitOrMergeStatus method testSplitRegionReplicaRitRecovery.

@Test
public void testSplitRegionReplicaRitRecovery() throws Exception {
    int startRowNum = 11;
    int rowCount = 60;
    final TableName tableName = TableName.valueOf(name.getMethodName());
    final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
    TEST_UTIL.getAdmin().createTable(TableDescriptorBuilder.newBuilder(tableName).setColumnFamily(ColumnFamilyDescriptorBuilder.of(FAMILY)).setRegionReplication(2).build());
    TEST_UTIL.waitUntilAllRegionsAssigned(tableName);
    ServerName serverName = RegionReplicaTestHelper.getRSCarryingReplica(TEST_UTIL, tableName, 1).get();
    List<RegionInfo> regions = TEST_UTIL.getAdmin().getRegions(tableName);
    insertData(tableName, startRowNum, rowCount);
    int splitRowNum = startRowNum + rowCount / 2;
    byte[] splitKey = Bytes.toBytes("" + splitRowNum);
    // Split region of the table
    long procId = procExec.submitProcedure(new SplitTableRegionProcedure(procExec.getEnvironment(), regions.get(0), splitKey));
    // Wait the completion
    ProcedureTestingUtility.waitProcedure(procExec, procId);
    // Disable the table
    long procId1 = procExec.submitProcedure(new DisableTableProcedure(procExec.getEnvironment(), tableName, false));
    // Wait the completion
    ProcedureTestingUtility.waitProcedure(procExec, procId1);
    // Delete Table
    long procId2 = procExec.submitProcedure(new DeleteTableProcedure(procExec.getEnvironment(), tableName));
    // Wait the completion
    ProcedureTestingUtility.waitProcedure(procExec, procId2);
    AssignmentTestingUtil.killRs(TEST_UTIL, serverName);
    Threads.sleepWithoutInterrupt(5000);
    boolean hasRegionsInTransition = TEST_UTIL.getMiniHBaseCluster().getMaster().getAssignmentManager().getRegionStates().hasRegionsInTransition();
    assertEquals(false, hasRegionsInTransition);
}
Also used : MasterProcedureEnv(org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv) DeleteTableProcedure(org.apache.hadoop.hbase.master.procedure.DeleteTableProcedure) DisableTableProcedure(org.apache.hadoop.hbase.master.procedure.DisableTableProcedure) SplitTableRegionProcedure(org.apache.hadoop.hbase.master.assignment.SplitTableRegionProcedure) TableName(org.apache.hadoop.hbase.TableName) ServerName(org.apache.hadoop.hbase.ServerName) Test(org.junit.Test)

Aggregations

ServerName (org.apache.hadoop.hbase.ServerName)1 TableName (org.apache.hadoop.hbase.TableName)1 SplitTableRegionProcedure (org.apache.hadoop.hbase.master.assignment.SplitTableRegionProcedure)1 DeleteTableProcedure (org.apache.hadoop.hbase.master.procedure.DeleteTableProcedure)1 DisableTableProcedure (org.apache.hadoop.hbase.master.procedure.DisableTableProcedure)1 MasterProcedureEnv (org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv)1 Test (org.junit.Test)1