use of org.apache.hadoop.hbase.master.HMaster in project hbase by apache.
the class TestMetaTableAccessor method testIsMetaWhenMetaGoesOffline.
@Test
public void testIsMetaWhenMetaGoesOffline() throws InterruptedException {
HMaster m = UTIL.getMiniHBaseCluster().getMaster();
int index = UTIL.getMiniHBaseCluster().getServerWithMeta();
HRegionServer rsWithMeta = UTIL.getMiniHBaseCluster().getRegionServer(index);
rsWithMeta.abort("TESTING");
assertTrue(m.waitForMetaOnline());
}
use of org.apache.hadoop.hbase.master.HMaster in project hbase by apache.
the class TestMasterRegistry method testDynamicMasterConfigurationRefresh.
/**
* Tests that the list of masters configured in the MasterRegistry is dynamically refreshed in the
* event of errors.
*/
@Test
public void testDynamicMasterConfigurationRefresh() throws Exception {
Configuration conf = new Configuration(TEST_UTIL.getConfiguration());
String currentMasterAddrs = Preconditions.checkNotNull(conf.get(HConstants.MASTER_ADDRS_KEY));
HMaster activeMaster = TEST_UTIL.getHBaseCluster().getMaster();
String clusterId = activeMaster.getClusterId();
// Add a non-working master
ServerName badServer = ServerName.valueOf("localhost", 1234, -1);
conf.set(HConstants.MASTER_ADDRS_KEY, badServer.toShortString() + "," + currentMasterAddrs);
// Set the hedging fan out so that all masters are queried.
conf.setInt(MasterRegistry.MASTER_REGISTRY_HEDGED_REQS_FANOUT_KEY, 4);
// Do not limit the number of refreshes during the test run.
conf.setLong(MasterRegistry.MASTER_REGISTRY_MIN_SECS_BETWEEN_REFRESHES, 0);
try (MasterRegistry registry = new MasterRegistry(conf)) {
final Set<ServerName> masters = registry.getParsedServers();
assertTrue(masters.contains(badServer));
// Make a registry RPC, this should trigger a refresh since one of the hedged RPC fails.
assertEquals(registry.getClusterId().get(), clusterId);
// Wait for new set of masters to be populated.
TEST_UTIL.waitFor(5000, (Waiter.Predicate<Exception>) () -> !registry.getParsedServers().equals(masters));
// new set of masters should not include the bad server
final Set<ServerName> newMasters = registry.getParsedServers();
// Bad one should be out.
assertEquals(3, newMasters.size());
assertFalse(newMasters.contains(badServer));
// Kill the active master
activeMaster.stopMaster();
TEST_UTIL.waitFor(10000, () -> TEST_UTIL.getMiniHBaseCluster().getLiveMasterThreads().size() == 2);
TEST_UTIL.getMiniHBaseCluster().waitForActiveAndReadyMaster(10000);
// Wait until the killed master de-registered. This should also trigger another refresh.
TEST_UTIL.waitFor(10000, () -> registry.getMasters().get().size() == 2);
TEST_UTIL.waitFor(20000, () -> registry.getParsedServers().size() == 2);
final Set<ServerName> newMasters2 = registry.getParsedServers();
assertEquals(2, newMasters2.size());
assertFalse(newMasters2.contains(activeMaster.getServerName()));
} finally {
// Reset the state, add a killed master.
TEST_UTIL.getMiniHBaseCluster().startMaster();
}
}
use of org.apache.hadoop.hbase.master.HMaster in project hbase by apache.
the class TestOpenRegionProcedureHang method test.
@Test
public void test() throws InterruptedException, KeeperException, IOException {
RegionInfo region = UTIL.getMiniHBaseCluster().getRegions(NAME).get(0).getRegionInfo();
AssignmentManager am = UTIL.getMiniHBaseCluster().getMaster().getAssignmentManager();
HRegionServer rs1 = UTIL.getRSForFirstRegionInTable(NAME);
HRegionServer rs2 = UTIL.getOtherRegionServer(rs1);
ARRIVE = new CountDownLatch(1);
RESUME = new CountDownLatch(1);
FINISH = new CountDownLatch(1);
ABORT = new CountDownLatch(1);
am.moveAsync(new RegionPlan(region, rs1.getServerName(), rs2.getServerName()));
ARRIVE.await();
ARRIVE = null;
HMaster master = UTIL.getMiniHBaseCluster().getMaster();
master.getZooKeeper().close();
UTIL.waitFor(30000, () -> {
for (MasterThread mt : UTIL.getMiniHBaseCluster().getMasterThreads()) {
if (mt.getMaster() != master && mt.getMaster().isActiveMaster()) {
return mt.getMaster().isInitialized();
}
}
return false;
});
ProcedureExecutor<MasterProcedureEnv> procExec = UTIL.getMiniHBaseCluster().getMaster().getMasterProcedureExecutor();
UTIL.waitFor(30000, () -> procExec.getProcedures().stream().filter(p -> p instanceof OpenRegionProcedure).map(p -> (OpenRegionProcedure) p).anyMatch(p -> p.region.getTable().equals(NAME)));
OpenRegionProcedure proc = procExec.getProcedures().stream().filter(p -> p instanceof OpenRegionProcedure).map(p -> (OpenRegionProcedure) p).filter(p -> p.region.getTable().equals(NAME)).findFirst().get();
// wait a bit to let the OpenRegionProcedure send out the request
Thread.sleep(2000);
RESUME.countDown();
if (!FINISH.await(15, TimeUnit.SECONDS)) {
LOG.info("Wait reportRegionStateTransition to finish timed out, this is possible if" + " we update the procedure store, as the WALProcedureStore" + " will retry forever to roll the writer if it is not closed");
}
FINISH = null;
// if the reportRegionTransition is finished, wait a bit to let it return the data to RS
Thread.sleep(2000);
ABORT.countDown();
UTIL.waitFor(30000, () -> procExec.isFinished(proc.getProcId()));
UTIL.waitFor(30000, () -> procExec.isFinished(proc.getParentProcId()));
}
use of org.apache.hadoop.hbase.master.HMaster in project hbase by apache.
the class TestAssignmentManagerLoadMetaRegionState method testRestart.
@Test
public void testRestart() throws InterruptedException, IOException {
ServerName sn = UTIL.getMiniHBaseCluster().getRegionServer(0).getServerName();
AssignmentManager am = UTIL.getMiniHBaseCluster().getMaster().getAssignmentManager();
Set<RegionInfo> regions = new HashSet<>(am.getRegionsOnServer(sn));
UTIL.getMiniHBaseCluster().stopMaster(0).join();
HMaster newMaster = UTIL.getMiniHBaseCluster().startMaster().getMaster();
UTIL.waitFor(30000, () -> newMaster.isInitialized());
am = UTIL.getMiniHBaseCluster().getMaster().getAssignmentManager();
List<RegionInfo> newRegions = am.getRegionsOnServer(sn);
assertEquals(regions.size(), newRegions.size());
for (RegionInfo region : newRegions) {
assertTrue(regions.contains(region));
}
}
use of org.apache.hadoop.hbase.master.HMaster in project hbase by apache.
the class TestRSGroupsBalance method testGetRSGroupAssignmentsByTable.
@Test
public void testGetRSGroupAssignmentsByTable() throws Exception {
final TableName tableName = TableName.valueOf(name.getMethodName());
TEST_UTIL.createMultiRegionTable(tableName, HConstants.CATALOG_FAMILY, 10);
// disable table
final TableName disableTableName = TableName.valueOf("testDisableTable");
TEST_UTIL.createMultiRegionTable(disableTableName, HConstants.CATALOG_FAMILY, 10);
TEST_UTIL.getAdmin().disableTable(disableTableName);
HMaster master = TEST_UTIL.getMiniHBaseCluster().getMaster();
RSGroupInfoManagerImpl gm = (RSGroupInfoManagerImpl) master.getRSGroupInfoManager();
Map<TableName, Map<ServerName, List<RegionInfo>>> assignments = gm.getRSGroupAssignmentsByTable(master.getTableStateManager(), RSGroupInfo.DEFAULT_GROUP);
assertFalse(assignments.containsKey(disableTableName));
assertTrue(assignments.containsKey(tableName));
}
Aggregations