Search in sources :

Example 51 with HMaster

use of org.apache.hadoop.hbase.master.HMaster in project hbase by apache.

the class TestAdmin2 method testMoveToPreviouslyAssignedRS.

@Test
public void testMoveToPreviouslyAssignedRS() throws IOException, InterruptedException {
    SingleProcessHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
    HMaster master = cluster.getMaster();
    final TableName tableName = TableName.valueOf(name.getMethodName());
    Admin localAdmin = createTable(tableName);
    List<RegionInfo> tableRegions = localAdmin.getRegions(tableName);
    RegionInfo hri = tableRegions.get(0);
    AssignmentManager am = master.getAssignmentManager();
    ServerName server = am.getRegionStates().getRegionServerOfRegion(hri);
    localAdmin.move(hri.getEncodedNameAsBytes(), server);
    assertEquals("Current region server and region server before move should be same.", server, am.getRegionStates().getRegionServerOfRegion(hri));
}
Also used : SingleProcessHBaseCluster(org.apache.hadoop.hbase.SingleProcessHBaseCluster) TableName(org.apache.hadoop.hbase.TableName) ServerName(org.apache.hadoop.hbase.ServerName) HMaster(org.apache.hadoop.hbase.master.HMaster) AssignmentManager(org.apache.hadoop.hbase.master.assignment.AssignmentManager) Test(org.junit.Test)

Example 52 with HMaster

use of org.apache.hadoop.hbase.master.HMaster in project hbase by apache.

the class TestCleanupMetaReplicaThroughConfig method testReplicaCleanup.

@Test
public void testReplicaCleanup() throws Exception {
    ZKWatcher zkw = TEST_UTIL.getZooKeeperWatcher();
    List<String> metaReplicaZnodes = zkw.getMetaReplicaNodes();
    assertEquals(3, metaReplicaZnodes.size());
    final HMaster master = TEST_UTIL.getMiniHBaseCluster().getMaster();
    master.stop("Restarting");
    TEST_UTIL.waitFor(30000, () -> master.isStopped());
    TEST_UTIL.getMiniHBaseCluster().getConfiguration().setInt(HConstants.META_REPLICAS_NUM, 1);
    JVMClusterUtil.MasterThread newMasterThread = TEST_UTIL.getMiniHBaseCluster().startMaster();
    final HMaster newMaster = newMasterThread.getMaster();
    // wait until new master finished meta replica assignment logic
    TEST_UTIL.waitFor(30000, () -> newMaster.getMasterQuotaManager() != null);
    TEST_UTIL.waitFor(30000, () -> TEST_UTIL.getZooKeeperWatcher().getMetaReplicaNodes().size() == 1);
}
Also used : JVMClusterUtil(org.apache.hadoop.hbase.util.JVMClusterUtil) ZKWatcher(org.apache.hadoop.hbase.zookeeper.ZKWatcher) HMaster(org.apache.hadoop.hbase.master.HMaster) Test(org.junit.Test)

Example 53 with HMaster

use of org.apache.hadoop.hbase.master.HMaster in project hbase by apache.

the class TestTransitRegionStateProcedure method testRecoveryAndDoubleExcution.

private void testRecoveryAndDoubleExcution(TransitRegionStateProcedure proc) throws Exception {
    HMaster master = UTIL.getHBaseCluster().getMaster();
    AssignmentManager am = master.getAssignmentManager();
    RegionStateNode regionNode = am.getRegionStates().getRegionStateNode(proc.getRegion());
    assertFalse(regionNode.isInTransition());
    regionNode.setProcedure(proc);
    assertTrue(regionNode.isInTransition());
    ProcedureExecutor<MasterProcedureEnv> procExec = master.getMasterProcedureExecutor();
    ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, true);
    long procId = procExec.submitProcedure(proc);
    MasterProcedureTestingUtility.testRecoveryAndDoubleExecution(procExec, procId);
    regionNode = am.getRegionStates().getRegionStateNode(proc.getRegion());
    assertFalse(regionNode.isInTransition());
}
Also used : HMaster(org.apache.hadoop.hbase.master.HMaster) MasterProcedureEnv(org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv)

