Java 类org.apache.hadoop.hbase.TableNotEnabledException 实例源码

项目:ditb    文件:SecureTestUtil.java   
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;
}
项目:ditb    文件:SnapshotTestingUtils.java   
/**
 * Take a snapshot of the specified table and verify the given families.
 * Note that this will leave the table disabled in the case of an offline snapshot.
 */
public static void createSnapshotAndValidate(Admin admin,
    TableName tableName, List<byte[]> nonEmptyFamilyNames, List<byte[]> emptyFamilyNames,
    String snapshotNameString, Path rootDir, FileSystem fs, boolean onlineSnapshot)
      throws Exception {
  if (!onlineSnapshot) {
    try {
      admin.disableTable(tableName);
    } catch (TableNotEnabledException tne) {
      LOG.info("In attempting to disable " + tableName + " it turns out that the this table is " +
          "already disabled.");
    }
  }
  admin.snapshot(snapshotNameString, tableName);

  List<SnapshotDescription> snapshots = SnapshotTestingUtils.assertExistsMatchingSnapshot(admin,
    snapshotNameString, tableName);
  if (snapshots == null || snapshots.size() != 1) {
    Assert.fail("Incorrect number of snapshots for table " + tableName);
  }

  SnapshotTestingUtils.confirmSnapshotValid(snapshots.get(0), tableName, nonEmptyFamilyNames,
    emptyFamilyNames, rootDir, admin, fs);
}
项目:LCIndex-HBase-0.94.16    文件:SnapshotTestingUtils.java   
/**
 * Take a snapshot of the specified table and verify the given families.
 * Note that this will leave the table disabled in the case of an offline snapshot.
 */
public static void createSnapshotAndValidate(HBaseAdmin admin,
    String tableName, List<byte[]> nonEmptyFamilyNames, List<byte[]> emptyFamilyNames,
    String snapshotNameString, Path rootDir, FileSystem fs, boolean onlineSnapshot)
      throws Exception {
  if (!onlineSnapshot) {
    try {
      admin.disableTable(tableName);
    } catch (TableNotEnabledException tne) {
      LOG.info("In attempting to disable " + tableName + " it turns out that the this table is " +
          "already disabled.");
    }
  }
  admin.snapshot(snapshotNameString, tableName);

  List<SnapshotDescription> snapshots = SnapshotTestingUtils.assertExistsMatchingSnapshot(admin,
    snapshotNameString, tableName);
  if (snapshots == null || snapshots.size() != 1) {
    Assert.fail("Incorrect number of snapshots for table " + tableName);
  }

  SnapshotTestingUtils.confirmSnapshotValid(snapshots.get(0), tableName, nonEmptyFamilyNames,
    emptyFamilyNames, rootDir, admin, fs, false,
    new Path(rootDir, HConstants.HREGION_LOGDIR_NAME), null);
}
项目:cloud-bigtable-client    文件:TestDisableTable.java   
@Test
@Category(KnownGap.class)
// TODO(sduskis): Disabled tables should throw TableNotEnabledException for gets.
public void testDisable() throws IOException {
  Admin admin = getConnection().getAdmin();
  TableName tableName = TableName.valueOf("test_table-" + UUID.randomUUID().toString());
  IntegrationTests.createTable(tableName);
  try (Table table = getConnection().getTable(tableName)) {
    Get get = new Get("row".getBytes());
    table.get(get);
    admin.disableTable(tableName);
    Assert.assertTrue(admin.isTableDisabled(tableName));
    try {
      table.get(get);
      Assert.fail("Expected TableNotEnabledException");
    } catch (TableNotEnabledException e) {
    }
    admin.enableTable(tableName);
    table.get(get);
  } finally {
    if (admin.isTableEnabled(tableName)) {
      admin.disableTable(tableName);
    }
    admin.deleteTable(tableName);
  }
}
项目:pbase    文件:SnapshotTestingUtils.java   
/**
 * Take a snapshot of the specified table and verify the given families.
 * Note that this will leave the table disabled in the case of an offline snapshot.
 */
