Search in sources :

Example 1 with HasRegionServerServices

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

the class ReplicationObserver method preCommitStoreFile.

@Override
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "NP_NULL_ON_SOME_PATH", justification = "NPE should never happen; if it does it is a bigger issue")
public void preCommitStoreFile(final ObserverContext<RegionCoprocessorEnvironment> ctx, final byte[] family, final List<Pair<Path, Path>> pairs) throws IOException {
    RegionCoprocessorEnvironment env = ctx.getEnvironment();
    Configuration c = env.getConfiguration();
    if (pairs == null || pairs.isEmpty() || !c.getBoolean(HConstants.REPLICATION_BULKLOAD_ENABLE_KEY, HConstants.REPLICATION_BULKLOAD_ENABLE_DEFAULT)) {
        LOG.debug("Skipping recording bulk load entries in preCommitStoreFile for bulkloaded " + "data replication.");
        return;
    }
    // This is completely cheating AND getting a HRegionServer from a RegionServerEnvironment is
    // just going to break. This is all private. Not allowed. Regions shouldn't assume they are
    // hosted in a RegionServer. TODO: fix.
    RegionServerServices rss = ((HasRegionServerServices) env).getRegionServerServices();
    Replication rep = (Replication) ((HRegionServer) rss).getReplicationSourceService();
    rep.addHFileRefsToQueue(env.getRegionInfo().getTable(), family, pairs);
}
Also used : RegionCoprocessorEnvironment(org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment) HasRegionServerServices(org.apache.hadoop.hbase.coprocessor.HasRegionServerServices) RegionServerServices(org.apache.hadoop.hbase.regionserver.RegionServerServices) Configuration(org.apache.hadoop.conf.Configuration) HasRegionServerServices(org.apache.hadoop.hbase.coprocessor.HasRegionServerServices)

Example 2 with HasRegionServerServices

use of org.apache.hadoop.hbase.coprocessor.HasRegionServerServices 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 = AccessChecker.isAuthorizationSupported(conf);
    if (!authorizationEnabled) {
        LOG.warn("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.");
    }
    if (env instanceof MasterCoprocessorEnvironment) {
        // if running on HMaster
        MasterCoprocessorEnvironment mEnv = (MasterCoprocessorEnvironment) env;
        if (mEnv instanceof HasMasterServices) {
            MasterServices masterServices = ((HasMasterServices) mEnv).getMasterServices();
            zkPermissionWatcher = masterServices.getZKPermissionWatcher();
            accessChecker = masterServices.getAccessChecker();
        }
    } else if (env instanceof RegionServerCoprocessorEnvironment) {
        RegionServerCoprocessorEnvironment rsEnv = (RegionServerCoprocessorEnvironment) env;
        if (rsEnv instanceof HasRegionServerServices) {
            RegionServerServices rsServices = ((HasRegionServerServices) rsEnv).getRegionServerServices();
            zkPermissionWatcher = rsServices.getZKPermissionWatcher();
            accessChecker = rsServices.getAccessChecker();
        }
    } else if (env instanceof RegionCoprocessorEnvironment) {
        // if running at region
        regionEnv = (RegionCoprocessorEnvironment) env;
        conf.addBytesMap(regionEnv.getRegion().getTableDescriptor().getValues());
        compatibleEarlyTermination = conf.getBoolean(AccessControlConstants.CF_ATTRIBUTE_EARLY_OUT, AccessControlConstants.DEFAULT_ATTRIBUTE_EARLY_OUT);
        if (regionEnv instanceof HasRegionServerServices) {
            RegionServerServices rsServices = ((HasRegionServerServices) regionEnv).getRegionServerServices();
            zkPermissionWatcher = rsServices.getZKPermissionWatcher();
            accessChecker = rsServices.getAccessChecker();
        }
    }
    Preconditions.checkState(zkPermissionWatcher != null, "ZKPermissionWatcher is null");
    Preconditions.checkState(accessChecker != null, "AccessChecker is null");
    // set the user-provider.
    this.userProvider = UserProvider.instantiate(env.getConfiguration());
    tableAcls = new MapMaker().weakValues().makeMap();
}
Also used : HasMasterServices(org.apache.hadoop.hbase.coprocessor.HasMasterServices) RegionServerCoprocessorEnvironment(org.apache.hadoop.hbase.coprocessor.RegionServerCoprocessorEnvironment) RegionCoprocessorEnvironment(org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment) HasRegionServerServices(org.apache.hadoop.hbase.coprocessor.HasRegionServerServices) RegionServerServices(org.apache.hadoop.hbase.regionserver.RegionServerServices) HasRegionServerServices(org.apache.hadoop.hbase.coprocessor.HasRegionServerServices) MapMaker(org.apache.hbase.thirdparty.com.google.common.collect.MapMaker) CompoundConfiguration(org.apache.hadoop.hbase.CompoundConfiguration) MasterCoprocessorEnvironment(org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment) MasterServices(org.apache.hadoop.hbase.master.MasterServices) HasMasterServices(org.apache.hadoop.hbase.coprocessor.HasMasterServices)

Example 3 with HasRegionServerServices

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

the class TokenProvider method start.

@Override
public void start(CoprocessorEnvironment env) {
    // if running at region
    if (env instanceof RegionCoprocessorEnvironment) {
        RegionCoprocessorEnvironment regionEnv = (RegionCoprocessorEnvironment) env;
        /* Getting the RpcServer from a RegionCE is wrong. There cannot be an expectation that Region
       is hosted inside a RegionServer. If you need RpcServer, then pass in a RegionServerCE.
       TODO: FIX.
       */
        RegionServerServices rss = ((HasRegionServerServices) regionEnv).getRegionServerServices();
        RpcServerInterface server = rss.getRpcServer();
        SecretManager<?> mgr = ((RpcServer) server).getSecretManager();
        if (mgr instanceof AuthenticationTokenSecretManager) {
            secretManager = (AuthenticationTokenSecretManager) mgr;
        }
    }
}
Also used : RegionCoprocessorEnvironment(org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment) HasRegionServerServices(org.apache.hadoop.hbase.coprocessor.HasRegionServerServices) RegionServerServices(org.apache.hadoop.hbase.regionserver.RegionServerServices) HasRegionServerServices(org.apache.hadoop.hbase.coprocessor.HasRegionServerServices) RpcServer(org.apache.hadoop.hbase.ipc.RpcServer) RpcServerInterface(org.apache.hadoop.hbase.ipc.RpcServerInterface)

Aggregations

HasRegionServerServices (org.apache.hadoop.hbase.coprocessor.HasRegionServerServices)3 RegionCoprocessorEnvironment (org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment)3 RegionServerServices (org.apache.hadoop.hbase.regionserver.RegionServerServices)3 Configuration (org.apache.hadoop.conf.Configuration)1 CompoundConfiguration (org.apache.hadoop.hbase.CompoundConfiguration)1 HasMasterServices (org.apache.hadoop.hbase.coprocessor.HasMasterServices)1 MasterCoprocessorEnvironment (org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment)1 RegionServerCoprocessorEnvironment (org.apache.hadoop.hbase.coprocessor.RegionServerCoprocessorEnvironment)1 RpcServer (org.apache.hadoop.hbase.ipc.RpcServer)1 RpcServerInterface (org.apache.hadoop.hbase.ipc.RpcServerInterface)1 MasterServices (org.apache.hadoop.hbase.master.MasterServices)1 MapMaker (org.apache.hbase.thirdparty.com.google.common.collect.MapMaker)1