Search in sources :

Example 11 with TableNotEnabledException

use of org.apache.hadoop.hbase.TableNotEnabledException in project hbase by apache.

the class TestCoprocessorWhitelistMasterObserver method tearDownTestCoprocessorWhitelistMasterObserver.

@After
public void tearDownTestCoprocessorWhitelistMasterObserver() throws Exception {
    Admin admin = UTIL.getAdmin();
    try {
        try {
            admin.disableTable(TEST_TABLE);
        } catch (TableNotEnabledException ex) {
            // Table was left disabled by test
            LOG.info("Table was left disabled by test");
        }
        admin.deleteTable(TEST_TABLE);
    } catch (TableNotFoundException ex) {
        // Table was not created for some reason?
        LOG.info("Table was not created for some reason");
    }
    UTIL.shutdownMiniCluster();
}
Also used : TableNotFoundException(org.apache.hadoop.hbase.TableNotFoundException) Admin(org.apache.hadoop.hbase.client.Admin) TableNotEnabledException(org.apache.hadoop.hbase.TableNotEnabledException) After(org.junit.After)

Example 12 with TableNotEnabledException

use of org.apache.hadoop.hbase.TableNotEnabledException in project hbase by apache.

the class SecureTestUtil method deleteTable.

public static void deleteTable(HBaseTestingUtility testUtil, Admin admin, TableName tableName) throws Exception {
    // NOTE: We need a latch because admin is not sync,
    // so the postOp coprocessor method may be called after the admin operation returned.
    MasterSyncObserver observer = (MasterSyncObserver) testUtil.getHBaseCluster().getMaster().getMasterCoprocessorHost().findCoprocessor(MasterSyncObserver.class.getName());
    observer.tableDeletionLatch = new CountDownLatch(1);
    try {
        admin.disableTable(tableName);
    } catch (TableNotEnabledException e) {
        LOG.debug("Table: " + tableName + " already disabled, so just deleting it.");
    }
    admin.deleteTable(tableName);
    observer.tableDeletionLatch.await();
    observer.tableDeletionLatch = null;
}
Also used : CountDownLatch(java.util.concurrent.CountDownLatch) TableNotEnabledException(org.apache.hadoop.hbase.TableNotEnabledException)

Example 13 with TableNotEnabledException

use of org.apache.hadoop.hbase.TableNotEnabledException in project hbase by apache.

the class SchemaResource method delete.

@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "DE_MIGHT_IGNORE", justification = "Expected")
@DELETE
public Response delete(@Context final UriInfo uriInfo) {
    if (LOG.isTraceEnabled()) {
        LOG.trace("DELETE " + uriInfo.getAbsolutePath());
    }
    servlet.getMetrics().incrementRequests(1);
    if (servlet.isReadOnly()) {
        return Response.status(Response.Status.FORBIDDEN).type(MIMETYPE_TEXT).entity("Forbidden" + CRLF).build();
    }
    try {
        Admin admin = servlet.getAdmin();
        try {
            admin.disableTable(TableName.valueOf(tableResource.getName()));
        } catch (TableNotEnabledException e) {
        /* this is what we want anyway */
        }
        admin.deleteTable(TableName.valueOf(tableResource.getName()));
        servlet.getMetrics().incrementSucessfulDeleteRequests(1);
        return Response.ok().build();
    } catch (Exception e) {
        servlet.getMetrics().incrementFailedDeleteRequests(1);
        return processException(e);
    }
}
Also used : Admin(org.apache.hadoop.hbase.client.Admin) TableNotFoundException(org.apache.hadoop.hbase.TableNotFoundException) TableNotEnabledException(org.apache.hadoop.hbase.TableNotEnabledException) TableExistsException(org.apache.hadoop.hbase.TableExistsException) IOException(java.io.IOException) TableNotEnabledException(org.apache.hadoop.hbase.TableNotEnabledException) DELETE(javax.ws.rs.DELETE)