public static void createSnapshotAndValidate(Admin admin,
    TableName tableName, List<byte[]> nonEmptyFamilyNames, List<byte[]> emptyFamilyNames,
    String snapshotNameString, Path rootDir, FileSystem fs, boolean onlineSnapshot)
      throws Exception {
  if (!onlineSnapshot) {
    try {
      admin.disableTable(tableName);
    } catch (TableNotEnabledException tne) {
      LOG.info("In attempting to disable " + tableName + " it turns out that the this table is " +
          "already disabled.");
    }
  }
  admin.snapshot(snapshotNameString, tableName);

  List<SnapshotDescription> snapshots = SnapshotTestingUtils.assertExistsMatchingSnapshot(admin,
    snapshotNameString, tableName);
  if (snapshots == null || snapshots.size() != 1) {
    Assert.fail("Incorrect number of snapshots for table " + tableName);
  }

  SnapshotTestingUtils.confirmSnapshotValid(snapshots.get(0), tableName, nonEmptyFamilyNames,
    emptyFamilyNames, rootDir, admin, fs);
}
项目:HIndex    文件:SnapshotTestingUtils.java   
/**
 * Take a snapshot of the specified table and verify the given families.
 * Note that this will leave the table disabled in the case of an offline snapshot.
 */
public static void createSnapshotAndValidate(HBaseAdmin admin,
    TableName tableName, List<byte[]> nonEmptyFamilyNames, List<byte[]> emptyFamilyNames,
    String snapshotNameString, Path rootDir, FileSystem fs, boolean onlineSnapshot)
      throws Exception {
  if (!onlineSnapshot) {
    try {
      admin.disableTable(tableName);
    } catch (TableNotEnabledException tne) {
      LOG.info("In attempting to disable " + tableName + " it turns out that the this table is " +
          "already disabled.");
    }
  }
  admin.snapshot(snapshotNameString, tableName);

  List<SnapshotDescription> snapshots = SnapshotTestingUtils.assertExistsMatchingSnapshot(admin,
    snapshotNameString, tableName);
  if (snapshots == null || snapshots.size() != 1) {
    Assert.fail("Incorrect number of snapshots for table " + tableName);
  }

  SnapshotTestingUtils.confirmSnapshotValid(snapshots.get(0), tableName, nonEmptyFamilyNames,
    emptyFamilyNames, rootDir, admin, fs, false,
    new Path(rootDir, HConstants.HREGION_LOGDIR_NAME), null);
}
项目:IRIndex    文件:SnapshotTestingUtils.java   
/**
 * Take a snapshot of the specified table and verify the given families.
 * Note that this will leave the table disabled in the case of an offline snapshot.
 */
public static void createSnapshotAndValidate(HBaseAdmin admin,
    String tableName, List<byte[]> nonEmptyFamilyNames, List<byte[]> emptyFamilyNames,
    String snapshotNameString, Path rootDir, FileSystem fs, boolean onlineSnapshot)
      throws Exception {
  if (!onlineSnapshot) {
    try {
      admin.disableTable(tableName);
    } catch (TableNotEnabledException tne) {
      LOG.info("In attempting to disable " + tableName + " it turns out that the this table is " +
          "already disabled.");
    }
  }
  admin.snapshot(snapshotNameString, tableName);

  List<SnapshotDescription> snapshots = SnapshotTestingUtils.assertExistsMatchingSnapshot(admin,
    snapshotNameString, tableName);
  if (snapshots == null || snapshots.size() != 1) {
    Assert.fail("Incorrect number of snapshots for table " + tableName);
  }

  SnapshotTestingUtils.confirmSnapshotValid(snapshots.get(0), tableName, nonEmptyFamilyNames,
    emptyFamilyNames, rootDir, admin, fs, false,
    new Path(rootDir, HConstants.HREGION_LOGDIR_NAME), null);
}
项目:storm-smoke-test    文件:CleanupUtils.java   
public static void deleteHBaseTable(String hbaseUrl, String tableName) throws Exception {
        final Configuration hbConfig = HBaseConfiguration.create();
        hbConfig.set("hbase.rootdir", hbaseUrl);
        HBaseAdmin hBaseAdmin = new HBaseAdmin(hbConfig);
        HTableDescriptor[] tables = hBaseAdmin.listTables();
        for (HTableDescriptor table : tables) {
            if (table.getNameAsString().equals(tableName)) {
                try {
                    hBaseAdmin.disableTable(tableName);
                } catch (TableNotEnabledException e) {
                    LOG.info(tableName + " failed to disable as it was never enabled", e);
                }
                hBaseAdmin.deleteTable(tableName);
            }
        }
}
项目:hbase    文件:SecureTestUtil.java   
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 = testUtil.getHBaseCluster().getMaster()
    .getMasterCoprocessorHost().findCoprocessor(MasterSyncObserver.class);
  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;
}
项目:hbase    文件:TableOutputFormat.java   
/**
 * Checks if the output table exists and is enabled.
 *
 * @param context  The current context.
 * @throws IOException When the check fails.
 * @throws InterruptedException When the job is aborted.
 * @see OutputFormat#checkOutputSpecs(JobContext)
 */
