use of org.apache.phoenix.coprocessor.DelegateRegionCoprocessorEnvironment in project phoenix by apache.
the class Indexer method start.
@Override
public void start(CoprocessorEnvironment e) throws IOException {
try {
final RegionCoprocessorEnvironment env = (RegionCoprocessorEnvironment) e;
String serverName = env.getRegionServerServices().getServerName().getServerName();
if (env.getConfiguration().getBoolean(CHECK_VERSION_CONF_KEY, true)) {
// make sure the right version <-> combinations are allowed.
String errormsg = Indexer.validateVersion(env.getHBaseVersion(), env.getConfiguration());
if (errormsg != null) {
IOException ioe = new IOException(errormsg);
env.getRegionServerServices().abort(errormsg, ioe);
throw ioe;
}
}
this.builder = new IndexBuildManager(env);
// Clone the config since it is shared
Configuration clonedConfig = PropertiesUtil.cloneConfig(e.getConfiguration());
/*
* Set the rpc controller factory so that the HTables used by IndexWriter would
* set the correct priorities on the remote RPC calls.
*/
clonedConfig.setClass(RpcControllerFactory.CUSTOM_CONTROLLER_CONF_KEY, InterRegionServerIndexRpcControllerFactory.class, RpcControllerFactory.class);
// lower the number of rpc retries. We inherit config from HConnectionManager#setServerSideHConnectionRetries,
// which by default uses a multiplier of 10. That is too many retries for our synchronous index writes
clonedConfig.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, env.getConfiguration().getInt(INDEX_WRITER_RPC_RETRIES_NUMBER, DEFAULT_INDEX_WRITER_RPC_RETRIES_NUMBER));
clonedConfig.setInt(HConstants.HBASE_CLIENT_PAUSE, env.getConfiguration().getInt(INDEX_WRITER_RPC_PAUSE, DEFAULT_INDEX_WRITER_RPC_PAUSE));
DelegateRegionCoprocessorEnvironment indexWriterEnv = new DelegateRegionCoprocessorEnvironment(clonedConfig, env);
// setup the actual index writer
this.writer = new IndexWriter(indexWriterEnv, serverName + "-index-writer");
this.rowLockWaitDuration = clonedConfig.getInt("hbase.rowlock.wait.duration", DEFAULT_ROWLOCK_WAIT_DURATION);
this.lockManager = new LockManager();
// Metrics impl for the Indexer -- avoiding unnecessary indirection for hadoop-1/2 compat
this.metricSource = MetricsIndexerSourceFactory.getInstance().create();
setSlowThresholds(e.getConfiguration());
try {
// get the specified failure policy. We only ever override it in tests, but we need to do it
// here
Class<? extends IndexFailurePolicy> policyClass = env.getConfiguration().getClass(INDEX_RECOVERY_FAILURE_POLICY_KEY, StoreFailuresInCachePolicy.class, IndexFailurePolicy.class);
IndexFailurePolicy policy = policyClass.getConstructor(PerRegionIndexWriteCache.class).newInstance(failedIndexEdits);
LOG.debug("Setting up recovery writter with failure policy: " + policy.getClass());
recoveryWriter = new RecoveryIndexWriter(policy, indexWriterEnv, serverName + "-recovery-writer");
} catch (Exception ex) {
throw new IOException("Could not instantiate recovery failure policy!", ex);
}
} catch (NoSuchMethodError ex) {
disabled = true;
super.start(e);
LOG.error("Must be too early a version of HBase. Disabled coprocessor ", ex);
}
}
use of org.apache.phoenix.coprocessor.DelegateRegionCoprocessorEnvironment in project phoenix by apache.
the class PhoenixTransactionalIndexer method start.
@Override
public void start(CoprocessorEnvironment e) throws IOException {
final RegionCoprocessorEnvironment env = (RegionCoprocessorEnvironment) e;
Configuration conf = e.getConfiguration();
String serverName = env.getRegionServerServices().getServerName().getServerName();
codec = new PhoenixIndexCodec(conf, env.getRegion().getRegionInfo().getStartKey(), env.getRegion().getRegionInfo().getEndKey(), env.getRegionInfo().getTable().getName());
// Clone the config since it is shared
Configuration clonedConfig = PropertiesUtil.cloneConfig(e.getConfiguration());
/*
* Set the rpc controller factory so that the HTables used by IndexWriter would
* set the correct priorities on the remote RPC calls.
*/
clonedConfig.setClass(RpcControllerFactory.CUSTOM_CONTROLLER_CONF_KEY, InterRegionServerIndexRpcControllerFactory.class, RpcControllerFactory.class);
// lower the number of rpc retries. We inherit config from HConnectionManager#setServerSideHConnectionRetries,
// which by default uses a multiplier of 10. That is too many retries for our synchronous index writes
clonedConfig.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, env.getConfiguration().getInt(INDEX_WRITER_RPC_RETRIES_NUMBER, DEFAULT_INDEX_WRITER_RPC_RETRIES_NUMBER));
clonedConfig.setInt(HConstants.HBASE_CLIENT_PAUSE, env.getConfiguration().getInt(INDEX_WRITER_RPC_PAUSE, DEFAULT_INDEX_WRITER_RPC_PAUSE));
DelegateRegionCoprocessorEnvironment indexWriterEnv = new DelegateRegionCoprocessorEnvironment(clonedConfig, env);
// setup the actual index writer
// For transactional tables, we keep the index active upon a write failure
// since we have the all versus none behavior for transactions. Also, we
// fail on any write exception since this will end up failing the transaction.
this.writer = new IndexWriter(IndexWriter.getCommitter(indexWriterEnv, ParallelWriterIndexCommitter.class), new LeaveIndexActiveFailurePolicy(), indexWriterEnv, serverName + "-tx-index-writer");
}
Aggregations