org.apache.hadoop.hbase.CoprocessorEnvironment Java Examples

The following examples show how to use org.apache.hadoop.hbase.CoprocessorEnvironment. 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: ConstraintProcessor.java    From hbase with Apache License 2.0 6 votes vote down vote up
@Override
public void start(CoprocessorEnvironment environment) {
  // make sure we are on a region server
  if (!(environment instanceof RegionCoprocessorEnvironment)) {
    throw new IllegalArgumentException(
        "Constraints only act on regions - started in an environment that was not a region");
  }
  RegionCoprocessorEnvironment env = (RegionCoprocessorEnvironment) environment;
  TableDescriptor desc = env.getRegion().getTableDescriptor();
  // load all the constraints from the HTD
  try {
    this.constraints = Constraints.getConstraints(desc, classloader);
  } catch (IOException e) {
    throw new IllegalArgumentException(e);
  }

  if (LOG.isInfoEnabled()) {
    LOG.info("Finished loading " + constraints.size()
        + " user Constraints on table: " + desc.getTableName());
  }

}
 
Example #2
Source File: BackupEndpointObserver.java    From spliceengine with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void start(CoprocessorEnvironment e) throws IOException {
    try {
        region = (HRegion) ((RegionCoprocessorEnvironment) e).getRegion();
        String[] name = region.getTableDescriptor().getTableName().getNameAsString().split(":");
        if (name.length == 2) {
            namespace = name[0];
            tableName = name[1];
        }
        else {
            tableName = name[0];
        }
        regionName = region.getRegionInfo().getEncodedName();

        conf = HConfiguration.unwrapDelegate();
        rootDir = FSUtils.getRootDir(conf);
        fs = FSUtils.getCurrentFileSystem(conf);
        backupDir = new Path(rootDir, BackupRestoreConstants.BACKUP_DIR + "/data/splice/" + tableName + "/" + regionName);
        preparing = new AtomicBoolean(false);
        isCompacting = new AtomicBoolean(false);
        isSplitting = new AtomicBoolean(false);
    } catch (Throwable t) {
        throw CoprocessorUtils.getIOException(t);
    }
}
 
Example #3
Source File: MetaTableMetrics.java    From hbase with Apache License 2.0 6 votes vote down vote up
@Override
public void start(CoprocessorEnvironment env) throws IOException {
  observer = new ExampleRegionObserverMeta();
  if (env instanceof RegionCoprocessorEnvironment
      && ((RegionCoprocessorEnvironment) env).getRegionInfo().getTable() != null
      && ((RegionCoprocessorEnvironment) env).getRegionInfo().getTable()
        .equals(TableName.META_TABLE_NAME)) {
    RegionCoprocessorEnvironment regionCoprocessorEnv = (RegionCoprocessorEnvironment) env;
    registry = regionCoprocessorEnv.getMetricRegistryForRegionServer();
    LossyCounting.LossyCountingListener<String> listener = key -> {
      registry.remove(key);
      metrics.remove(key);
    };
    final Configuration conf = regionCoprocessorEnv.getConfiguration();
    clientMetricsLossyCounting = new LossyCounting<>("clientMetaMetrics", conf, listener);
    regionMetricsLossyCounting = new LossyCounting<>("regionMetaMetrics", conf, listener);
    // only be active mode when this region holds meta table.
    active = true;
  }
}
 
Example #4
Source File: MasterQuotasObserver.java    From hbase with Apache License 2.0 6 votes vote down vote up
@Override
public void start(CoprocessorEnvironment ctx) throws IOException {
  this.conf = ctx.getConfiguration();
  this.quotasEnabled = QuotaUtil.isQuotaEnabled(conf);

  if (!(ctx instanceof MasterCoprocessorEnvironment)) {
    throw new CoprocessorException("Must be loaded on master.");
  }
  // if running on master
  MasterCoprocessorEnvironment mEnv = (MasterCoprocessorEnvironment) ctx;
  if (mEnv instanceof HasMasterServices) {
    this.masterServices = ((HasMasterServices) mEnv).getMasterServices();
  } else {
    throw new CoprocessorException("Must be loaded on a master having master services.");
  }
}
 