@Override
public void checkOutputSpecs(JobContext context) throws IOException,
    InterruptedException {

  try (Admin admin = ConnectionFactory.createConnection(getConf()).getAdmin()) {
    TableName tableName = TableName.valueOf(this.conf.get(OUTPUT_TABLE));
    if (!admin.tableExists(tableName)) {
      throw new TableNotFoundException("Can't write, table does not exist:" +
          tableName.getNameAsString());
    }

    if (!admin.isTableEnabled(tableName)) {
      throw new TableNotEnabledException("Can't write, table is not enabled: " +
          tableName.getNameAsString());
    }
  }
}
项目:hbase    文件:RegionServerCallable.java   
@Override
public void prepare(final boolean reload) throws IOException {
  // check table state if this is a retry
  if (reload && tableName != null && !tableName.equals(TableName.META_TABLE_NAME)
      && getConnection().isTableDisabled(tableName)) {
    throw new TableNotEnabledException(tableName.getNameAsString() + " is disabled.");
  }
  try (RegionLocator regionLocator = connection.getRegionLocator(tableName)) {
    this.location = regionLocator.getRegionLocation(row);
  }
  if (this.location == null) {
    throw new IOException("Failed to find location, tableName=" + tableName +
        ", row=" + Bytes.toString(row) + ", reload=" + reload);
  }
  setStubByServiceName(this.location.getServerName());
}
项目:PyroDB    文件:SnapshotTestingUtils.java   
/**
 * Take a snapshot of the specified table and verify the given families.
 * Note that this will leave the table disabled in the case of an offline snapshot.
 */
public static void createSnapshotAndValidate(HBaseAdmin admin,
    TableName tableName, List<byte[]> nonEmptyFamilyNames, List<byte[]> emptyFamilyNames,
    String snapshotNameString, Path rootDir, FileSystem fs, boolean onlineSnapshot)
      throws Exception {
  if (!onlineSnapshot) {
    try {
      admin.disableTable(tableName);
    } catch (TableNotEnabledException tne) {
      LOG.info("In attempting to disable " + tableName + " it turns out that the this table is " +
          "already disabled.");
    }
  }
  admin.snapshot(snapshotNameString, tableName);

  List<SnapshotDescription> snapshots = SnapshotTestingUtils.assertExistsMatchingSnapshot(admin,
    snapshotNameString, tableName);
  if (snapshots == null || snapshots.size() != 1) {
    Assert.fail("Incorrect number of snapshots for table " + tableName);
  }

  SnapshotTestingUtils.confirmSnapshotValid(snapshots.get(0), tableName, nonEmptyFamilyNames,
    emptyFamilyNames, rootDir, admin, fs);
}
项目:c5    文件:SnapshotTestingUtils.java   
/**
 * Take a snapshot of the specified table and verify the given families.
 * Note that this will leave the table disabled in the case of an offline snapshot.
 */
