Search in sources :

Example 16 with HBaseDDLExecutor

use of co.cask.cdap.spi.hbase.HBaseDDLExecutor in project cdap by caskdata.

the class MetricHBaseTableUtilTest method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception {
    cConf = CConfiguration.create();
    hBaseTableUtil = new HBaseTableUtilFactory(cConf, new SimpleNamespaceQueryAdmin()).get();
    HBaseDDLExecutor executor = new HBaseDDLExecutorFactory(cConf, TEST_HBASE.getHBaseAdmin().getConfiguration()).get();
    executor.createNamespaceIfNotExists(hBaseTableUtil.getHBaseNamespace(NamespaceId.SYSTEM));
}
Also used : HBaseDDLExecutor(co.cask.cdap.spi.hbase.HBaseDDLExecutor) SimpleNamespaceQueryAdmin(co.cask.cdap.common.namespace.SimpleNamespaceQueryAdmin) HBaseDDLExecutorFactory(co.cask.cdap.data2.util.hbase.HBaseDDLExecutorFactory) HBaseTableUtilFactory(co.cask.cdap.data2.util.hbase.HBaseTableUtilFactory) BeforeClass(org.junit.BeforeClass)

Example 17 with HBaseDDLExecutor

use of co.cask.cdap.spi.hbase.HBaseDDLExecutor in project cdap by caskdata.

the class DistributedStorageProviderNamespaceAdmin method delete.

@SuppressWarnings("ConstantConditions")
@Override
public void delete(NamespaceId namespaceId) throws IOException, ExploreException, SQLException {
    // delete namespace directory from filesystem
    super.delete(namespaceId);
    if (NamespaceId.DEFAULT.equals(namespaceId)) {
        return;
    }
    // delete HBase namespace
    NamespaceConfig namespaceConfig;
    try {
        namespaceConfig = namespaceQueryAdmin.get(namespaceId).getConfig();
    } catch (Exception ex) {
        throw new IOException("Could not fetch custom HBase mapping.", ex);
    }
    if (!Strings.isNullOrEmpty(namespaceConfig.getHbaseNamespace())) {
        // custom namespace mapping is set for HBase, hence don't do anything during delete since the lifecycle of the
        // namespace will be managed by the user
        LOG.debug("Custom HBase mapping {} was found while deleting {}. Hence skipping deletion of HBase namespace", namespaceConfig.getHbaseNamespace(), namespaceId);
        return;
    }
    // delete HBase namespace
    String namespace = tableUtil.getHBaseNamespace(namespaceId);
    try (HBaseDDLExecutor executor = hBaseDDLExecutorFactory.get()) {
        executor.deleteNamespaceIfExists(namespace);
    }
}
Also used : NamespaceConfig(co.cask.cdap.proto.NamespaceConfig) HBaseDDLExecutor(co.cask.cdap.spi.hbase.HBaseDDLExecutor) IOException(java.io.IOException) IOException(java.io.IOException) SQLException(java.sql.SQLException) ExploreException(co.cask.cdap.explore.service.ExploreException)

Aggregations

HBaseDDLExecutor (co.cask.cdap.spi.hbase.HBaseDDLExecutor)17 TableId (co.cask.cdap.data2.util.TableId)8 HBaseAdmin (org.apache.hadoop.hbase.client.HBaseAdmin)7 IOException (java.io.IOException)6 ColumnFamilyDescriptorBuilder (co.cask.cdap.data2.util.hbase.ColumnFamilyDescriptorBuilder)5 HTableDescriptorBuilder (co.cask.cdap.data2.util.hbase.HTableDescriptorBuilder)5 TableDescriptorBuilder (co.cask.cdap.data2.util.hbase.TableDescriptorBuilder)5 HTable (org.apache.hadoop.hbase.client.HTable)5 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)4 NamespaceId (co.cask.cdap.proto.id.NamespaceId)3 Map (java.util.Map)3 ProjectInfo (co.cask.cdap.common.utils.ProjectInfo)2 ExploreException (co.cask.cdap.explore.service.ExploreException)2 RowKeyDistributorByHashPrefix (co.cask.cdap.hbase.wd.RowKeyDistributorByHashPrefix)2 SQLException (java.sql.SQLException)2 HashMap (java.util.HashMap)2 ExecutionException (java.util.concurrent.ExecutionException)2 Future (java.util.concurrent.Future)2 SimpleNamespaceQueryAdmin (co.cask.cdap.common.namespace.SimpleNamespaceQueryAdmin)1 QueueConstants (co.cask.cdap.data2.transaction.queue.QueueConstants)1