Search in sources :

Example 91 with TableId

use of io.cdap.cdap.data2.util.TableId in project cdap by caskdata.

the class HBaseStreamConsumerStateStoreFactory method dropAllInNamespace.

@Override
public synchronized void dropAllInNamespace(NamespaceId namespace) throws IOException {
    try (HBaseDDLExecutor executor = ddlExecutorFactory.get();
        HBaseAdmin admin = new HBaseAdmin(hConf)) {
        TableId tableId = StreamUtils.getStateStoreTableId(namespace);
        TableId hbaseTableId = tableUtil.createHTableId(new NamespaceId(tableId.getNamespace()), tableId.getTableName());
        if (tableUtil.tableExists(admin, hbaseTableId)) {
            tableUtil.dropTable(executor, hbaseTableId);
        }
    }
}
Also used : HBaseDDLExecutor(co.cask.cdap.spi.hbase.HBaseDDLExecutor) TableId(co.cask.cdap.data2.util.TableId) HBaseAdmin(org.apache.hadoop.hbase.client.HBaseAdmin) NamespaceId(co.cask.cdap.proto.id.NamespaceId)

Example 92 with TableId

use of io.cdap.cdap.data2.util.TableId in project cdap by caskdata.

the class HBaseQueueAdmin method create.

@Override
public void create(QueueName queueName, Properties properties) throws IOException {
    // Queue Config needs to be on separate table, otherwise disabling the queue table would makes queue config
    // not accessible by the queue region coprocessor for doing eviction.
    // Create the config table first so that in case the queue table coprocessor runs, it can access the config table.
    createStateStoreDataset(queueName.getFirstComponent());
    TableId tableId = getDataTableId(queueName);
    try (QueueDatasetAdmin dsAdmin = new QueueDatasetAdmin(tableId, hConf, cConf, tableUtil, properties)) {
        dsAdmin.create();
    }
}
Also used : TableId(co.cask.cdap.data2.util.TableId)

Example 93 with TableId

use of io.cdap.cdap.data2.util.TableId in project cdap by caskdata.

the class HBaseQueueAdmin method dropAllInNamespace.

@Override
public void dropAllInNamespace(NamespaceId namespaceId) throws Exception {
    Set<QueueConstants.QueueType> queueTypes = EnumSet.of(QueueConstants.QueueType.QUEUE, QueueConstants.QueueType.SHARDED_QUEUE);
    try (HBaseDDLExecutor ddlExecutor = ddlExecutorFactory.get()) {
        for (QueueConstants.QueueType queueType : queueTypes) {
            // Note: The trailing "." is crucial, since otherwise nsId could match nsId1, nsIdx etc
            // It's important to keep config table enabled while disabling and dropping  queue tables.
            final String queueTableNamePrefix = String.format("%s.%s.", NamespaceId.SYSTEM.getNamespace(), queueType);
            final String hbaseNamespace = tableUtil.getHBaseNamespace(namespaceId);
            final TableId configTableId = TableId.from(hbaseNamespace, getConfigTableName());
            tableUtil.deleteAllInNamespace(ddlExecutor, hbaseNamespace, hConf, new Predicate<TableId>() {

                @Override
                public boolean apply(TableId tableId) {
                    // It's a bit hacky here since we know how the Dataset System names tables
                    return (tableId.getTableName().startsWith(queueTableNamePrefix)) && !tableId.equals(configTableId);
                }
            });
        }
    }
    // Delete the state store in the namespace
    DatasetId id = getStateStoreId(namespaceId.getEntityName());
    if (datasetFramework.hasInstance(id)) {
        datasetFramework.deleteInstance(id);
    }
}
Also used : HBaseDDLExecutor(co.cask.cdap.spi.hbase.HBaseDDLExecutor) TableId(co.cask.cdap.data2.util.TableId) QueueConstants(co.cask.cdap.data2.transaction.queue.QueueConstants) DatasetId(co.cask.cdap.proto.id.DatasetId)

Example 94 with TableId

use of io.cdap.cdap.data2.util.TableId in project cdap by caskdata.

the class InMemoryStreamConsumerStateStoreFactory method create.

@Override
public synchronized StreamConsumerStateStore create(StreamConfig streamConfig) throws IOException {
    NamespaceId namespace = streamConfig.getStreamId().getParent();
    TableId tableId = StreamUtils.getStateStoreTableId(namespace);
    InMemoryTableAdmin admin = new InMemoryTableAdmin(DatasetContext.from(tableId.getNamespace()), tableId.getTableName(), cConf);
    if (!admin.exists()) {
        admin.create();
    }
    InMemoryTable table = new NoTxInMemoryTable(DatasetContext.from(tableId.getNamespace()), tableId.getTableName(), cConf);
    return new InMemoryStreamConsumerStateStore(streamConfig, table);
}
Also used : TableId(co.cask.cdap.data2.util.TableId) InMemoryTable(co.cask.cdap.data2.dataset2.lib.table.inmemory.InMemoryTable) NoTxInMemoryTable(co.cask.cdap.data2.dataset2.lib.table.inmemory.NoTxInMemoryTable) InMemoryTableAdmin(co.cask.cdap.data2.dataset2.lib.table.inmemory.InMemoryTableAdmin) NamespaceId(co.cask.cdap.proto.id.NamespaceId) NoTxInMemoryTable(co.cask.cdap.data2.dataset2.lib.table.inmemory.NoTxInMemoryTable)

Example 95 with TableId

use of io.cdap.cdap.data2.util.TableId in project cdap by caskdata.

the class InMemoryStreamConsumerStateStoreFactory method dropAllInNamespace.

@Override
public synchronized void dropAllInNamespace(NamespaceId namespace) throws IOException {
    TableId tableId = StreamUtils.getStateStoreTableId(namespace);
    InMemoryTableAdmin admin = new InMemoryTableAdmin(DatasetContext.from(tableId.getNamespace()), tableId.getTableName(), cConf);
    admin.drop();
}
Also used : TableId(co.cask.cdap.data2.util.TableId) InMemoryTableAdmin(co.cask.cdap.data2.dataset2.lib.table.inmemory.InMemoryTableAdmin)

Aggregations

TableId (co.cask.cdap.data2.util.TableId)102 Test (org.junit.Test)95 TableId (io.cdap.cdap.data2.util.TableId)78 HRegion (org.apache.hadoop.hbase.regionserver.HRegion)60 Put (org.apache.hadoop.hbase.client.Put)57 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)55 Cell (org.apache.hadoop.hbase.Cell)42 Scan (org.apache.hadoop.hbase.client.Scan)40 RegionScanner (org.apache.hadoop.hbase.regionserver.RegionScanner)32 NamespaceId (co.cask.cdap.proto.id.NamespaceId)26 NamespaceId (io.cdap.cdap.proto.id.NamespaceId)19 IOException (java.io.IOException)17 HTableDescriptorBuilder (io.cdap.cdap.data2.util.hbase.HTableDescriptorBuilder)16 Result (org.apache.hadoop.hbase.client.Result)16 Delete (org.apache.hadoop.hbase.client.Delete)15 Get (org.apache.hadoop.hbase.client.Get)14 HBaseAdmin (org.apache.hadoop.hbase.client.HBaseAdmin)14 HBaseTableUtil (io.cdap.cdap.data2.util.hbase.HBaseTableUtil)12 TableName (org.apache.hadoop.hbase.TableName)12 HTable (org.apache.hadoop.hbase.client.HTable)12