public static void createSnapshotAndValidate(HBaseAdmin admin,
    TableName tableName, List<byte[]> nonEmptyFamilyNames, List<byte[]> emptyFamilyNames,
    String snapshotNameString, Path rootDir, FileSystem fs, boolean onlineSnapshot)
      throws Exception {
  if (!onlineSnapshot) {
    try {
      admin.disableTable(tableName);
    } catch (TableNotEnabledException tne) {
      LOG.info("In attempting to disable " + tableName + " it turns out that the this table is " +
          "already disabled.");
    }
  }
  admin.snapshot(snapshotNameString, tableName);

  List<SnapshotDescription> snapshots = SnapshotTestingUtils.assertExistsMatchingSnapshot(admin,
    snapshotNameString, tableName);
  if (snapshots == null || snapshots.size() != 1) {
    Assert.fail("Incorrect number of snapshots for table " + tableName);
  }

  SnapshotTestingUtils.confirmSnapshotValid(snapshots.get(0), tableName, nonEmptyFamilyNames,
    emptyFamilyNames, rootDir, admin, fs, false,
    new Path(rootDir, HConstants.HREGION_LOGDIR_NAME), null);
}
项目:spliceengine    文件:RegionServerLifecycle.java   
private boolean causeIsPleaseHold(Throwable e) {
    if (e instanceof PleaseHoldException)
        return true;
    if (e instanceof TableNotEnabledException)
        return true;
    if (e instanceof RegionOfflineException)
        return true;
    if (e instanceof RetriesExhaustedException || e instanceof SocketTimeoutException) {
        if (e.getCause() instanceof RemoteException) {
            RemoteException re = (RemoteException) e.getCause();
            if (PleaseHoldException.class.getName().equals(re.getClassName()))
                return true;
        }
    }
    return false;
}
项目:ditb    文件:DisableTableProcedure.java   
/**
 * Action before any real action of disabling table. Set the exception in the procedure instead
 * of throwing it.  This approach is to deal with backward compatible with 1.0.
 * @param env MasterProcedureEnv
 * @throws HBaseException
 * @throws IOException
 */
private boolean prepareDisable(final MasterProcedureEnv env) throws HBaseException, IOException {
  boolean canTableBeDisabled = true;
  if (tableName.equals(TableName.META_TABLE_NAME)) {
    setFailure("master-disable-table", new ConstraintException("Cannot disable catalog table"));
    canTableBeDisabled = false;
  } else if (!MetaTableAccessor.tableExists(env.getMasterServices().getConnection(), tableName)) {
    setFailure("master-disable-table", new TableNotFoundException(tableName));
    canTableBeDisabled = false;
  } else if (!skipTableStateCheck) {
    // There could be multiple client requests trying to disable or enable
    // the table at the same time. Ensure only the first request is honored
    // After that, no other requests can be accepted until the table reaches
    // DISABLED or ENABLED.
    //
    // Note: A quick state check should be enough for us to move forward. However, instead of
    // calling TableStateManager.isTableState() to just check the state, we called
    // TableStateManager.setTableStateIfInStates() to set the state to DISABLING from ENABLED.
    // This is because we treat empty state as enabled from 0.92-clusters. See
    // ZKTableStateManager.setTableStateIfInStates() that has a hack solution to work around
    // this issue.
    TableStateManager tsm =
      env.getMasterServices().getAssignmentManager().getTableStateManager();
    if (!tsm.setTableStateIfInStates(tableName, ZooKeeperProtos.Table.State.DISABLING,
          ZooKeeperProtos.Table.State.DISABLING, ZooKeeperProtos.Table.State.ENABLED)) {
      LOG.info("Table " + tableName + " isn't enabled; skipping disable");
      setFailure("master-disable-table", new TableNotEnabledException(tableName));
      canTableBeDisabled = false;
    }
  }

  // We are done the check. Future actions in this procedure could be done asynchronously.
  ProcedurePrepareLatch.releaseLatch(syncLatch, this);

  return canTableBeDisabled;
}
项目:ditb    文件:TestAdmin2.java   
/**
 * Can't disable a table if the table isn't in enabled state
 * @throws IOException
 */
@Test (expected=TableNotEnabledException.class, timeout=300000)
public void testTableNotEnabledExceptionWithATable() throws IOException {
  final TableName name = TableName.valueOf("testTableNotEnabledExceptionWithATable");
  TEST_UTIL.createTable(name, HConstants.CATALOG_FAMILY).close();
  this.admin.disableTable(name);
  this.admin.disableTable(name);
}
项目:ditb    文件:ConnectionManager.java   
@Override
public RegionLocations relocateRegion(final TableName tableName,
    final byte [] row, int replicaId) throws IOException{
  // Since this is an explicit request not to use any caching, finding
  // disabled tables should not be desirable.  This will ensure that an exception is thrown when
  // the first time a disabled table is interacted with.
  if (!tableName.equals(TableName.META_TABLE_NAME) && isTableDisabled(tableName)) {
    throw new TableNotEnabledException(tableName.getNameAsString() + " is disabled.");
  }

  return locateRegion(tableName, row, false, true, replicaId);
}
项目:LCIndex-HBase-0.94.16    文件:DisableTableHandler.java   
public DisableTableHandler(Server server, byte [] tableName,
    CatalogTracker catalogTracker, AssignmentManager assignmentManager,
    boolean skipTableStateCheck)