Example #5
Source File: OmidCompactor.java    From phoenix-omid with Apache License 2.0 6 votes vote down vote up
@Override
public void start(CoprocessorEnvironment env) throws IOException {
    LOG.info("Starting compactor coprocessor");
    commitTableConf = new HBaseCommitTableConfig();
    String commitTableName = env.getConfiguration().get(COMMIT_TABLE_NAME_KEY);
    if (commitTableName != null) {
        commitTableConf.setTableName(commitTableName);
    }

    connection = RegionConnectionFactory
            .getConnection(RegionConnectionFactory.ConnectionType.COMPACTION_CONNECTION, (RegionCoprocessorEnvironment) env);
    commitTableClient = new HBaseCommitTable(connection, commitTableConf).getClient();
    retainNonTransactionallyDeletedCells =
            env.getConfiguration().getBoolean(HBASE_RETAIN_NON_TRANSACTIONALLY_DELETED_CELLS_KEY,
                    HBASE_RETAIN_NON_TRANSACTIONALLY_DELETED_CELLS_DEFAULT);
    LOG.info("Compactor coprocessor started");
}
 
Example #6
Source File: RSGroupAdminEndpoint.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Override
public void start(CoprocessorEnvironment env) throws IOException {
  if (!(env instanceof HasMasterServices)) {
    throw new IOException("Does not implement HMasterServices");
  }
  master = ((HasMasterServices) env).getMasterServices();
  groupAdminService.initialize(master);
}
 
Example #7
Source File: TestServerCustomProtocol.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Override
public void start(CoprocessorEnvironment env) throws IOException {
  if (env instanceof RegionCoprocessorEnvironment) {
    return;
  }
  throw new CoprocessorException("Must be loaded on a table region!");
}
 
Example #8
Source File: MetaTableMetrics.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Override
public void stop(CoprocessorEnvironment env) throws IOException {
  // since meta region can move around, clear stale metrics when stop.
  for(String metric:metrics){
    registry.remove(metric);
  }
}
 
Example #9
Source File: ColumnAggregationEndpointWithErrors.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Override
public void start(CoprocessorEnvironment env) throws IOException {
  if (env instanceof RegionCoprocessorEnvironment) {
    this.env = (RegionCoprocessorEnvironment)env;
    return;
  }
  throw new CoprocessorException("Must be loaded on a table region!");
}
 
Example #10
Source File: CoprocessorHost.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Override
public int compare(final CoprocessorEnvironment env1,
    final CoprocessorEnvironment env2) {
  if (env1.getPriority() < env2.getPriority()) {
    return -1;
  } else if (env1.getPriority() > env2.getPriority()) {
    return 1;
  }
  if (env1.getLoadSequence() < env2.getLoadSequence()) {
    return -1;
  } else if (env1.getLoadSequence() > env2.getLoadSequence()) {
    return 1;
  }
  return 0;
}
 
Example #11
Source File: IndexWriterUtils.java    From phoenix with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static HTableFactory getDefaultDelegateHTableFactory(CoprocessorEnvironment env) {
  // create a simple delegate factory, setup the way we need
  Configuration conf = env.getConfiguration();
  // set the number of threads allowed per table.
  int htableThreads =
      conf.getInt(IndexWriterUtils.INDEX_WRITER_PER_TABLE_THREADS_CONF_KEY, IndexWriterUtils.DEFAULT_NUM_PER_TABLE_THREADS);
  LOG.trace("Creating HTableFactory with " + htableThreads + " threads for each HTable.");
  IndexManagementUtil.setIfNotSet(conf, HTABLE_THREAD_KEY, htableThreads);
  return new CoprocessorHTableFactory(env);
}
 
