use of org.apache.hadoop.hbase.master.HMaster in project hbase by apache.
the class TestAsyncRegionAdminApi method createTableAndGetOneRegion.
RegionInfo createTableAndGetOneRegion(final TableName tableName) throws IOException, InterruptedException, ExecutionException {
TableDescriptor desc = TableDescriptorBuilder.newBuilder(tableName).setColumnFamily(ColumnFamilyDescriptorBuilder.of(FAMILY)).build();
admin.createTable(desc, Bytes.toBytes("A"), Bytes.toBytes("Z"), 5).get();
// wait till the table is assigned
HMaster master = TEST_UTIL.getHBaseCluster().getMaster();
long timeoutTime = EnvironmentEdgeManager.currentTime() + 3000;
while (true) {
List<RegionInfo> regions = master.getAssignmentManager().getRegionStates().getRegionsOfTable(tableName);
if (regions.size() > 3) {
return regions.get(2);
}
long now = EnvironmentEdgeManager.currentTime();
if (now > timeoutTime) {
fail("Could not find an online region");
}
Thread.sleep(10);
}
}
use of org.apache.hadoop.hbase.master.HMaster in project hbase by apache.
the class HBaseTestingUtility method expireMasterSession.
/**
* Expire the Master's session
* @throws Exception
*/
public void expireMasterSession() throws Exception {
HMaster master = getMiniHBaseCluster().getMaster();
expireSession(master.getZooKeeper(), false);
}
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(RegionInfo destRegion, ServerName destServer) throws InterruptedException, IOException {
HMaster master = getMiniHBaseCluster().getMaster();
// TODO: Here we start the move. The move can take a while.
getAdmin().move(destRegion.getEncodedNameAsBytes(), destServer);
while (true) {
ServerName serverName = master.getAssignmentManager().getRegionStates().getRegionServerOfRegion(destRegion);
if (serverName != null && serverName.equals(destServer)) {
assertRegionOnServer(destRegion, serverName, 2000);
break;
}
Thread.sleep(10);
}
}
use of org.apache.hadoop.hbase.master.HMaster in project hbase by apache.
the class TestSeparateClientZKCluster method testMasterSwitch.
@Test
public void testMasterSwitch() throws Exception {
// get an admin instance and issue some request first
Connection conn = TEST_UTIL.getConnection();
try (Admin admin = conn.getAdmin()) {
LOG.debug("Tables: " + admin.listTableDescriptors());
SingleProcessHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
// switch active master
HMaster master = cluster.getMaster();
master.stopMaster();
LOG.info("Stopped master {}", master.getServerName());
while (master.isAlive()) {
Thread.sleep(200);
}
LOG.info("Shutdown master {}", master.getServerName());
while (cluster.getMaster() == null || !cluster.getMaster().isInitialized()) {
LOG.info("Get master {}", cluster.getMaster() == null ? "null" : cluster.getMaster().getServerName());
Thread.sleep(200);
}
LOG.info("Got master {}", cluster.getMaster().getServerName());
// confirm client access still works
assertTrue(admin.balance(BalanceRequest.defaultInstance()).isBalancerRan());
}
}
use of org.apache.hadoop.hbase.master.HMaster in project hbase by apache.
the class TestMasterObserverPostCalls method testPostCreateNamespace.
@Test
public void testPostCreateNamespace() throws IOException {
final Admin admin = UTIL.getAdmin();
final String ns = "postcreatens";
HMaster master = UTIL.getMiniHBaseCluster().getMaster();
MasterObserverForTest observer = master.getMasterCoprocessorHost().findCoprocessor(MasterObserverForTest.class);
// Validate that the post hook is called
int preCount = observer.postHookCalls.get();
NamespaceDescriptor nsDesc = NamespaceDescriptor.create(ns).build();
admin.createNamespace(nsDesc);
int postCount = observer.postHookCalls.get();
assertEquals("Expected 1 invocation of postModifyNamespace", preCount + 1, postCount);
// Then, validate that it's not called when the call fails
preCount = observer.postHookCalls.get();
try {
admin.createNamespace(nsDesc);
fail("Creating an already present namespace should fail");
} catch (IOException e) {
// Pass
}
postCount = observer.postHookCalls.get();
assertEquals("Expected no invocations of postModifyNamespace when the operation fails", preCount, postCount);
}
Aggregations