throws TableNotFoundException, TableNotEnabledException, IOException {
  super(server, EventType.C_M_DISABLE_TABLE);
  this.tableName = tableName;
  this.tableNameStr = Bytes.toString(this.tableName);
  this.assignmentManager = assignmentManager;
  // Check if table exists
  // TODO: do we want to keep this in-memory as well?  i guess this is
  //       part of old master rewrite, schema to zk to check for table
  //       existence and such
  if (!MetaReader.tableExists(catalogTracker, this.tableNameStr)) {
    throw new TableNotFoundException(this.tableNameStr);
  }

  // There could be multiple client requests trying to disable or enable
  // the table at the same time. Ensure only the first request is honored
  // After that, no other requests can be accepted until the table reaches
  // DISABLED or ENABLED.
  if (!skipTableStateCheck)
  {
    try {
      if (!this.assignmentManager.getZKTable().checkEnabledAndSetDisablingTable
        (this.tableNameStr)) {
        LOG.info("Table " + tableNameStr + " isn't enabled; skipping disable");
        throw new TableNotEnabledException(this.tableNameStr);
      }
    } catch (KeeperException e) {
      throw new IOException("Unable to ensure that the table will be" +
        " disabling because of a ZooKeeper issue", e);
    }
  }
}
项目:LCIndex-HBase-0.94.16    文件:TestAdmin.java   
/**
 * Can't disable a table if the table isn't in enabled state
 * @throws IOException
 */
@Test (expected=TableNotEnabledException.class)
public void testTableNotEnabledExceptionWithATable() throws IOException {
  final byte [] name = Bytes.toBytes(
    "testTableNotEnabledExceptionWithATable");
  TEST_UTIL.createTable(name, HConstants.CATALOG_FAMILY).close();
  this.admin.disableTable(name);
  this.admin.disableTable(name);
}
项目:notaql    文件:NotaQLCSVTest.java   
private void deleteTable(String name) throws IOException {
    try {
        this.admin.disableTable(name);
    } catch(TableNotEnabledException ignored) {

    }
    this.admin.deleteTable(name);
}
项目:cloud-bigtable-client    文件:BigtableAdmin.java   
@Override
public void disableTable(TableName tableName) throws IOException {
  TableName.isLegalFullyQualifiedTableName(tableName.getName());
  if (!this.tableExists(tableName)) {
    throw new TableNotFoundException(tableName);
  }
  if (this.isTableDisabled(tableName)) {
    throw new TableNotEnabledException(tableName);
  }
  disabledTables.add(tableName);
  LOG.warn("Table " + tableName + " was disabled in memory only.");
}
项目:pbase    文件:TestAdmin2.java   
/**
 * Can't disable a table if the table isn't in enabled state
 * @throws IOException
 */
@Test (expected=TableNotEnabledException.class, timeout=300000)
public void testTableNotEnabledExceptionWithATable() throws IOException {
  final TableName name = TableName.valueOf("testTableNotEnabledExceptionWithATable");
  TEST_UTIL.createTable(name, HConstants.CATALOG_FAMILY).close();
  this.admin.disableTable(name);
  this.admin.disableTable(name);
}
项目:pbase    文件:ConnectionManager.java   
@Override
public RegionLocations relocateRegion(final TableName tableName,
                                      final byte[] row, int replicaId) throws IOException {
    // Since this is an explicit request not to use any caching, finding
    // disabled tables should not be desirable.  This will ensure that an exception is thrown when
    // the first time a disabled table is interacted with.
    if (!tableName.equals(TableName.META_TABLE_NAME) && isTableDisabled(tableName)) {
        throw new TableNotEnabledException(tableName.getNameAsString() + " is disabled.");
    }

    return locateRegion(tableName, row, false, true, replicaId);
}
项目:HIndex    文件:TestAdmin.java   
/**
 * Can't disable a table if the table isn't in enabled state
 * @throws IOException
 */
