org.apache.hadoop.hbase.coprocessor.RegionCoprocessor Java Examples

The following examples show how to use org.apache.hadoop.hbase.coprocessor.RegionCoprocessor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RegionCoprocessorHost.java    From hbase with Apache License 2.0 6 votes vote down vote up
@Override
public RegionEnvironment createEnvironment(RegionCoprocessor instance, int priority, int seq,
    Configuration conf) {
  // If coprocessor exposes any services, register them.
  for (Service service : instance.getServices()) {
    region.registerService(service);
  }
  ConcurrentMap<String, Object> classData;
  // make sure only one thread can add maps
  synchronized (SHARED_DATA_MAP) {
    // as long as at least one RegionEnvironment holds on to its classData it will
    // remain in this map
    classData =
        SHARED_DATA_MAP.computeIfAbsent(instance.getClass().getName(),
            k -> new ConcurrentHashMap<>());
  }
  // If a CoreCoprocessor, return a 'richer' environment, one laden with RegionServerServices.
  return instance.getClass().isAnnotationPresent(CoreCoprocessor.class)?
      new RegionEnvironmentForCoreCoprocessors(instance, priority, seq, conf, region,
          rsServices, classData):
      new RegionEnvironment(instance, priority, seq, conf, region, rsServices, classData);
}
 
Example #2
Source File: PhoenixAccessController.java    From phoenix with Apache License 2.0 6 votes vote down vote up
private List<MasterObserver> getAccessControllers() throws IOException {
    ArrayList<MasterObserver> oldAccessControllers = accessControllers.get();
    if (oldAccessControllers == null) {
        oldAccessControllers = new ArrayList<>();
        RegionCoprocessorHost cpHost = this.env.getCoprocessorHost();
        for (RegionCoprocessor cp : cpHost.findCoprocessors(RegionCoprocessor.class)) {
            if (cp instanceof AccessControlService.Interface && cp instanceof MasterObserver) {
                oldAccessControllers.add((MasterObserver)cp);
                if(cp.getClass().getName().equals(org.apache.hadoop.hbase.security.access.AccessController.class.getName())) {
                    hbaseAccessControllerEnabled = true;
                }
            }
        }
        accessControllers.set(oldAccessControllers);
    }
    return accessControllers.get();
}
 
Example #3
Source File: RegionCoprocessorHost.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor
 * @param impl the coprocessor instance
 * @param priority chaining priority
 */
public RegionEnvironment(final RegionCoprocessor impl, final int priority,
    final int seq, final Configuration conf, final Region region,
    final RegionServerServices services, final ConcurrentMap<String, Object> sharedData) {
  super(impl, priority, seq, conf);
  this.region = region;
  this.sharedData = sharedData;
  this.services = services;
  this.metricRegistry =
      MetricsCoprocessor.createRegistryForRegionCoprocessor(impl.getClass().getName());
}
 
Example #4
Source File: RegionCoprocessorHost.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Override
public RegionCoprocessor checkAndGetInstance(Class<?> implClass)
    throws InstantiationException, IllegalAccessException {
  try {
    if (RegionCoprocessor.class.isAssignableFrom(implClass)) {
      return implClass.asSubclass(RegionCoprocessor.class).getDeclaredConstructor().newInstance();
    } else {
      LOG.error("{} is not of type RegionCoprocessor. Check the configuration of {}",
          implClass.getName(), CoprocessorHost.REGION_COPROCESSOR_CONF_KEY);
      return null;
    }
  } catch (NoSuchMethodException | InvocationTargetException e) {
    throw (InstantiationException) new InstantiationException(implClass.getName()).initCause(e);
  }
}
 
Example #5
Source File: RegionCoprocessorHost.java    From hbase with Apache License 2.0 4 votes vote down vote up
public RegionEnvironmentForCoreCoprocessors(final RegionCoprocessor impl, final int priority,
  final int seq, final Configuration conf, final Region region,
  final RegionServerServices services, final ConcurrentMap<String, Object> sharedData) {
  super(impl, priority, seq, conf, region, services, sharedData);
  this.rsServices = services;
}
 
Example #6
Source File: RegionCoprocessorHost.java    From hbase with Apache License 2.0 4 votes vote down vote up
public BulkLoadObserverOperation(User user) {
  super(RegionCoprocessor::getBulkLoadObserver, user);
}
 
Example #7
Source File: DelegateRegionCoprocessorEnvironment.java    From phoenix with Apache License 2.0 4 votes vote down vote up
@Override
public RegionCoprocessor getInstance() {
    return delegate.getInstance();
}
 
Example #8
Source File: OmidTransactionalProcessor.java    From phoenix with Apache License 2.0 4 votes vote down vote up
@Override
public void start(CoprocessorEnvironment env) throws IOException {
    if (delegate instanceof RegionCoprocessor) {
        ((RegionCoprocessor)delegate).start(env);
    }
}
 
Example #9
Source File: OmidTransactionalProcessor.java    From phoenix with Apache License 2.0 4 votes vote down vote up
@Override
public void stop(CoprocessorEnvironment env) throws IOException {
    if (delegate instanceof RegionCoprocessor) {
        ((RegionCoprocessor)delegate).stop(env);
    }
}
 
Example #10
Source File: OmidGCProcessor.java    From phoenix with Apache License 2.0 4 votes vote down vote up
@Override
public void start(CoprocessorEnvironment env) throws IOException {
    if (delegate instanceof RegionCoprocessor) {
        ((RegionCoprocessor)delegate).start(env);
    }
}
 
Example #11
Source File: OmidGCProcessor.java    From phoenix with Apache License 2.0 4 votes vote down vote up
@Override
public void stop(CoprocessorEnvironment env) throws IOException {
    if (delegate instanceof RegionCoprocessor) {
        ((RegionCoprocessor)delegate).stop(env);
    }
}
 
Example #12
Source File: TephraTransactionalProcessor.java    From phoenix with Apache License 2.0 4 votes vote down vote up
@Override
public void start(CoprocessorEnvironment env) throws IOException {
    if (delegate instanceof RegionCoprocessor) {
        ((RegionCoprocessor)delegate).start(env);
    }
}
 
Example #13
Source File: TephraTransactionalProcessor.java    From phoenix with Apache License 2.0 4 votes vote down vote up
@Override
public void stop(CoprocessorEnvironment env) throws IOException {
    if (delegate instanceof RegionCoprocessor) {
        ((RegionCoprocessor)delegate).stop(env);
    }
}