Example 54 with HMaster

use of org.apache.hadoop.hbase.master.HMaster in project hbase by apache.

the class TestRegionServerCrashDisableWAL method test.

@Test
public void test() throws InterruptedException, IOException {
    HMaster master = UTIL.getMiniHBaseCluster().stopMaster(0).getMaster();
    // Shutdown master before shutting down rs
    UTIL.waitFor(30000, () -> !master.isAlive());
    RegionServerThread thread = null;
    for (RegionServerThread t : UTIL.getMiniHBaseCluster().getRegionServerThreads()) {
        if (!t.getRegionServer().getRegions(TABLE_NAME).isEmpty()) {
            thread = t;
            break;
        }
    }
    // shutdown rs
    thread.getRegionServer().abort("For testing");
    thread.join();
    // restart master
    UTIL.getMiniHBaseCluster().startMaster();
    // the region online.
    try (Table table = UTIL.getConnection().getTableBuilder(TABLE_NAME, null).setOperationTimeout(30000).build()) {
        table.put(new Put(Bytes.toBytes(1)).addColumn(CF, CQ, Bytes.toBytes(1)));
        assertEquals(1, Bytes.toInt(table.get(new Get(Bytes.toBytes(1))).getValue(CF, CQ)));
    }
}
Also used : Table(org.apache.hadoop.hbase.client.Table) Get(org.apache.hadoop.hbase.client.Get) HMaster(org.apache.hadoop.hbase.master.HMaster) RegionServerThread(org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread) Put(org.apache.hadoop.hbase.client.Put) Test(org.junit.Test)

Example 55 with HMaster

use of org.apache.hadoop.hbase.master.HMaster in project hbase by apache.

the class TestMasterFifoRpcScheduler method testMasterRpcScheduler.

@Test
public void testMasterRpcScheduler() {
    HMaster master = TEST_UTIL.getHBaseCluster().getMaster();
    MasterRpcServices masterRpcServices = master.getMasterRpcServices();
    RpcScheduler masterRpcScheduler = masterRpcServices.getRpcScheduler();
    Assert.assertTrue(masterRpcScheduler instanceof MasterFifoRpcScheduler);
}
Also used : MasterRpcServices(org.apache.hadoop.hbase.master.MasterRpcServices) HMaster(org.apache.hadoop.hbase.master.HMaster) Test(org.junit.Test)

Aggregations

HMaster (org.apache.hadoop.hbase.master.HMaster)132 Test (org.junit.Test)91 TableName (org.apache.hadoop.hbase.TableName)42 IOException (java.io.IOException)33 RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)31 ServerName (org.apache.hadoop.hbase.ServerName)24 Admin (org.apache.hadoop.hbase.client.Admin)23 Table (org.apache.hadoop.hbase.client.Table)23 SingleProcessHBaseCluster (org.apache.hadoop.hbase.SingleProcessHBaseCluster)22 TableDescriptor (org.apache.hadoop.hbase.client.TableDescriptor)16 HRegionServer (org.apache.hadoop.hbase.regionserver.HRegionServer)15 Configuration (org.apache.hadoop.conf.Configuration)13 MasterCoprocessorHost (org.apache.hadoop.hbase.master.MasterCoprocessorHost)12 BeforeClass (org.junit.BeforeClass)11 AssignmentManager (org.apache.hadoop.hbase.master.assignment.AssignmentManager)10 List (java.util.List)9 HBaseClassTestRule (org.apache.hadoop.hbase.HBaseClassTestRule)9 HRegionLocation (org.apache.hadoop.hbase.HRegionLocation)9 RegionStates (org.apache.hadoop.hbase.master.assignment.RegionStates)9 ClassRule (org.junit.ClassRule)9