Example 14 with TableNotEnabledException

use of org.apache.hadoop.hbase.TableNotEnabledException in project titan by thinkaurelius.

the class HBaseStoreManager method ensureColumnFamilyExists.

private void ensureColumnFamilyExists(String tableName, String columnFamily, int ttlInSeconds) throws BackendException {
    AdminMask adm = null;
    try {
        adm = getAdminInterface();
        HTableDescriptor desc = ensureTableExists(tableName, columnFamily, ttlInSeconds);
        Preconditions.checkNotNull(desc);
        HColumnDescriptor cf = desc.getFamily(columnFamily.getBytes());
        // Create our column family, if necessary
        if (cf == null) {
            try {
                if (!adm.isTableDisabled(tableName)) {
                    adm.disableTable(tableName);
                }
            } catch (TableNotEnabledException e) {
                logger.debug("Table {} already disabled", tableName);
            } catch (IOException e) {
                throw new TemporaryBackendException(e);
            }
            try {
                HColumnDescriptor cdesc = new HColumnDescriptor(columnFamily);
                setCFOptions(cdesc, ttlInSeconds);
                adm.addColumn(tableName, cdesc);
                try {
                    logger.debug("Added HBase ColumnFamily {}, waiting for 1 sec. to propogate.", columnFamily);
                    Thread.sleep(1000L);
                } catch (InterruptedException ie) {
                    throw new TemporaryBackendException(ie);
                }
                adm.enableTable(tableName);
            } catch (TableNotFoundException ee) {
                logger.error("TableNotFoundException", ee);
                throw new PermanentBackendException(ee);
            } catch (org.apache.hadoop.hbase.TableExistsException ee) {
                logger.debug("Swallowing exception {}", ee);
            } catch (IOException ee) {
                throw new TemporaryBackendException(ee);
            }
        }
    } finally {
        IOUtils.closeQuietly(adm);
    }
}
Also used : TableNotFoundException(org.apache.hadoop.hbase.TableNotFoundException) TemporaryBackendException(com.thinkaurelius.titan.diskstorage.TemporaryBackendException) HColumnDescriptor(org.apache.hadoop.hbase.HColumnDescriptor) PermanentBackendException(com.thinkaurelius.titan.diskstorage.PermanentBackendException) IOException(java.io.IOException) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor) TableNotEnabledException(org.apache.hadoop.hbase.TableNotEnabledException)

Aggregations

TableNotEnabledException (org.apache.hadoop.hbase.TableNotEnabledException)14 TableNotFoundException (org.apache.hadoop.hbase.TableNotFoundException)8 IOException (java.io.IOException)6 TableName (org.apache.hadoop.hbase.TableName)6 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)4 HColumnDescriptor (org.apache.hadoop.hbase.HColumnDescriptor)3 Admin (org.apache.hadoop.hbase.client.Admin)3 Test (org.junit.Test)3 PermanentBackendException (com.thinkaurelius.titan.diskstorage.PermanentBackendException)2 TemporaryBackendException (com.thinkaurelius.titan.diskstorage.TemporaryBackendException)2 ProjectInfo (co.cask.cdap.common.utils.ProjectInfo)1 HBaseTableUtil (co.cask.cdap.data2.util.hbase.HBaseTableUtil)1 HTableDescriptorBuilder (co.cask.cdap.data2.util.hbase.HTableDescriptorBuilder)1 HBaseDDLExecutor (co.cask.cdap.spi.hbase.HBaseDDLExecutor)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 DELETE (javax.ws.rs.DELETE)1 Cell (org.apache.hadoop.hbase.Cell)1 ProcedureInfo (org.apache.hadoop.hbase.ProcedureInfo)1 TableExistsException (org.apache.hadoop.hbase.TableExistsException)1 UnknownScannerException (org.apache.hadoop.hbase.UnknownScannerException)1