Search in sources :

Example 1 with MasterCoprocessorHost

use of org.apache.hadoop.hbase.master.MasterCoprocessorHost 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());
}
Also used : MasterCoprocessorHost(org.apache.hadoop.hbase.master.MasterCoprocessorHost) HMaster(org.apache.hadoop.hbase.master.HMaster) MiniHBaseCluster(org.apache.hadoop.hbase.MiniHBaseCluster) Test(org.junit.Test)

Example 2 with MasterCoprocessorHost

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

the class TestHTableWrapper method testHTableInterfaceMethods.

@Test
public void testHTableInterfaceMethods() throws Exception {
    Configuration conf = util.getConfiguration();
    MasterCoprocessorHost cpHost = util.getMiniHBaseCluster().getMaster().getMasterCoprocessorHost();
    Class<?> implClazz = DummyRegionObserver.class;
    cpHost.load(implClazz, Coprocessor.PRIORITY_HIGHEST, conf);
    CoprocessorEnvironment env = cpHost.findCoprocessorEnvironment(implClazz.getName());
    assertEquals(Coprocessor.VERSION, env.getVersion());
    assertEquals(VersionInfo.getVersion(), env.getHBaseVersion());
    hTableInterface = env.getTable(TEST_TABLE);
    checkHTableInterfaceMethods();
    cpHost.shutdown(env);
}
Also used : MasterCoprocessorHost(org.apache.hadoop.hbase.master.MasterCoprocessorHost) Configuration(org.apache.hadoop.conf.Configuration) CoprocessorEnvironment(org.apache.hadoop.hbase.CoprocessorEnvironment) Test(org.junit.Test)

Example 3 with MasterCoprocessorHost

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

the class MergeTableRegionsProcedure method preMergeRegionsCommit.

/**
 * Post merge region action
 * @param env MasterProcedureEnv
 */
private void preMergeRegionsCommit(final MasterProcedureEnv env) throws IOException {
    final MasterCoprocessorHost cpHost = env.getMasterCoprocessorHost();
    if (cpHost != null) {
        @MetaMutationAnnotation final List<Mutation> metaEntries = new ArrayList<>();
        cpHost.preMergeRegionsCommit(regionsToMerge, metaEntries, getUser());
        try {
            for (Mutation p : metaEntries) {
                RegionInfo.parseRegionName(p.getRow());
            }
        } catch (IOException e) {
            LOG.error("Row key of mutation from coprocessor is not parsable as region name. " + "Mutations from coprocessor should only be for hbase:meta table.", e);
            throw e;
        }
    }
}
Also used : MasterCoprocessorHost(org.apache.hadoop.hbase.master.MasterCoprocessorHost) MetaMutationAnnotation(org.apache.hadoop.hbase.MetaMutationAnnotation) ArrayList(java.util.ArrayList) Mutation(org.apache.hadoop.hbase.client.Mutation) IOException(java.io.IOException)

Example 4 with MasterCoprocessorHost

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

the class CloneSnapshotProcedure method preCloneSnapshot.

/**
 * Action before cloning from snapshot.
 * @param env MasterProcedureEnv
 * @throws IOException
 * @throws InterruptedException
 */
private void preCloneSnapshot(final MasterProcedureEnv env) throws IOException, InterruptedException {
    if (!getTableName().isSystemTable()) {
        // Check and update namespace quota
        final MasterFileSystem mfs = env.getMasterServices().getMasterFileSystem();
        SnapshotManifest manifest = SnapshotManifest.open(env.getMasterConfiguration(), mfs.getFileSystem(), SnapshotDescriptionUtils.getCompletedSnapshotDir(snapshot, mfs.getRootDir()), snapshot);
        ProcedureSyncWait.getMasterQuotaManager(env).checkNamespaceTableAndRegionQuota(getTableName(), manifest.getRegionManifestsMap().size());
    }
    final MasterCoprocessorHost cpHost = env.getMasterCoprocessorHost();
    if (cpHost != null) {
        cpHost.preCreateTableAction(tableDescriptor, null, getUser());
    }
}
Also used : MasterFileSystem(org.apache.hadoop.hbase.master.MasterFileSystem) SnapshotManifest(org.apache.hadoop.hbase.snapshot.SnapshotManifest) MasterCoprocessorHost(org.apache.hadoop.hbase.master.MasterCoprocessorHost)

Example 5 with MasterCoprocessorHost

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

the class SplitTableRegionProcedure method preSplitRegionBeforeMETA.

/**
 * Post split region actions before the Point-of-No-Return step
 * @param env MasterProcedureEnv
 */
private void preSplitRegionBeforeMETA(final MasterProcedureEnv env) throws IOException, InterruptedException {
    final List<Mutation> metaEntries = new ArrayList<Mutation>();
    final MasterCoprocessorHost cpHost = env.getMasterCoprocessorHost();
    if (cpHost != null) {
        cpHost.preSplitBeforeMETAAction(getSplitRow(), metaEntries, getUser());
        try {
            for (Mutation p : metaEntries) {
                RegionInfo.parseRegionName(p.getRow());
            }
        } catch (IOException e) {
            LOG.error("pid=" + getProcId() + " row key of mutation from coprocessor not parsable as " + "region name." + "Mutations from coprocessor should only for hbase:meta table.");
            throw e;
        }
    }
}
Also used : MasterCoprocessorHost(org.apache.hadoop.hbase.master.MasterCoprocessorHost) ArrayList(java.util.ArrayList) Mutation(org.apache.hadoop.hbase.client.Mutation) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) InterruptedIOException(java.io.InterruptedIOException) IOException(java.io.IOException)

Aggregations

MasterCoprocessorHost (org.apache.hadoop.hbase.master.MasterCoprocessorHost)62 Test (org.junit.Test)18 IOException (java.io.IOException)16 HMaster (org.apache.hadoop.hbase.master.HMaster)14 SingleProcessHBaseCluster (org.apache.hadoop.hbase.SingleProcessHBaseCluster)13 TableName (org.apache.hadoop.hbase.TableName)12 RegionServerCoprocessorHost (org.apache.hadoop.hbase.regionserver.RegionServerCoprocessorHost)7 BeforeClass (org.junit.BeforeClass)7 ArrayList (java.util.ArrayList)6 RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)6 TableDescriptor (org.apache.hadoop.hbase.client.TableDescriptor)6 Admin (org.apache.hadoop.hbase.client.Admin)5 Configuration (org.apache.hadoop.conf.Configuration)4 Path (org.apache.hadoop.fs.Path)4 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)4 Mutation (org.apache.hadoop.hbase.client.Mutation)4 InterruptedIOException (java.io.InterruptedIOException)3 FileSystem (org.apache.hadoop.fs.FileSystem)3 MasterFileSystem (org.apache.hadoop.hbase.master.MasterFileSystem)3 FileNotFoundException (java.io.FileNotFoundException)2