Search in sources :

Example 1 with DefaultTransactionStateCacheSupplier

use of co.cask.cdap.data2.transaction.coprocessor.DefaultTransactionStateCacheSupplier 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 2 with DefaultTransactionStateCacheSupplier

use of co.cask.cdap.data2.transaction.coprocessor.DefaultTransactionStateCacheSupplier 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 3 with DefaultTransactionStateCacheSupplier

use of co.cask.cdap.data2.transaction.coprocessor.DefaultTransactionStateCacheSupplier 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 4 with DefaultTransactionStateCacheSupplier

use of co.cask.cdap.data2.transaction.coprocessor.DefaultTransactionStateCacheSupplier 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 5 with DefaultTransactionStateCacheSupplier

use of co.cask.cdap.data2.transaction.coprocessor.DefaultTransactionStateCacheSupplier 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)

Aggregations

CConfiguration (co.cask.cdap.common.conf.CConfiguration)7 DefaultTransactionStateCacheSupplier (co.cask.cdap.data2.transaction.coprocessor.DefaultTransactionStateCacheSupplier)7 CConfigurationReader (co.cask.cdap.data2.transaction.queue.hbase.coprocessor.CConfigurationReader)7 Configuration (org.apache.hadoop.conf.Configuration)7 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)7 RegionCoprocessorEnvironment (org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment)7 TransactionVisibilityState (org.apache.tephra.persist.TransactionVisibilityState)7