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));
}
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);
}
}
Aggregations