Search in sources :

Example 1 with IndexWriter

use of org.apache.phoenix.hbase.index.write.IndexWriter 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)

Example 2 with IndexWriter

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

the class PhoenixTransactionalIndexer method start.

@Override
public void start(CoprocessorEnvironment e) throws IOException {
    final RegionCoprocessorEnvironment env = (RegionCoprocessorEnvironment) e;
    String serverName = env.getRegionServerServices().getServerName().getServerName();
    codec = new PhoenixIndexCodec();
    codec.initialize(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.
    this.writer = new IndexWriter(new LeaveIndexActiveFailurePolicy(), env, serverName + "-tx-index-writer");
}
Also used : RegionCoprocessorEnvironment(org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment) IndexWriter(org.apache.phoenix.hbase.index.write.IndexWriter) LeaveIndexActiveFailurePolicy(org.apache.phoenix.hbase.index.write.LeaveIndexActiveFailurePolicy)

Aggregations

RegionCoprocessorEnvironment (org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment)2 IndexWriter (org.apache.phoenix.hbase.index.write.IndexWriter)2 IOException (java.io.IOException)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 LeaveIndexActiveFailurePolicy (org.apache.phoenix.hbase.index.write.LeaveIndexActiveFailurePolicy)1 RecoveryIndexWriter (org.apache.phoenix.hbase.index.write.RecoveryIndexWriter)1 PerRegionIndexWriteCache (org.apache.phoenix.hbase.index.write.recovery.PerRegionIndexWriteCache)1