Search in sources :

Example 11 with CConfigurationReader

use of co.cask.cdap.data2.transaction.queue.hbase.coprocessor.CConfigurationReader in project cdap by caskdata.

the class PayloadTableRegionObserver method start.

@Override
public void start(CoprocessorEnvironment e) throws IOException {
    if (e instanceof RegionCoprocessorEnvironment) {
        RegionCoprocessorEnvironment env = (RegionCoprocessorEnvironment) e;
        HTableDescriptor tableDesc = env.getRegion().getTableDesc();
        String metadataTableNamespace = tableDesc.getValue(Constants.MessagingSystem.HBASE_METADATA_TABLE_NAMESPACE);
        String hbaseNamespacePrefix = tableDesc.getValue(Constants.Dataset.TABLE_PREFIX);
        prefixLength = Integer.valueOf(tableDesc.getValue(Constants.MessagingSystem.HBASE_MESSAGING_TABLE_PREFIX_NUM_BYTES));
        String sysConfigTablePrefix = HTableNameConverter.getSysConfigTablePrefix(hbaseNamespacePrefix);
        CConfigurationReader cConfReader = new CConfigurationReader(env.getConfiguration(), sysConfigTablePrefix);
        topicMetadataCacheSupplier = new TopicMetadataCacheSupplier(env, cConfReader, hbaseNamespacePrefix, metadataTableNamespace, new DefaultScanBuilder());
        topicMetadataCache = topicMetadataCacheSupplier.get();
    }
}
Also used : TopicMetadataCacheSupplier(co.cask.cdap.messaging.TopicMetadataCacheSupplier) RegionCoprocessorEnvironment(org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment) CConfigurationReader(co.cask.cdap.data2.transaction.queue.hbase.coprocessor.CConfigurationReader) DefaultScanBuilder(co.cask.cdap.data2.util.hbase.DefaultScanBuilder) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor)

Example 12 with CConfigurationReader

use of co.cask.cdap.data2.transaction.queue.hbase.coprocessor.CConfigurationReader in project cdap by caskdata.

the class HBaseQueueRegionObserver method start.

@Override
public void start(CoprocessorEnvironment env) {
    if (env instanceof RegionCoprocessorEnvironment) {
        HTableDescriptor tableDesc = ((RegionCoprocessorEnvironment) env).getRegion().getTableDesc();
        String hTableName = tableDesc.getNameAsString();
        String prefixBytes = tableDesc.getValue(HBaseQueueAdmin.PROPERTY_PREFIX_BYTES);
        try {
            // Default to SALT_BYTES for the older salted queue implementation.
            this.prefixBytes = prefixBytes == null ? SaltedHBaseQueueStrategy.SALT_BYTES : Integer.parseInt(prefixBytes);
        } catch (NumberFormatException e) {
            // Shouldn't happen for table created by cdap.
            LOG.error("Unable to parse value of '" + HBaseQueueAdmin.PROPERTY_PREFIX_BYTES + "' property. " + "Default to " + SaltedHBaseQueueStrategy.SALT_BYTES, e);
            this.prefixBytes = SaltedHBaseQueueStrategy.SALT_BYTES;
        }
        namespaceId = HTableNameConverter.from(tableDesc).getNamespace();
        appName = HBaseQueueAdmin.getApplicationName(hTableName);
        flowName = HBaseQueueAdmin.getFlowName(hTableName);
        Configuration conf = env.getConfiguration();
        String hbaseNamespacePrefix = tableDesc.getValue(Constants.Dataset.TABLE_PREFIX);
        final String sysConfigTablePrefix = HTableNameConverter.getSysConfigTablePrefix(hbaseNamespacePrefix);
        txStateCacheSupplier = new DefaultTransactionStateCacheSupplier(sysConfigTablePrefix, conf);
        txStateCache = txStateCacheSupplier.get();
        txSnapshotSupplier = new Supplier<TransactionVisibilityState>() {

            @Override
            public TransactionVisibilityState get() {
                return txStateCache.getLatestState();
            }
        };
        String queueConfigTableId = HBaseQueueAdmin.getConfigTableName();
        configTableName = HTableNameConverter.toTableName(hbaseNamespacePrefix, TableId.from(namespaceId, queueConfigTableId));
        cConfReader = new CConfigurationReader(conf, sysConfigTablePrefix);
        configCacheSupplier = createConfigCache(env);
        configCache = configCacheSupplier.get();
    }
}
Also used : RegionCoprocessorEnvironment(org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment) CConfiguration(co.cask.cdap.common.conf.CConfiguration) Configuration(org.apache.hadoop.conf.Configuration) CConfigurationReader(co.cask.cdap.data2.transaction.queue.hbase.coprocessor.CConfigurationReader) TransactionVisibilityState(org.apache.tephra.persist.TransactionVisibilityState) DefaultTransactionStateCacheSupplier(co.cask.cdap.data2.transaction.coprocessor.DefaultTransactionStateCacheSupplier) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor)

