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);
}
}
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();
}
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());
}
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);
}
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);
}
}
Aggregations