@Test (expected=TableNotEnabledException.class, timeout=300000)
public void testTableNotEnabledExceptionWithATable() throws IOException {
  final byte [] name = Bytes.toBytes(
    "testTableNotEnabledExceptionWithATable");
  TEST_UTIL.createTable(name, HConstants.CATALOG_FAMILY).close();
  this.admin.disableTable(name);
  this.admin.disableTable(name);
}
项目:HIndex    文件:HConnectionManager.java   
@Override
public HRegionLocation relocateRegion(final TableName tableName,
    final byte [] row) throws IOException{
  // Since this is an explicit request not to use any caching, finding
  // disabled tables should not be desirable.  This will ensure that an exception is thrown when
  // the first time a disabled table is interacted with.
  if (isTableDisabled(tableName)) {
    throw new TableNotEnabledException(tableName.getNameAsString() + " is disabled.");
  }

  return locateRegion(tableName, row, false, true);
}
项目:IRIndex    文件:DisableTableHandler.java   
public DisableTableHandler(Server server, byte [] tableName,
    CatalogTracker catalogTracker, AssignmentManager assignmentManager,
    boolean skipTableStateCheck)
throws TableNotFoundException, TableNotEnabledException, IOException {
  super(server, EventType.C_M_DISABLE_TABLE);
  this.tableName = tableName;
  this.tableNameStr = Bytes.toString(this.tableName);
  this.assignmentManager = assignmentManager;
  // Check if table exists
  // TODO: do we want to keep this in-memory as well?  i guess this is
  //       part of old master rewrite, schema to zk to check for table
  //       existence and such
  if (!MetaReader.tableExists(catalogTracker, this.tableNameStr)) {
    throw new TableNotFoundException(this.tableNameStr);
  }

  // There could be multiple client requests trying to disable or enable
  // the table at the same time. Ensure only the first request is honored
  // After that, no other requests can be accepted until the table reaches
  // DISABLED or ENABLED.
  if (!skipTableStateCheck)
  {
    try {
      if (!this.assignmentManager.getZKTable().checkEnabledAndSetDisablingTable
        (this.tableNameStr)) {
        LOG.info("Table " + tableNameStr + " isn't enabled; skipping disable");
        throw new TableNotEnabledException(this.tableNameStr);
      }
    } catch (KeeperException e) {
      throw new IOException("Unable to ensure that the table will be" +
        " disabling because of a ZooKeeper issue", e);
    }
  }
}
项目:IRIndex    文件:TestAdmin.java   
/**
 * Can't disable a table if the table isn't in enabled state
 * @throws IOException
 */
@Test (expected=TableNotEnabledException.class)
public void testTableNotEnabledExceptionWithATable() throws IOException {
  final byte [] name = Bytes.toBytes(
    "testTableNotEnabledExceptionWithATable");
  TEST_UTIL.createTable(name, HConstants.CATALOG_FAMILY).close();
  this.admin.disableTable(name);
  this.admin.disableTable(name);
}
项目:hbase    文件:DisableTableViolationPolicyEnforcement.java   
@Override
public void enable() throws IOException {
  try {
    if (LOG.isTraceEnabled()) {
      LOG.trace("Starting disable of " + getTableName());
    }
    getRegionServerServices().getClusterConnection().getAdmin().disableTable(getTableName());
    if (LOG.isTraceEnabled()) {
      LOG.trace("Disable is complete for " + getTableName());
    }
  } catch (TableNotEnabledException tnee) {
    // The state we wanted it to be in.
  }
}
项目:hbase    文件:DisableTableProcedure.java   
/**
 * Action before any real action of disabling table. Set the exception in the procedure instead
 * of throwing it.  This approach is to deal with backward compatible with 1.0.
 * @param env MasterProcedureEnv
 * @throws IOException
 */
private boolean prepareDisable(final MasterProcedureEnv env) throws IOException {
  boolean canTableBeDisabled = true;
  if (tableName.equals(TableName.META_TABLE_NAME)) {
    setFailure("master-disable-table", new ConstraintException("Cannot disable catalog table"));
    canTableBeDisabled = false;
  } else if (!MetaTableAccessor.tableExists(env.getMasterServices().getConnection(), tableName)) {
    setFailure("master-disable-table", new TableNotFoundException(tableName));
    canTableBeDisabled = false;
  } else if (!skipTableStateCheck) {
    // There could be multiple client requests trying to disable or enable
    // the table at the same time. Ensure only the first request is honored
    // After that, no other requests can be accepted until the table reaches
    // DISABLED or ENABLED.
    //
    // Note: in 1.0 release, we called TableStateManager.setTableStateIfInStates() to set
    // the state to DISABLING from ENABLED. The implementation was done before table lock
    // was implemented. With table lock, there is no need to set the state here (it will
    // set the state later on). A quick state check should be enough for us to move forward.
    TableStateManager tsm = env.getMasterServices().getTableStateManager();
    TableState.State state = tsm.getTableState(tableName);
    if (!state.equals(TableState.State.ENABLED)){
      LOG.info("Table " + tableName + " isn't enabled;is "+state.name()+"; skipping disable");
      setFailure("master-disable-table", new TableNotEnabledException(
              tableName+" state is "+state.name()));
      canTableBeDisabled = false;
    }
  }

  // We are done the check. Future actions in this procedure could be done asynchronously.
  releaseSyncLatch();

  return canTableBeDisabled;
}
项目:hbase    文件:TestAdmin2.java   
/**
 * Can't disable a table if the table isn't in enabled state
 * @throws IOException
 */
