use of co.cask.cdap.proto.NamespaceConfig 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);
}
}
use of co.cask.cdap.proto.NamespaceConfig in project cdap by caskdata.
the class RemoteNamespaceQueryTest method testCustomNS.
@Test
public void testCustomNS() throws Exception {
String cdapNamespace = "NS1";
String hbaseNamespace = "custHBase";
String rootDirectory = "/directory";
String hiveDb = "myHive";
String schedulerQueue = "schQ";
String description = "Namespace with custom HBase mapping";
NamespaceConfig namespaceConfig = new NamespaceConfig(schedulerQueue, rootDirectory, hbaseNamespace, hiveDb, null, null, null);
NamespaceMeta meta = new NamespaceMeta.Builder().setName(cdapNamespace).setDescription(description).setSchedulerQueueName(schedulerQueue).setRootDirectory(rootDirectory).setHBaseNamespace(hbaseNamespace).setHiveDatabase(hiveDb).build();
// create the ns location since admin expect it to exists
Location nsLocation = namespacedLocationFactory.get(meta);
nsLocation.mkdirs();
namespaceAdmin.create(meta);
NamespaceId namespaceId = new NamespaceId(cdapNamespace);
Assert.assertTrue(queryClient.exists(namespaceId));
NamespaceMeta resultMeta = queryClient.get(namespaceId);
Assert.assertEquals(namespaceConfig, resultMeta.getConfig());
namespaceAdmin.delete(namespaceId);
Assert.assertTrue(!queryClient.exists(namespaceId));
}
Aggregations