Example 13 with CConfigurationReader

use of co.cask.cdap.data2.transaction.queue.hbase.coprocessor.CConfigurationReader in project cdap by caskdata.

the class HBaseQueueRegionObserver method start.

@Override
public void start(CoprocessorEnvironment env) {
    if (env instanceof RegionCoprocessorEnvironment) {
        HTableDescriptor tableDesc = ((RegionCoprocessorEnvironment) env).getRegion().getTableDesc();
        String hTableName = tableDesc.getNameAsString();
        String prefixBytes = tableDesc.getValue(HBaseQueueAdmin.PROPERTY_PREFIX_BYTES);
        try {
            // Default to SALT_BYTES for the older salted queue implementation.
            this.prefixBytes = prefixBytes == null ? SaltedHBaseQueueStrategy.SALT_BYTES : Integer.parseInt(prefixBytes);
        } catch (NumberFormatException e) {
            // Shouldn't happen for table created by cdap.
            LOG.error("Unable to parse value of '" + HBaseQueueAdmin.PROPERTY_PREFIX_BYTES + "' property. " + "Default to " + SaltedHBaseQueueStrategy.SALT_BYTES, e);
            this.prefixBytes = SaltedHBaseQueueStrategy.SALT_BYTES;
        }
        namespaceId = HTableNameConverter.from(tableDesc).getNamespace();
        appName = HBaseQueueAdmin.getApplicationName(hTableName);
        flowName = HBaseQueueAdmin.getFlowName(hTableName);
        Configuration conf = env.getConfiguration();
        String hbaseNamespacePrefix = tableDesc.getValue(Constants.Dataset.TABLE_PREFIX);
        final String sysConfigTablePrefix = HTableNameConverter.getSysConfigTablePrefix(hbaseNamespacePrefix);
        txStateCacheSupplier = new DefaultTransactionStateCacheSupplier(sysConfigTablePrefix, conf);
        txStateCache = txStateCacheSupplier.get();
        txSnapshotSupplier = new Supplier<TransactionVisibilityState>() {

            @Override
            public TransactionVisibilityState get() {
                return txStateCache.getLatestState();
            }
        };
        String queueConfigTableId = HBaseQueueAdmin.getConfigTableName();
        configTableName = HTableNameConverter.toTableName(hbaseNamespacePrefix, TableId.from(namespaceId, queueConfigTableId));
        cConfReader = new CConfigurationReader(conf, sysConfigTablePrefix);
        configCacheSupplier = createConfigCache(env);
        configCache = configCacheSupplier.get();
    }
}
Also used : RegionCoprocessorEnvironment(org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment) CConfiguration(co.cask.cdap.common.conf.CConfiguration) Configuration(org.apache.hadoop.conf.Configuration) CConfigurationReader(co.cask.cdap.data2.transaction.queue.hbase.coprocessor.CConfigurationReader) TransactionVisibilityState(org.apache.tephra.persist.TransactionVisibilityState) DefaultTransactionStateCacheSupplier(co.cask.cdap.data2.transaction.coprocessor.DefaultTransactionStateCacheSupplier) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor)

Example 14 with CConfigurationReader

use of co.cask.cdap.data2.transaction.queue.hbase.coprocessor.CConfigurationReader in project cdap by caskdata.

the class PayloadTableRegionObserver method start.

@Override
public void start(CoprocessorEnvironment e) throws IOException {
    if (e instanceof RegionCoprocessorEnvironment) {
        RegionCoprocessorEnvironment env = (RegionCoprocessorEnvironment) e;
        HTableDescriptor tableDesc = env.getRegion().getTableDesc();
        String metadataTableNamespace = tableDesc.getValue(Constants.MessagingSystem.HBASE_METADATA_TABLE_NAMESPACE);
        String hbaseNamespacePrefix = tableDesc.getValue(Constants.Dataset.TABLE_PREFIX);
        prefixLength = Integer.valueOf(tableDesc.getValue(Constants.MessagingSystem.HBASE_MESSAGING_TABLE_PREFIX_NUM_BYTES));
        String sysConfigTablePrefix = HTableNameConverter.getSysConfigTablePrefix(hbaseNamespacePrefix);
        CConfigurationReader cConfReader = new CConfigurationReader(env.getConfiguration(), sysConfigTablePrefix);
        topicMetadataCacheSupplier = new TopicMetadataCacheSupplier(env, cConfReader, hbaseNamespacePrefix, metadataTableNamespace, new DefaultScanBuilder());
        topicMetadataCache = topicMetadataCacheSupplier.get();
    }
}
Also used : TopicMetadataCacheSupplier(co.cask.cdap.messaging.TopicMetadataCacheSupplier) RegionCoprocessorEnvironment(org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment) CConfigurationReader(co.cask.cdap.data2.transaction.queue.hbase.coprocessor.CConfigurationReader) DefaultScanBuilder(co.cask.cdap.data2.util.hbase.DefaultScanBuilder) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor)

