Search in sources :

Example 76 with HMaster

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

the class TestHbck method testRunHbckChore.

@Test
public void testRunHbckChore() throws Exception {
    HMaster master = TEST_UTIL.getMiniHBaseCluster().getMaster();
    long endTimestamp = master.getHbckChore().getCheckingEndTimestamp();
    Hbck hbck = getHbck();
    boolean ran = false;
    while (!ran) {
        ran = hbck.runHbckChore();
        if (ran) {
            assertTrue(master.getHbckChore().getCheckingEndTimestamp() > endTimestamp);
        }
    }
}
Also used : HMaster(org.apache.hadoop.hbase.master.HMaster) Test(org.junit.Test)

Example 77 with HMaster

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

the class TestIncreaseMetaReplicaThroughConfig method testUpgradeAndIncreaseReplicaCount.

@Test
public void testUpgradeAndIncreaseReplicaCount() throws Exception {
    HMaster oldMaster = TEST_UTIL.getMiniHBaseCluster().getMaster();
    TableDescriptors oldTds = oldMaster.getTableDescriptors();
    TableDescriptor oldMetaTd = oldTds.get(TableName.META_TABLE_NAME);
    assertEquals(3, oldMetaTd.getRegionReplication());
    // force update the replica count to 1 and then kill the master, to simulate that hen upgrading,
    // we have no region replication in meta table descriptor but we actually have meta region
    // replicas
    oldTds.update(TableDescriptorBuilder.newBuilder(oldMetaTd).setRegionReplication(1).build());
    oldMaster.stop("Restarting");
    TEST_UTIL.waitFor(30000, () -> oldMaster.isStopped());
    // increase replica count to 5 through Configuration
    TEST_UTIL.getMiniHBaseCluster().getConfiguration().setInt(HConstants.META_REPLICAS_NUM, 5);
    TEST_UTIL.getMiniHBaseCluster().startMaster();
    TEST_UTIL.waitFor(30000, () -> TEST_UTIL.getZooKeeperWatcher().getMetaReplicaNodes().size() == 5);
}
Also used : TableDescriptors(org.apache.hadoop.hbase.TableDescriptors) HMaster(org.apache.hadoop.hbase.master.HMaster) Test(org.junit.Test)

Example 78 with HMaster

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

the class TestMasterRegistry method testRegistryRPCs.

@Test
public void testRegistryRPCs() throws Exception {
    Configuration conf = new Configuration(TEST_UTIL.getConfiguration());
    HMaster activeMaster = TEST_UTIL.getHBaseCluster().getMaster();
    final int size = activeMaster.getMetaLocations().size();
    for (int numHedgedReqs = 1; numHedgedReqs <= size; numHedgedReqs++) {
        conf.setInt(MasterRegistry.MASTER_REGISTRY_HEDGED_REQS_FANOUT_KEY, numHedgedReqs);
        try (MasterRegistry registry = new MasterRegistry(conf)) {
            // Add wait on all replicas being assigned before proceeding w/ test. Failed on occasion
            // because not all replicas had made it up before test started.
            RegionReplicaTestHelper.waitUntilAllMetaReplicasAreReady(TEST_UTIL, registry);
            assertEquals(registry.getClusterId().get(), activeMaster.getClusterId());
            assertEquals(registry.getActiveMaster().get(), activeMaster.getServerName());
            List<HRegionLocation> metaLocations = Arrays.asList(registry.getMetaRegionLocations().get().getRegionLocations());
            List<HRegionLocation> actualMetaLocations = activeMaster.getMetaLocations();
            Collections.sort(metaLocations);
            Collections.sort(actualMetaLocations);
            assertEquals(actualMetaLocations, metaLocations);
        }
    }
}
Also used : HRegionLocation(org.apache.hadoop.hbase.HRegionLocation) Configuration(org.apache.hadoop.conf.Configuration) HMaster(org.apache.hadoop.hbase.master.HMaster) Test(org.junit.Test)

Example 79 with HMaster

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

the class TestMetaRegionLocationCache method testStandByMetaLocations.

@Test
public void testStandByMetaLocations() throws Exception {
    HMaster standBy = TEST_UTIL.getMiniHBaseCluster().startMaster().getMaster();
    verifyCachedMetaLocations(standBy);
}
Also used : HMaster(org.apache.hadoop.hbase.master.HMaster) Test(org.junit.Test)

Example 80 with HMaster

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

the class TestRpcConnectionRegistry method testRegistryRPCs.

@Test
public void testRegistryRPCs() throws Exception {
    HMaster activeMaster = UTIL.getHBaseCluster().getMaster();
    // sleep 3 seconds, since our initial delay is 1 second, we should have refreshed the endpoints
    Thread.sleep(3000);
    assertThat(registry.getParsedServers(), hasItems(activeMaster.getServerManager().getOnlineServersList().toArray(new ServerName[0])));
    // Add wait on all replicas being assigned before proceeding w/ test. Failed on occasion
    // because not all replicas had made it up before test started.
    RegionReplicaTestHelper.waitUntilAllMetaReplicasAreReady(UTIL, registry);
    assertEquals(registry.getClusterId().get(), activeMaster.getClusterId());
    assertEquals(registry.getActiveMaster().get(), activeMaster.getServerName());
    List<HRegionLocation> metaLocations = Arrays.asList(registry.getMetaRegionLocations().get().getRegionLocations());
    List<HRegionLocation> actualMetaLocations = activeMaster.getMetaLocations();
    Collections.sort(metaLocations);
    Collections.sort(actualMetaLocations);
    assertEquals(actualMetaLocations, metaLocations);
    // test that the node count config works
    setMaxNodeCount(1);
    UTIL.waitFor(10000, () -> registry.getParsedServers().size() == 1);
}
Also used : HRegionLocation(org.apache.hadoop.hbase.HRegionLocation) 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