Example #12
Source File: TxnLifecycleEndpoint.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void start(CoprocessorEnvironment env) throws IOException{
    try {
        RegionCoprocessorEnvironment rce=(RegionCoprocessorEnvironment)env;
        HRegion region=(HRegion)rce.getRegion();
        HBaseSIEnvironment siEnv = HBaseSIEnvironment.loadEnvironment(new SystemClock(), ZkUtils.getRecoverableZooKeeper());
        SConfiguration configuration=siEnv.configuration();
        TableType table= EnvUtils.getTableType(configuration,rce);
        if(table.equals(TableType.TRANSACTION_TABLE)){
            TransactionResolver resolver=resolverRef.get();
            SIDriver driver=siEnv.getSIDriver();
            assert driver!=null:"SIDriver Cannot be null";
            long txnKeepAliveTimeout = configuration.getTransactionTimeout();
            @SuppressWarnings("unchecked") TxnPartition regionStore=new RegionTxnStore(region,
                    driver.getTxnSupplier(),
                    resolver,
                    txnKeepAliveTimeout,
                    new SystemClock());
            TimestampSource timestampSource=driver.getTimestampSource();
            int txnLockStrips = configuration.getTransactionLockStripes();
            lifecycleStore = new StripedTxnLifecycleStore(txnLockStrips,regionStore,
                    new RegionServerControl(region, (RegionServerServices)rce.getOnlineRegions()),timestampSource);
            isTxnTable=true;
        }
    } catch (Throwable t) {
        throw CoprocessorUtils.getIOException(t);
    }
}
 
Example #13
Source File: ServerCachingEndpointImpl.java    From phoenix with Apache License 2.0 5 votes vote down vote up
@Override
public void start(CoprocessorEnvironment env) throws IOException {
  if (env instanceof RegionCoprocessorEnvironment) {
    this.env = (RegionCoprocessorEnvironment) env;
  } else {
    throw new CoprocessorException("Must be loaded on a table region!");
  }
}
 
Example #14
Source File: RegionServerLifecycleObserver.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Logs the start of the observer and runs the SpliceDriver if needed...
 */
