Search in sources :

Example 6 with TableNotDisabledException

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

the class TestRestoreSnapshotProcedure method testRestoreSnapshotToEnabledTable.

@Test(timeout = 60000)
public void testRestoreSnapshotToEnabledTable() throws Exception {
    final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
    try {
        UTIL.getAdmin().enableTable(snapshotTableName);
        long procId = ProcedureTestingUtility.submitAndWait(procExec, new RestoreSnapshotProcedure(procExec.getEnvironment(), snapshotHTD, snapshot));
        ProcedureInfo result = procExec.getResult(procId);
        assertTrue(result.isFailed());
        LOG.debug("Restore snapshot failed with exception: " + result.getExceptionFullMessage());
        assertTrue(ProcedureTestingUtility.getExceptionCause(result) instanceof TableNotDisabledException);
    } finally {
        UTIL.getAdmin().disableTable(snapshotTableName);
    }
}
Also used : TableNotDisabledException(org.apache.hadoop.hbase.TableNotDisabledException) ProcedureInfo(org.apache.hadoop.hbase.ProcedureInfo) Test(org.junit.Test)

Example 7 with TableNotDisabledException

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

the class TestTruncateTableProcedure method testTruncateNotDisabledTable.

@Test(timeout = 60000)
public void testTruncateNotDisabledTable() throws Exception {
    final TableName tableName = TableName.valueOf(name.getMethodName());
    final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
    MasterProcedureTestingUtility.createTable(procExec, tableName, null, "f");
    long procId = ProcedureTestingUtility.submitAndWait(procExec, new TruncateTableProcedure(procExec.getEnvironment(), tableName, false));
    // Second delete should fail with TableNotDisabled
    ProcedureInfo result = procExec.getResult(procId);
    assertTrue(result.isFailed());
    LOG.debug("Truncate failed with exception: " + result.getExceptionFullMessage());
    assertTrue(ProcedureTestingUtility.getExceptionCause(result) instanceof TableNotDisabledException);
}
Also used : TableNotDisabledException(org.apache.hadoop.hbase.TableNotDisabledException) TableName(org.apache.hadoop.hbase.TableName) ProcedureInfo(org.apache.hadoop.hbase.ProcedureInfo) Test(org.junit.Test)

Example 8 with TableNotDisabledException

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

the class TestAdmin1 method testEnableDisableAddColumnDeleteColumn.

@Test(timeout = 300000)
public void testEnableDisableAddColumnDeleteColumn() throws Exception {
    final TableName tableName = TableName.valueOf(name.getMethodName());
    TEST_UTIL.createTable(tableName, HConstants.CATALOG_FAMILY).close();
    while (!this.admin.isTableEnabled(TableName.valueOf(name.getMethodName()))) {
        Thread.sleep(10);
    }
    this.admin.disableTable(tableName);
    try {
        TEST_UTIL.getConnection().getTable(tableName);
    } catch (org.apache.hadoop.hbase.DoNotRetryIOException e) {
    //expected
    }
    this.admin.addColumnFamily(tableName, new HColumnDescriptor("col2"));
    this.admin.enableTable(tableName);
    try {
        this.admin.deleteColumnFamily(tableName, Bytes.toBytes("col2"));
    } catch (TableNotDisabledException e) {
        LOG.info(e);
    }
    this.admin.disableTable(tableName);
    this.admin.deleteTable(tableName);
}
Also used : TableNotDisabledException(org.apache.hadoop.hbase.TableNotDisabledException) TableName(org.apache.hadoop.hbase.TableName) HColumnDescriptor(org.apache.hadoop.hbase.HColumnDescriptor) Test(org.junit.Test)

Example 9 with TableNotDisabledException

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

the class HBaseAdmin1_0 method clearTable.

@Override
public void clearTable(String tableString, long timestamp) throws IOException {
    TableName tableName = TableName.valueOf(tableString);
    if (!adm.tableExists(tableName)) {
        log.debug("Attempted to clear table {} before it exists (noop)", tableString);
        return;
    }
    if (!adm.isTableDisabled(tableName))
        adm.disableTable(tableName);
    if (!adm.isTableDisabled(tableName))
        throw new RuntimeException("Unable to disable table " + tableName);
    // This API call appears to both truncate and reenable the table.
    log.info("Truncating table {}", tableName);
    adm.truncateTable(tableName, true);
    try {
        adm.enableTable(tableName);
    } catch (TableNotDisabledException e) {
        // This triggers seemingly every time in testing with 1.0.2.
        log.debug("Table automatically reenabled by truncation: {}", tableName, e);
    }
}
Also used : TableNotDisabledException(org.apache.hadoop.hbase.TableNotDisabledException) TableName(org.apache.hadoop.hbase.TableName)

Example 10 with TableNotDisabledException

use of org.apache.hadoop.hbase.TableNotDisabledException in project cdap by caskdata.

the class HBaseTableFactory method enableTable.

private void enableTable(HBaseDDLExecutor ddlExecutor, TableId tableId) throws IOException {
    try {
        TableName tableName = HTableNameConverter.toTableName(cConf.get(Constants.Dataset.TABLE_PREFIX), tableId);
        ddlExecutor.enableTableIfDisabled(tableName.getNamespaceAsString(), tableName.getQualifierAsString());
        LOG.debug("TMS Table {} has been enabled.", tableName);
    } catch (TableNotFoundException ex) {
        LOG.debug("TMS Table {} was not found. Skipping enable.", tableId, ex);
    } catch (TableNotDisabledException ex) {
        LOG.debug("TMS Table {} was already in enabled state.", tableId, ex);
    }
}
Also used : TableNotDisabledException(org.apache.hadoop.hbase.TableNotDisabledException) TableName(org.apache.hadoop.hbase.TableName) TableNotFoundException(org.apache.hadoop.hbase.TableNotFoundException)

Aggregations

TableNotDisabledException (org.apache.hadoop.hbase.TableNotDisabledException)10 TableName (org.apache.hadoop.hbase.TableName)8 Test (org.junit.Test)5 ProcedureInfo (org.apache.hadoop.hbase.ProcedureInfo)3 HColumnDescriptor (org.apache.hadoop.hbase.HColumnDescriptor)2 TableNotFoundException (org.apache.hadoop.hbase.TableNotFoundException)2 IOException (java.io.IOException)1 InterruptedIOException (java.io.InterruptedIOException)1 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)1 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)1 TableState (org.apache.hadoop.hbase.client.TableState)1 TimeoutIOException (org.apache.hadoop.hbase.exceptions.TimeoutIOException)1 TableStateManager (org.apache.hadoop.hbase.master.TableStateManager)1 EnableTableState (org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.EnableTableState)1 RestoreSnapshotException (org.apache.hadoop.hbase.snapshot.RestoreSnapshotException)1