Search in sources :

Example 6 with NamespaceConfig

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

Example 7 with NamespaceConfig

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));
}
Also used : NamespaceConfig(co.cask.cdap.proto.NamespaceConfig) NamespaceMeta(co.cask.cdap.proto.NamespaceMeta) NamespaceId(co.cask.cdap.proto.id.NamespaceId) Location(org.apache.twill.filesystem.Location) Test(org.junit.Test)

Aggregations

NamespaceConfig (co.cask.cdap.proto.NamespaceConfig)7 NamespaceMeta (co.cask.cdap.proto.NamespaceMeta)4 IOException (java.io.IOException)3 NamespaceNotFoundException (co.cask.cdap.common.NamespaceNotFoundException)2 Nullable (javax.annotation.Nullable)2 Test (org.junit.Test)2 AppForUnrecoverableResetTest (co.cask.cdap.AppForUnrecoverableResetTest)1 BadRequestException (co.cask.cdap.common.BadRequestException)1 FeatureDisabledException (co.cask.cdap.common.FeatureDisabledException)1 ExploreException (co.cask.cdap.explore.service.ExploreException)1 KerberosPrincipalId (co.cask.cdap.proto.id.KerberosPrincipalId)1 NamespaceId (co.cask.cdap.proto.id.NamespaceId)1 HBaseDDLExecutor (co.cask.cdap.spi.hbase.HBaseDDLExecutor)1 CacheBuilder (com.google.common.cache.CacheBuilder)1 JsonObject (com.google.gson.JsonObject)1 File (java.io.File)1 URI (java.net.URI)1 SQLException (java.sql.SQLException)1 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)1 KerberosName (org.apache.hadoop.security.authentication.util.KerberosName)1