@Test (expected=TableNotEnabledException.class, timeout=300000)
public void testTableNotEnabledExceptionWithATable() throws IOException {
  final TableName name = TableName.valueOf(this.name.getMethodName());
  TEST_UTIL.createTable(name, HConstants.CATALOG_FAMILY).close();
  this.admin.disableTable(name);
  this.admin.disableTable(name);
}
项目:hbase    文件:SnapshotTestingUtils.java   
/**
 * Take a snapshot of the specified table and verify the given families.
 * Note that this will leave the table disabled in the case of an offline snapshot.
 */
public static void createSnapshotAndValidate(Admin admin,
    TableName tableName, List<byte[]> nonEmptyFamilyNames, List<byte[]> emptyFamilyNames,
    String snapshotNameString, Path rootDir, FileSystem fs, boolean onlineSnapshot)
      throws Exception {
  if (!onlineSnapshot) {
    try {
      LOG.info("prepping for offline snapshot.");
      admin.disableTable(tableName);
    } catch (TableNotEnabledException tne) {
      LOG.info("In attempting to disable " + tableName + " it turns out that the this table is " +
          "already disabled.");
    }
  }
  LOG.info("taking snapshot.");
  admin.snapshot(snapshotNameString, tableName);

  LOG.info("Confirming snapshot exists.");
  List<SnapshotDescription> snapshots =
      SnapshotTestingUtils.assertExistsMatchingSnapshot(admin, snapshotNameString, tableName);
  if (snapshots == null || snapshots.size() != 1) {
    Assert.fail("Incorrect number of snapshots for table " + tableName);
  }

  LOG.info("validating snapshot.");
  SnapshotTestingUtils.confirmSnapshotValid(
    ProtobufUtil.createHBaseProtosSnapshotDesc(snapshots.get(0)), tableName, nonEmptyFamilyNames,
    emptyFamilyNames, rootDir, admin, fs);
}
项目:hbase    文件:TestTableMapReduce.java   
@Test(expected = TableNotEnabledException.class)
public void testWritingToDisabledTable() throws IOException {

  try (Admin admin = UTIL.getConnection().getAdmin();
    Table table = UTIL.getConnection().getTable(TABLE_FOR_NEGATIVE_TESTS)) {
    admin.disableTable(table.getName());
    runTestOnTable(table);
    fail("Should not have reached here, should have thrown an exception");
  }
}
项目:hbase    文件:ConnectionImplementation.java   
@Override
public RegionLocations relocateRegion(final TableName tableName,
    final byte [] row, int replicaId) throws IOException{
  // Since this is an explicit request not to use any caching, finding
  // disabled tables should not be desirable.  This will ensure that an exception is thrown when
  // the first time a disabled table is interacted with.
  if (!tableName.equals(TableName.META_TABLE_NAME) && isTableDisabled(tableName)) {
    throw new TableNotEnabledException(tableName.getNameAsString() + " is disabled.");
  }

  return locateRegion(tableName, row, false, true, replicaId);
}
项目:hbase    文件:RawAsyncHBaseAdmin.java   
@Override
public CompletableFuture<Void> flush(TableName tableName) {
  CompletableFuture<Void> future = new CompletableFuture<>();
  tableExists(tableName).whenComplete((exists, err) -> {
    if (err != null) {
      future.completeExceptionally(err);
    } else if (!exists) {
      future.completeExceptionally(new TableNotFoundException(tableName));
    } else {
      isTableEnabled(tableName).whenComplete((tableEnabled, err2) -> {
        if (err2 != null) {
          future.completeExceptionally(err2);
        } else if (!tableEnabled) {
          future.completeExceptionally(new TableNotEnabledException(tableName));
        } else {
          execProcedure(FLUSH_TABLE_PROCEDURE_SIGNATURE, tableName.getNameAsString(),
            new HashMap<>()).whenComplete((ret, err3) -> {
              if (err3 != null) {
                future.completeExceptionally(err3);
              } else {
                future.complete(ret);
              }
            });
        }
      });
    }
  });
  return future;
}
项目:RStore    文件:DisableTableHandler.java   
public DisableTableHandler(Server server, byte [] tableName,
    CatalogTracker catalogTracker, AssignmentManager assignmentManager,
    boolean skipTableStateCheck)
