Search in sources :

Example 1 with RegionServerCoprocessorEnvironment

use of org.apache.hadoop.hbase.coprocessor.RegionServerCoprocessorEnvironment in project hbase by apache.

the class AccessController method start.

/* ---- MasterObserver implementation ---- */
@Override
public void start(CoprocessorEnvironment env) throws IOException {
    CompoundConfiguration conf = new CompoundConfiguration();
    conf.add(env.getConfiguration());
    authorizationEnabled = isAuthorizationSupported(conf);
    if (!authorizationEnabled) {
        LOG.warn("The AccessController has been loaded with authorization checks disabled.");
    }
    shouldCheckExecPermission = conf.getBoolean(AccessControlConstants.EXEC_PERMISSION_CHECKS_KEY, AccessControlConstants.DEFAULT_EXEC_PERMISSION_CHECKS);
    cellFeaturesEnabled = (HFile.getFormatVersion(conf) >= HFile.MIN_FORMAT_VERSION_WITH_TAGS);
    if (!cellFeaturesEnabled) {
        LOG.info("A minimum HFile version of " + HFile.MIN_FORMAT_VERSION_WITH_TAGS + " is required to persist cell ACLs. Consider setting " + HFile.FORMAT_VERSION_KEY + " accordingly.");
    }
    ZooKeeperWatcher zk = null;
    if (env instanceof MasterCoprocessorEnvironment) {
        // if running on HMaster
        MasterCoprocessorEnvironment mEnv = (MasterCoprocessorEnvironment) env;
        zk = mEnv.getMasterServices().getZooKeeper();
    } else if (env instanceof RegionServerCoprocessorEnvironment) {
        RegionServerCoprocessorEnvironment rsEnv = (RegionServerCoprocessorEnvironment) env;
        zk = rsEnv.getRegionServerServices().getZooKeeper();
    } else if (env instanceof RegionCoprocessorEnvironment) {
        // if running at region
        regionEnv = (RegionCoprocessorEnvironment) env;
        conf.addStringMap(regionEnv.getRegion().getTableDesc().getConfiguration());
        zk = regionEnv.getRegionServerServices().getZooKeeper();
        compatibleEarlyTermination = conf.getBoolean(AccessControlConstants.CF_ATTRIBUTE_EARLY_OUT, AccessControlConstants.DEFAULT_ATTRIBUTE_EARLY_OUT);
    }
    // set the user-provider.
    this.userProvider = UserProvider.instantiate(env.getConfiguration());
    // throw RuntimeException so that the coprocessor is unloaded.
    if (zk != null) {
        try {
            this.authManager = TableAuthManager.getOrCreate(zk, env.getConfiguration());
        } catch (IOException ioe) {
            throw new RuntimeException("Error obtaining TableAuthManager", ioe);
        }
    } else {
        throw new RuntimeException("Error obtaining TableAuthManager, zk found null.");
    }
    tableAcls = new MapMaker().weakValues().makeMap();
}
Also used : RegionServerCoprocessorEnvironment(org.apache.hadoop.hbase.coprocessor.RegionServerCoprocessorEnvironment) RegionCoprocessorEnvironment(org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment) ZooKeeperWatcher(org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher) MapMaker(com.google.common.collect.MapMaker) CompoundConfiguration(org.apache.hadoop.hbase.CompoundConfiguration) MasterCoprocessorEnvironment(org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException)

Example 2 with RegionServerCoprocessorEnvironment

use of org.apache.hadoop.hbase.coprocessor.RegionServerCoprocessorEnvironment in project hbase by apache.

the class TestAccessController2 method testCoprocessorLoading.

@Test(timeout = 180000)
public void testCoprocessorLoading() throws Exception {
    MasterCoprocessorHost cpHost = TEST_UTIL.getMiniHBaseCluster().getMaster().getMasterCoprocessorHost();
    cpHost.load(MyAccessController.class, Coprocessor.PRIORITY_HIGHEST, conf);
    AccessController ACCESS_CONTROLLER = (AccessController) cpHost.findCoprocessor(MyAccessController.class.getName());
    MasterCoprocessorEnvironment CP_ENV = cpHost.createEnvironment(MyAccessController.class, ACCESS_CONTROLLER, Coprocessor.PRIORITY_HIGHEST, 1, conf);
    RegionServerCoprocessorHost rsHost = TEST_UTIL.getMiniHBaseCluster().getRegionServer(0).getRegionServerCoprocessorHost();
    RegionServerCoprocessorEnvironment RSCP_ENV = rsHost.createEnvironment(MyAccessController.class, ACCESS_CONTROLLER, Coprocessor.PRIORITY_HIGHEST, 1, conf);
}
Also used : MasterCoprocessorHost(org.apache.hadoop.hbase.master.MasterCoprocessorHost) RegionServerCoprocessorEnvironment(org.apache.hadoop.hbase.coprocessor.RegionServerCoprocessorEnvironment) RegionServerCoprocessorHost(org.apache.hadoop.hbase.regionserver.RegionServerCoprocessorHost) MasterCoprocessorEnvironment(org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment) Test(org.junit.Test)

Aggregations

MasterCoprocessorEnvironment (org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment)2 RegionServerCoprocessorEnvironment (org.apache.hadoop.hbase.coprocessor.RegionServerCoprocessorEnvironment)2 MapMaker (com.google.common.collect.MapMaker)1 IOException (java.io.IOException)1 CompoundConfiguration (org.apache.hadoop.hbase.CompoundConfiguration)1 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)1 RegionCoprocessorEnvironment (org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment)1 MasterCoprocessorHost (org.apache.hadoop.hbase.master.MasterCoprocessorHost)1 RegionServerCoprocessorHost (org.apache.hadoop.hbase.regionserver.RegionServerCoprocessorHost)1 ZooKeeperWatcher (org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher)1 Test (org.junit.Test)1