Example 15 with CConfigurationReader

use of co.cask.cdap.data2.transaction.queue.hbase.coprocessor.CConfigurationReader in project cdap by caskdata.

the class MessageTableRegionObserver method start.

@Override
public void start(CoprocessorEnvironment e) throws IOException {
    if (e instanceof RegionCoprocessorEnvironment) {
        RegionCoprocessorEnvironment env = (RegionCoprocessorEnvironment) e;
        HTableDescriptor tableDesc = env.getRegion().getTableDesc();
        String metadataTableNamespace = tableDesc.getValue(Constants.MessagingSystem.HBASE_METADATA_TABLE_NAMESPACE);
        String hbaseNamespacePrefix = tableDesc.getValue(Constants.Dataset.TABLE_PREFIX);
        prefixLength = Integer.valueOf(tableDesc.getValue(Constants.MessagingSystem.HBASE_MESSAGING_TABLE_PREFIX_NUM_BYTES));
        String sysConfigTablePrefix = HTableNameConverter.getSysConfigTablePrefix(hbaseNamespacePrefix);
        CConfigurationReader cConfReader = new CConfigurationReader(env.getConfiguration(), sysConfigTablePrefix);
        txStateCacheSupplier = getTransactionStateCacheSupplier(hbaseNamespacePrefix, env.getConfiguration());
        txStateCache = txStateCacheSupplier.get();
        topicMetadataCacheSupplier = new TopicMetadataCacheSupplier(env, cConfReader, hbaseNamespacePrefix, metadataTableNamespace, new HBase11ScanBuilder());
        topicMetadataCache = topicMetadataCacheSupplier.get();
    }
}
Also used : TopicMetadataCacheSupplier(co.cask.cdap.messaging.TopicMetadataCacheSupplier) RegionCoprocessorEnvironment(org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment) HBase11ScanBuilder(co.cask.cdap.data2.util.hbase.HBase11ScanBuilder) CConfigurationReader(co.cask.cdap.data2.transaction.queue.hbase.coprocessor.CConfigurationReader) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor)

Aggregations

CConfigurationReader (co.cask.cdap.data2.transaction.queue.hbase.coprocessor.CConfigurationReader)22 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)22 RegionCoprocessorEnvironment (org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment)21 TopicMetadataCacheSupplier (co.cask.cdap.messaging.TopicMetadataCacheSupplier)14 DefaultScanBuilder (co.cask.cdap.data2.util.hbase.DefaultScanBuilder)11 CConfiguration (co.cask.cdap.common.conf.CConfiguration)7 DefaultTransactionStateCacheSupplier (co.cask.cdap.data2.transaction.coprocessor.DefaultTransactionStateCacheSupplier)7 Configuration (org.apache.hadoop.conf.Configuration)7 TransactionVisibilityState (org.apache.tephra.persist.TransactionVisibilityState)7 TableNameAwareCacheSupplier (co.cask.cdap.data2.transaction.queue.hbase.coprocessor.TableNameAwareCacheSupplier)1 TableId (co.cask.cdap.data2.util.TableId)1 HBase10ScanBuilder (co.cask.cdap.data2.util.hbase.HBase10ScanBuilder)1 HBase11ScanBuilder (co.cask.cdap.data2.util.hbase.HBase11ScanBuilder)1 HBase12CDH570ScanBuilder (co.cask.cdap.data2.util.hbase.HBase12CDH570ScanBuilder)1 NamespaceId (co.cask.cdap.proto.id.NamespaceId)1 Supplier (com.google.common.base.Supplier)1 InputSupplier (com.google.common.io.InputSupplier)1 IOException (java.io.IOException)1 TableName (org.apache.hadoop.hbase.TableName)1 HTable (org.apache.hadoop.hbase.client.HTable)1