Search in sources :

Example 1 with HMaster

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

the class HBaseTestingUtility method moveRegionAndWait.

/**
   * Move region to destination server and wait till region is completely moved and online
   *
   * @param destRegion region to move
   * @param destServer destination server of the region
   * @throws InterruptedException
   * @throws IOException
   */
public void moveRegionAndWait(HRegionInfo destRegion, ServerName destServer) throws InterruptedException, IOException {
    HMaster master = getMiniHBaseCluster().getMaster();
    getHBaseAdmin().move(destRegion.getEncodedNameAsBytes(), Bytes.toBytes(destServer.getServerName()));
    while (true) {
        ServerName serverName = master.getAssignmentManager().getRegionStates().getRegionServerOfRegion(destRegion);
        if (serverName != null && serverName.equals(destServer)) {
            assertRegionOnServer(destRegion, serverName, 200);
            break;
        }
        Thread.sleep(10);
    }
}
Also used : HMaster(org.apache.hadoop.hbase.master.HMaster)

Example 2 with HMaster

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

the class MiniHBaseCluster method getServerHoldingRegion.

@Override
public ServerName getServerHoldingRegion(final TableName tn, byte[] regionName) throws IOException {
    // Assume there is only one master thread which is the active master.
    // If there are multiple master threads, the backup master threads
    // should hold some regions. Please refer to #countServedRegions
    // to see how we find out all regions.
    HMaster master = getMaster();
    Region region = master.getOnlineRegion(regionName);
    if (region != null) {
        return master.getServerName();
    }
    int index = getServerWith(regionName);
    if (index < 0) {
        return null;
    }
    return getRegionServer(index).getServerName();
}
Also used : HMaster(org.apache.hadoop.hbase.master.HMaster) HRegion(org.apache.hadoop.hbase.regionserver.HRegion) Region(org.apache.hadoop.hbase.regionserver.Region)

Example 3 with HMaster

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

the class TestMasterObserver method testListProceduresOperation.

@Test(timeout = 180000)
public void testListProceduresOperation() throws Exception {
    MiniHBaseCluster cluster = UTIL.getHBaseCluster();
    HMaster master = cluster.getMaster();
    MasterCoprocessorHost host = master.getMasterCoprocessorHost();
    CPMasterObserver cp = (CPMasterObserver) host.findCoprocessor(CPMasterObserver.class.getName());
    cp.resetStates();
    master.listProcedures();
    assertTrue("Coprocessor should be called on list procedures request", cp.wasListProceduresCalled());
}
Also used : MasterCoprocessorHost(org.apache.hadoop.hbase.master.MasterCoprocessorHost) HMaster(org.apache.hadoop.hbase.master.HMaster) MiniHBaseCluster(org.apache.hadoop.hbase.MiniHBaseCluster) Test(org.junit.Test)

Example 4 with HMaster

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

the class MasterProcedureTestingUtility method masterFailover.

// ==========================================================================
//  Master failover utils
// ==========================================================================
public static void masterFailover(final HBaseTestingUtility testUtil) throws Exception {
    MiniHBaseCluster cluster = testUtil.getMiniHBaseCluster();
    // Kill the master
    HMaster oldMaster = cluster.getMaster();
    cluster.killMaster(cluster.getMaster().getServerName());
    // Wait the secondary
    waitBackupMaster(testUtil, oldMaster);
}
Also used : HMaster(org.apache.hadoop.hbase.master.HMaster) MiniHBaseCluster(org.apache.hadoop.hbase.MiniHBaseCluster)

Example 5 with HMaster

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

the class MasterProcedureTestingUtility method waitBackupMaster.

public static void waitBackupMaster(final HBaseTestingUtility testUtil, final HMaster oldMaster) throws Exception {
    MiniHBaseCluster cluster = testUtil.getMiniHBaseCluster();
    HMaster newMaster = cluster.getMaster();
    while (newMaster == null || newMaster == oldMaster) {
        Thread.sleep(250);
        newMaster = cluster.getMaster();
    }
    while (!(newMaster.isActiveMaster() && newMaster.isInitialized())) {
        Thread.sleep(250);
    }
}
Also used : HMaster(org.apache.hadoop.hbase.master.HMaster) MiniHBaseCluster(org.apache.hadoop.hbase.MiniHBaseCluster)

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