@SuppressFBWarnings(value="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification="intentional")
@Override
public void start(CoprocessorEnvironment e) throws IOException{
    try {
        isHbaseJVM= true;
        lifecycleManager = startEngine(e);
        SpliceClient.isRegionServer = true;
    } catch (Throwable t) {
        throw CoprocessorUtils.getIOException(t);
    }
}
 
Example #15
Source File: PhoenixAccessController.java    From phoenix with Apache License 2.0 5 votes vote down vote up
@Override
public void start(CoprocessorEnvironment env) throws IOException {
    Configuration conf = env.getConfiguration();
    this.accessCheckEnabled = conf.getBoolean(QueryServices.PHOENIX_ACLS_ENABLED,
            QueryServicesOptions.DEFAULT_PHOENIX_ACLS_ENABLED);
        if (!this.accessCheckEnabled) {
            LOGGER.warn(
                    "PhoenixAccessController has been loaded with authorization checks disabled.");
        }
    this.execPermissionsCheckEnabled = conf.getBoolean(AccessControlConstants.EXEC_PERMISSION_CHECKS_KEY,
            AccessControlConstants.DEFAULT_EXEC_PERMISSION_CHECKS);
    if (env instanceof PhoenixMetaDataControllerEnvironment) {
        this.env = (PhoenixMetaDataControllerEnvironment)env;
    } else {
        throw new IllegalArgumentException(
                "Not a valid environment, should be loaded by PhoenixMetaDataControllerEnvironment");
    }

    ZKWatcher zk = null;
    RegionCoprocessorEnvironment regionEnv = this.env.getRegionCoprocessorEnvironment();
    if (regionEnv instanceof HasRegionServerServices) {
        zk = ((HasRegionServerServices) regionEnv).getRegionServerServices().getZooKeeper();
    }
    accessChecker = new AccessChecker(env.getConfiguration(), zk);
    // set the user-provider.
    this.userProvider = UserProvider.instantiate(env.getConfiguration());
    // init superusers and add the server principal (if using security)
    // or process owner as default super user.
    Superusers.initialize(env.getConfiguration());
}
 
Example #16
Source File: RefreshHFilesEndpoint.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Override
public void start(CoprocessorEnvironment env) throws IOException {
  if (env instanceof RegionCoprocessorEnvironment) {
    this.env = (RegionCoprocessorEnvironment) env;
  } else {
    throw new CoprocessorException("Must be loaded on a table region!");
  }
}
 
Example #17
Source File: Indexer.java    From phoenix with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void stop(CoprocessorEnvironment e) throws IOException {
  if (this.stopped) {
    return;
  }
  if (this.disabled) {
      super.stop(e);
      return;
    }
  this.stopped = true;
  String msg = "Indexer is being stopped";
  this.builder.stop(msg);
  this.writer.stop(msg);
  this.recoveryWriter.stop(msg);
}
 
Example #18
Source File: IIEndpoint.java    From Kylin with Apache License 2.0 5 votes vote down vote up
@Override
public void start(CoprocessorEnvironment env) throws IOException {
    if (env instanceof RegionCoprocessorEnvironment) {
        this.env = (RegionCoprocessorEnvironment) env;
    } else {
        throw new CoprocessorException("Must be loaded on a table region!");
    }
}
 
Example #19
Source File: Export.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Override
public void start(CoprocessorEnvironment environment) throws IOException {
  if (environment instanceof RegionCoprocessorEnvironment) {
    env = (RegionCoprocessorEnvironment) environment;
    userProvider = UserProvider.instantiate(env.getConfiguration());
  } else {
    throw new CoprocessorException("Must be loaded on a table region!");
  }
}
 
Example #20
Source File: ServerCachingEndpointImpl.java    From phoenix with Apache License 2.0 5 votes vote down vote up
@Override
public void start(CoprocessorEnvironment env) throws IOException {
  if (env instanceof RegionCoprocessorEnvironment) {
    this.env = (RegionCoprocessorEnvironment) env;
  } else {
    throw new CoprocessorException("Must be loaded on a table region!");
  }
}
 
Example #21
Source File: AggregateProtocolEndPoint.java    From eagle with Apache License 2.0 5 votes vote down vote up
@Override
public void start(CoprocessorEnvironment env) throws IOException {
    if (env instanceof RegionCoprocessorEnvironment) {
        this.env = (RegionCoprocessorEnvironment) env;
    } else {
        throw new CoprocessorException("Must be loaded on a table region!");
    }
}
 
Example #22
Source File: AggregationEndpoint.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Override
public void start(final CoprocessorEnvironment env) throws IOException {
  if (env instanceof RegionCoprocessorEnvironment) {
    this.env = (RegionCoprocessorEnvironment) env;
  } else {
    throw new CoprocessorException("Must be loaded on a table region!");
  }
}
 
Example #23
Source File: TestAccessController3.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Override
public void stop(CoprocessorEnvironment env) {
  super.stop(env);
  if (callSuperTwice) {
    super.stop(env);
  }
}
 
Example #24
Source File: SolrRegionObserver.java    From SolrCoprocessor with Apache License 2.0 5 votes vote down vote up
@Override
public void stop(CoprocessorEnvironment e) throws IOException {
	synchronized (SolrRegionObserver.class) {
		_startCount--;
		if (_startCount > 0) { //��������
			return;
		}
	}

	this.destroy(e);
}
 
Example #25
Source File: SolrRegionObserver.java    From SolrCoprocessor with Apache License 2.0 5 votes vote down vote up
@Override
public void start(CoprocessorEnvironment e) throws IOException {
	synchronized (SolrRegionObserver.class) {
		_startCount++;
		if (_startCount > 1) { //�Ѿ���ʼ�����
			return;
		}
	}

	init(e);
}
 
Example #26
Source File: ZooKeeperScanPolicyObserver.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Override
public void start(CoprocessorEnvironment env) throws IOException {
  RegionCoprocessorEnvironment renv = (RegionCoprocessorEnvironment) env;
  try {
    this.cache = ((ZKDataHolder) renv.getSharedData().computeIfAbsent(ZKKEY, k -> {
      String ensemble = renv.getConfiguration().get(ZK_ENSEMBLE_KEY);
      int sessionTimeout =
          renv.getConfiguration().getInt(ZK_SESSION_TIMEOUT_KEY, ZK_SESSION_TIMEOUT_DEFAULT);
      return new ZKDataHolder(ensemble, sessionTimeout);
    })).acquire();
  } catch (Exception e) {
    throw new IOException(e);
  }
}
 
Example #27
Source File: TransactionProcessor.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
@Override
public void start(CoprocessorEnvironment e) throws IOException {
  if (e instanceof RegionCoprocessorEnvironment) {
    RegionCoprocessorEnvironment env = (RegionCoprocessorEnvironment) e;
    this.cacheSupplier = getTransactionStateCacheSupplier(env);
    this.cache = cacheSupplier.get();

    HTableDescriptor tableDesc = env.getRegion().getTableDesc();
    for (HColumnDescriptor columnDesc : tableDesc.getFamilies()) {
      String columnTTL = columnDesc.getValue(TxConstants.PROPERTY_TTL);
      long ttl = 0;
      if (columnTTL != null) {
        try {
          ttl = Long.parseLong(columnTTL);
          LOG.info("Family " + columnDesc.getNameAsString() + " has TTL of " + columnTTL);
        } catch (NumberFormatException nfe) {
          LOG.warn("Invalid TTL value configured for column family " + columnDesc.getNameAsString() +
                     ", value = " + columnTTL);
        }
      }
      ttlByFamily.put(columnDesc.getName(), ttl);
    }

    this.allowEmptyValues = getAllowEmptyValues(env, tableDesc);
    this.txMaxLifetimeMillis = getTxMaxLifetimeMillis(env);
    this.readNonTxnData = Boolean.valueOf(tableDesc.getValue(TxConstants.READ_NON_TX_DATA));
    if (readNonTxnData) {
      LOG.info("Reading pre-existing data enabled for table " + tableDesc.getNameAsString());
    }
    initializePruneState(env);
  }
}
 
Example #28
Source File: TransactionProcessor.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
@Override
public void stop(CoprocessorEnvironment e) throws IOException {
  try {
    resetPruneState();
  } finally {
    if (cacheSupplier != null) {
      cacheSupplier.release();
    }
  }
}
 
Example #29
Source File: TransactionProcessor.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
@Override
public void start(CoprocessorEnvironment e) throws IOException {
  if (e instanceof RegionCoprocessorEnvironment) {
    RegionCoprocessorEnvironment env = (RegionCoprocessorEnvironment) e;
    this.cacheSupplier = getTransactionStateCacheSupplier(env);
    this.cache = cacheSupplier.get();

    HTableDescriptor tableDesc = env.getRegion().getTableDesc();
    for (HColumnDescriptor columnDesc : tableDesc.getFamilies()) {
      String columnTTL = columnDesc.getValue(TxConstants.PROPERTY_TTL);
      long ttl = 0;
      if (columnTTL != null) {
        try {
          ttl = Long.parseLong(columnTTL);
          LOG.info("Family " + columnDesc.getNameAsString() + " has TTL of " + columnTTL);
        } catch (NumberFormatException nfe) {
          LOG.warn("Invalid TTL value configured for column family " + columnDesc.getNameAsString() +
                     ", value = " + columnTTL);
        }
      }
      ttlByFamily.put(columnDesc.getName(), ttl);
    }

    this.allowEmptyValues = getAllowEmptyValues(env, tableDesc);
    this.txMaxLifetimeMillis = getTxMaxLifetimeMillis(env);
    this.readNonTxnData = Boolean.valueOf(tableDesc.getValue(TxConstants.READ_NON_TX_DATA));
    if (readNonTxnData) {
      LOG.info("Reading pre-existing data enabled for table " + tableDesc.getNameAsString());
    }
    initializePruneState(env);
  }
}
 
Example #30
Source File: TransactionProcessor.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
@Override
public void stop(CoprocessorEnvironment e) throws IOException {
  try {
    resetPruneState();
  } finally {
    if (cacheSupplier != null) {
      cacheSupplier.release();
    }
  }
}