Search in sources :

Example 41 with HMaster

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

the class TestMasterObserver method testStarted.

@Test
public void testStarted() throws Exception {
    SingleProcessHBaseCluster cluster = UTIL.getHBaseCluster();
    HMaster master = cluster.getMaster();
    assertTrue("Master should be active", master.isActiveMaster());
    MasterCoprocessorHost host = master.getMasterCoprocessorHost();
    assertNotNull("CoprocessorHost should not be null", host);
    CPMasterObserver cp = host.findCoprocessor(CPMasterObserver.class);
    assertNotNull("CPMasterObserver coprocessor not found or not installed!", cp);
    // check basic lifecycle
    assertTrue("MasterObserver should have been started", cp.wasStarted());
    assertTrue("preMasterInitialization() hook should have been called", cp.wasMasterInitializationCalled());
    assertTrue("postStartMaster() hook should have been called", cp.wasStartMasterCalled());
}
Also used : SingleProcessHBaseCluster(org.apache.hadoop.hbase.SingleProcessHBaseCluster) MasterCoprocessorHost(org.apache.hadoop.hbase.master.MasterCoprocessorHost) HMaster(org.apache.hadoop.hbase.master.HMaster) Test(org.junit.Test)

Example 42 with HMaster

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

the class TestMasterObserver method testGetProceduresOperation.

@Test
public void testGetProceduresOperation() throws Exception {
    SingleProcessHBaseCluster cluster = UTIL.getHBaseCluster();
    HMaster master = cluster.getMaster();
    MasterCoprocessorHost host = master.getMasterCoprocessorHost();
    CPMasterObserver cp = host.findCoprocessor(CPMasterObserver.class);
    cp.resetStates();
    master.getProcedures();
    assertTrue("Coprocessor should be called on get procedures request", cp.wasGetProceduresCalled());
}
Also used : SingleProcessHBaseCluster(org.apache.hadoop.hbase.SingleProcessHBaseCluster) MasterCoprocessorHost(org.apache.hadoop.hbase.master.MasterCoprocessorHost) HMaster(org.apache.hadoop.hbase.master.HMaster) Test(org.junit.Test)

Example 43 with HMaster

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

the class TestMasterObserver method testNamespaceOperations.

@Test
public void testNamespaceOperations() throws Exception {
    SingleProcessHBaseCluster cluster = UTIL.getHBaseCluster();
    String testNamespace = "observed_ns";
    HMaster master = cluster.getMaster();
    MasterCoprocessorHost host = master.getMasterCoprocessorHost();
    CPMasterObserver cp = host.findCoprocessor(CPMasterObserver.class);
    // create a table
    Admin admin = UTIL.getAdmin();
    admin.listNamespaces();
    assertTrue("preListNamespaces should have been called", cp.preListNamespacesCalled);
    assertTrue("postListNamespaces should have been called", cp.postListNamespacesCalled);
    admin.createNamespace(NamespaceDescriptor.create(testNamespace).build());
    assertTrue("Test namespace should be created", cp.wasCreateNamespaceCalled());
    assertNotNull(admin.getNamespaceDescriptor(testNamespace));
    assertTrue("Test namespace descriptor should have been called", cp.wasGetNamespaceDescriptorCalled());
// This test used to do a bunch w/ bypass but bypass of these table and namespace stuff has
// been removed so the testing code was removed.
}
Also used : SingleProcessHBaseCluster(org.apache.hadoop.hbase.SingleProcessHBaseCluster) MasterCoprocessorHost(org.apache.hadoop.hbase.master.MasterCoprocessorHost) HMaster(org.apache.hadoop.hbase.master.HMaster) Admin(org.apache.hadoop.hbase.client.Admin) Test(org.junit.Test)

Example 44 with HMaster

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

the class TestMasterObserver method testGetLocksOperation.

@Test
public void testGetLocksOperation() throws Exception {
    SingleProcessHBaseCluster cluster = UTIL.getHBaseCluster();
    HMaster master = cluster.getMaster();
    MasterCoprocessorHost host = master.getMasterCoprocessorHost();
    CPMasterObserver cp = host.findCoprocessor(CPMasterObserver.class);
    cp.resetStates();
    master.getLocks();
    assertTrue("Coprocessor should be called on get locks request", cp.wasGetLocksCalled());
}
Also used : SingleProcessHBaseCluster(org.apache.hadoop.hbase.SingleProcessHBaseCluster) MasterCoprocessorHost(org.apache.hadoop.hbase.master.MasterCoprocessorHost) HMaster(org.apache.hadoop.hbase.master.HMaster) Test(org.junit.Test)

Example 45 with HMaster

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

the class TestMasterObserver method testTableNamesEnumeration.

@Test
public void testTableNamesEnumeration() throws Exception {
    SingleProcessHBaseCluster cluster = UTIL.getHBaseCluster();
    HMaster master = cluster.getMaster();
    MasterCoprocessorHost host = master.getMasterCoprocessorHost();
    CPMasterObserver cp = host.findCoprocessor(CPMasterObserver.class);
    cp.resetStates();
    master.getMasterRpcServices().getTableNames(null, GetTableNamesRequest.newBuilder().build());
    assertTrue("Coprocessor should be called on table names request", cp.wasGetTableNamesCalled());
}
Also used : SingleProcessHBaseCluster(org.apache.hadoop.hbase.SingleProcessHBaseCluster) MasterCoprocessorHost(org.apache.hadoop.hbase.master.MasterCoprocessorHost) 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