throws TableNotFoundException, TableNotEnabledException, IOException {
  super(server, EventType.C_M_DISABLE_TABLE);
  this.tableName = tableName;
  this.tableNameStr = Bytes.toString(this.tableName);
  this.assignmentManager = assignmentManager;
  // Check if table exists
  // TODO: do we want to keep this in-memory as well?  i guess this is
  //       part of old master rewrite, schema to zk to check for table
  //       existence and such
  if (!MetaReader.tableExists(catalogTracker, this.tableNameStr)) {
    throw new TableNotFoundException(this.tableNameStr);
  }

  // There could be multiple client requests trying to disable or enable
  // the table at the same time. Ensure only the first request is honored
  // After that, no other requests can be accepted until the table reaches
  // DISABLED or ENABLED.
  if (!skipTableStateCheck)
  {
    try {
      if (!this.assignmentManager.getZKTable().checkEnabledAndSetDisablingTable
        (this.tableNameStr)) {
        LOG.info("Table " + tableNameStr + " isn't enabled; skipping disable");
        throw new TableNotEnabledException(this.tableNameStr);
      }
    } catch (KeeperException e) {
      throw new IOException("Unable to ensure that the table will be" +
        " disabling because of a ZooKeeper issue", e);
    }
  }
}
项目:CSBT    文件:ClusterVerifierUtil.java   
public static void disableTable(HBaseAdmin admin, String tableName) throws IOException {
  try {
    admin.disableTable(tableName);
  } catch (TableNotEnabledException e) {
    // Supress the TableNotEnabledException.
  }
}
项目:PyroDB    文件:TestAdmin.java   
/**
 * Can't disable a table if the table isn't in enabled state
 * @throws IOException
 */
@Test (expected=TableNotEnabledException.class, timeout=300000)
public void testTableNotEnabledExceptionWithATable() throws IOException {
  final byte [] name = Bytes.toBytes(
    "testTableNotEnabledExceptionWithATable");
  TEST_UTIL.createTable(name, HConstants.CATALOG_FAMILY).close();
  this.admin.disableTable(name);
  this.admin.disableTable(name);
}
项目:PyroDB    文件:ConnectionManager.java   
@Override
public HRegionLocation relocateRegion(final TableName tableName,
    final byte [] row) throws IOException{
  // Since this is an explicit request not to use any caching, finding
  // disabled tables should not be desirable.  This will ensure that an exception is thrown when
  // the first time a disabled table is interacted with.
  if (isTableDisabled(tableName)) {
    throw new TableNotEnabledException(tableName.getNameAsString() + " is disabled.");
  }

  return locateRegion(tableName, row, false, true);
}
项目:c5    文件:TestAdmin.java   
/**
 * Can't disable a table if the table isn't in enabled state
 * @throws IOException
 */
@Test (expected=TableNotEnabledException.class, timeout=300000)
public void testTableNotEnabledExceptionWithATable() throws IOException {
  final byte [] name = Bytes.toBytes(
    "testTableNotEnabledExceptionWithATable");
  TEST_UTIL.createTable(name, HConstants.CATALOG_FAMILY).close();
  this.admin.disableTable(name);
  this.admin.disableTable(name);
}
项目:c5    文件:HConnectionManager.java   
@Override
public HRegionLocation relocateRegion(final TableName tableName,
    final byte [] row) throws IOException{
  // Since this is an explicit request not to use any caching, finding
  // disabled tables should not be desirable.  This will ensure that an exception is thrown when
  // the first time a disabled table is interacted with.
  if (isTableDisabled(tableName)) {
    throw new TableNotEnabledException(tableName.getNameAsString() + " is disabled.");
  }

  return locateRegion(tableName, row, false, true);
}