Search in sources :

Example 1 with ConsumerConfigCache

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

the class HBaseQueueTest method verifyConsumerConfigIsDeleted.

@Override
protected void verifyConsumerConfigIsDeleted(QueueName... queueNames) throws Exception {
    for (QueueName queueName : queueNames) {
        // Either the config table doesn't exists, or the consumer config is empty for the given queue
        try {
            ConsumerConfigCache cache = getConsumerConfigCache(queueName);
            cache.updateCache();
            Assert.assertNull("for " + queueName, cache.getConsumerConfig(queueName.toBytes()));
        } catch (TableNotFoundException e) {
        // Expected.
        }
    }
}
Also used : TableNotFoundException(org.apache.hadoop.hbase.TableNotFoundException) ConsumerConfigCache(co.cask.cdap.data2.transaction.queue.hbase.coprocessor.ConsumerConfigCache) QueueName(co.cask.cdap.common.queue.QueueName)

Example 2 with ConsumerConfigCache

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

the class HBaseQueueTest method getConsumerConfigCache.

private ConsumerConfigCache getConsumerConfigCache(QueueName queueName) throws Exception {
    String tableName = HBaseQueueAdmin.getConfigTableName();
    TableId hTableId = tableUtil.createHTableId(new NamespaceId(queueName.getFirstComponent()), tableName);
    try (HTable hTable = tableUtil.createHTable(hConf, hTableId)) {
        HTableDescriptor htd = hTable.getTableDescriptor();
        final TableName configTableName = htd.getTableName();
        String prefix = htd.getValue(Constants.Dataset.TABLE_PREFIX);
        CConfigurationReader cConfReader = new CConfigurationReader(hConf, HTableNameConverter.getSysConfigTablePrefix(prefix));
        return TableNameAwareCacheSupplier.getSupplier(configTableName, cConfReader, new Supplier<TransactionVisibilityState>() {

            @Override
            public TransactionVisibilityState get() {
                try {
                    return getTransactionManager().getSnapshot();
                } catch (IOException e) {
                    throw Throwables.propagate(e);
                }
            }
        }, new InputSupplier<HTableInterface>() {

            @Override
            public HTableInterface getInput() throws IOException {
                return new HTable(hConf, configTableName);
            }
        }).get();
    }
}
Also used : TableId(co.cask.cdap.data2.util.TableId) TableName(org.apache.hadoop.hbase.TableName) CConfigurationReader(co.cask.cdap.data2.transaction.queue.hbase.coprocessor.CConfigurationReader) InputSupplier(com.google.common.io.InputSupplier) Supplier(com.google.common.base.Supplier) TableNameAwareCacheSupplier(co.cask.cdap.data2.transaction.queue.hbase.coprocessor.TableNameAwareCacheSupplier) NamespaceId(co.cask.cdap.proto.id.NamespaceId) IOException(java.io.IOException) HTable(org.apache.hadoop.hbase.client.HTable) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor) InputSupplier(com.google.common.io.InputSupplier)

Example 3 with ConsumerConfigCache

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

the class HBaseQueueTest method verifyConsumerConfigExists.

@Override
protected void verifyConsumerConfigExists(QueueName... queueNames) throws Exception {
    for (QueueName queueName : queueNames) {
        ConsumerConfigCache cache = getConsumerConfigCache(queueName);
        cache.updateCache();
        Assert.assertNotNull("for " + queueName, cache.getConsumerConfig(queueName.toBytes()));
    }
}
Also used : ConsumerConfigCache(co.cask.cdap.data2.transaction.queue.hbase.coprocessor.ConsumerConfigCache) QueueName(co.cask.cdap.common.queue.QueueName)

Aggregations

QueueName (co.cask.cdap.common.queue.QueueName)2 ConsumerConfigCache (co.cask.cdap.data2.transaction.queue.hbase.coprocessor.ConsumerConfigCache)2 CConfigurationReader (co.cask.cdap.data2.transaction.queue.hbase.coprocessor.CConfigurationReader)1 TableNameAwareCacheSupplier (co.cask.cdap.data2.transaction.queue.hbase.coprocessor.TableNameAwareCacheSupplier)1 TableId (co.cask.cdap.data2.util.TableId)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 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)1 TableName (org.apache.hadoop.hbase.TableName)1 TableNotFoundException (org.apache.hadoop.hbase.TableNotFoundException)1 HTable (org.apache.hadoop.hbase.client.HTable)1