Search in sources :

Example 1 with IndexFailurePolicy

use of org.apache.phoenix.hbase.index.write.IndexFailurePolicy in project phoenix by apache.

the class Indexer method start.

@Override
public void start(CoprocessorEnvironment e) throws IOException {
    try {
        final RegionCoprocessorEnvironment env = (RegionCoprocessorEnvironment) e;
        this.environment = env;
        env.getConfiguration().setClass(RpcControllerFactory.CUSTOM_CONTROLLER_CONF_KEY, ServerRpcControllerFactory.class, RpcControllerFactory.class);
        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);
        // setup the actual index writer
        this.writer = new IndexWriter(env, serverName + "-index-writer");
        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, env, 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);
    }
}
Also used : IndexFailurePolicy(org.apache.phoenix.hbase.index.write.IndexFailurePolicy) PerRegionIndexWriteCache(org.apache.phoenix.hbase.index.write.recovery.PerRegionIndexWriteCache) RegionCoprocessorEnvironment(org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment) IndexWriter(org.apache.phoenix.hbase.index.write.IndexWriter) RecoveryIndexWriter(org.apache.phoenix.hbase.index.write.RecoveryIndexWriter) RecoveryIndexWriter(org.apache.phoenix.hbase.index.write.RecoveryIndexWriter) IndexBuildManager(org.apache.phoenix.hbase.index.builder.IndexBuildManager) IOException(java.io.IOException) IndexManagementUtil.rethrowIndexingException(org.apache.phoenix.hbase.index.util.IndexManagementUtil.rethrowIndexingException) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 RegionCoprocessorEnvironment (org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment)1 IndexBuildManager (org.apache.phoenix.hbase.index.builder.IndexBuildManager)1 IndexManagementUtil.rethrowIndexingException (org.apache.phoenix.hbase.index.util.IndexManagementUtil.rethrowIndexingException)1 IndexFailurePolicy (org.apache.phoenix.hbase.index.write.IndexFailurePolicy)1 IndexWriter (org.apache.phoenix.hbase.index.write.IndexWriter)1 RecoveryIndexWriter (org.apache.phoenix.hbase.index.write.RecoveryIndexWriter)1 PerRegionIndexWriteCache (org.apache.phoenix.hbase.index.write.recovery.PerRegionIndexWriteCache)1