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

项目:ditb    文件:HMaster.java   
@Override
public NamespaceDescriptor getNamespaceDescriptor(String name) throws IOException {
  checkNamespaceManagerReady();

  if (cpHost != null) {
    cpHost.preGetNamespaceDescriptor(name);
  }

  NamespaceDescriptor nsd = tableNamespaceManager.get(name);
  if (nsd == null) {
    throw new NamespaceNotFoundException(name);
  }

  if (cpHost != null) {
    cpHost.postGetNamespaceDescriptor(nsd);
  }

  return nsd;
}
项目:ColumnManagerForHBase    文件:TestRepositoryAdmin.java   
private void dropTestTablesAndNamespaces(Admin standardAdmin)
        throws IOException {
  // loop to disable and drop test tables and namespaces
  for (TableName tableName : testTableNamesAndDescriptors.keySet()) {
    if (!standardAdmin.tableExists(tableName)) {
      continue;
    }
    if (!standardAdmin.isTableDisabled(tableName)) {
      standardAdmin.disableTable(tableName);
    }
    standardAdmin.deleteTable(tableName);
  }
  for (String namespaceName : testNamespacesAndDescriptors.keySet()) {
    if (namespaceName.isEmpty() || namespaceName.equals("default")) {
      continue;
    }
    try { standardAdmin.deleteNamespace(namespaceName);
    } catch (NamespaceNotFoundException e) {}
  }
}
项目:ColumnManagerForHBase    文件:TestColumnAliasing.java   
private void dropTestTablesAndNamespaces(Admin standardAdmin) throws IOException {
  // loop to disable and drop test tables and namespaces
  for (TableName tableName : testTableNamesAndDescriptors.keySet()) {
    if (!standardAdmin.tableExists(tableName)) {
      continue;
    }
    if (!standardAdmin.isTableDisabled(tableName)) {
      standardAdmin.disableTable(tableName);
    }
    standardAdmin.deleteTable(tableName);
  }
  for (String namespaceName : testNamespacesAndDescriptors.keySet()) {
    if (namespaceName.isEmpty() || namespaceName.equals("default")) {
      continue;
    }
    try { standardAdmin.deleteNamespace(namespaceName);
    } catch (NamespaceNotFoundException e) {}
  }
}
项目:pbase    文件:HMaster.java   
@Override
public NamespaceDescriptor getNamespaceDescriptor(String name) throws IOException {
    checkNamespaceManagerReady();

    if (cpHost != null) {
        cpHost.preGetNamespaceDescriptor(name);
    }

    NamespaceDescriptor nsd = tableNamespaceManager.get(name);
    if (nsd == null) {
        throw new NamespaceNotFoundException(name);
    }

    if (cpHost != null) {
        cpHost.postGetNamespaceDescriptor(nsd);
    }

    return nsd;
}
项目:hbase    文件:DeleteNamespaceProcedure.java   
/**
 * Action before any real action of deleting namespace.
 * @param env MasterProcedureEnv
 * @throws IOException
 */
private void prepareDelete(final MasterProcedureEnv env) throws IOException {
  if (getTableNamespaceManager(env).doesNamespaceExist(namespaceName) == false) {
    throw new NamespaceNotFoundException(namespaceName);
  }
  if (NamespaceDescriptor.RESERVED_NAMESPACES.contains(namespaceName)) {
    throw new ConstraintException("Reserved namespace "+ namespaceName +" cannot be removed.");
  }

  int tableCount = 0;
  try {
    tableCount = env.getMasterServices().listTableDescriptorsByNamespace(namespaceName).size();
  } catch (FileNotFoundException fnfe) {
    throw new NamespaceNotFoundException(namespaceName);
  }
  if (tableCount > 0) {
    throw new ConstraintException("Only empty namespaces can be removed. " +
        "Namespace "+ namespaceName + " has "+ tableCount +" tables");
  }

  // This is used for rollback
  nsDescriptor = getTableNamespaceManager(env).get(namespaceName);
}
项目:hbase    文件:TestCreateNamespaceProcedure.java   
@Test(timeout = 60000)
public void testRollbackAndDoubleExecution() throws Exception {
  final NamespaceDescriptor nsd =
      NamespaceDescriptor.create("testRollbackAndDoubleExecution").build();
  final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();

  ProcedureTestingUtility.waitNoProcedureRunning(procExec);
  ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, true);

  // Start the CreateNamespace procedure && kill the executor
  long procId = procExec.submitProcedure(
    new CreateNamespaceProcedure(procExec.getEnvironment(), nsd));

  int numberOfSteps = 0; // failing at pre operation
  MasterProcedureTestingUtility.testRollbackAndDoubleExecution(procExec, procId, numberOfSteps);

  // Validate the non-existence of namespace
  try {
    NamespaceDescriptor nsDescriptor = UTIL.getAdmin().getNamespaceDescriptor(nsd.getName());
    assertNull(nsDescriptor);
  } catch (NamespaceNotFoundException nsnfe) {
    // Expected
    LOG.info("The namespace " + nsd.getName() + " is not created.");
  }
}
项目:hbase    文件:TestDeleteNamespaceProcedure.java   
@Test(timeout=60000)
public void testDeleteNonExistNamespace() throws Exception {
  final String namespaceName = "testDeleteNonExistNamespace";
  final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();

  validateNamespaceNotExist(namespaceName);

  long procId = procExec.submitProcedure(
    new DeleteNamespaceProcedure(procExec.getEnvironment(), namespaceName));
  // Wait the completion
  ProcedureTestingUtility.waitProcedure(procExec, procId);
  // Expect fail with NamespaceNotFoundException
  Procedure<?> result = procExec.getResult(procId);
  assertTrue(result.isFailed());
  LOG.debug("Delete namespace failed with exception: " + result.getException());
  assertTrue(
    ProcedureTestingUtility.getExceptionCause(result) instanceof NamespaceNotFoundException);
}
项目:ditb    文件:HMaster.java   
/**
 * Ensure that the specified namespace exists, otherwise throws a NamespaceNotFoundException
 *
 * @param name the namespace to check
 * @throws IOException if the namespace manager is not ready yet.
 * @throws NamespaceNotFoundException if the namespace does not exists
 */
private void ensureNamespaceExists(final String name)
    throws IOException, NamespaceNotFoundException {
  checkNamespaceManagerReady();
  NamespaceDescriptor nsd = tableNamespaceManager.get(name);
  if (nsd == null) {
    throw new NamespaceNotFoundException(name);
  }
}
项目:ditb    文件:TableNamespaceManager.java   
public synchronized void update(NamespaceDescriptor ns) throws IOException {
  Table table = getNamespaceTable();
  if (get(table, ns.getName()) == null) {
    throw new NamespaceNotFoundException(ns.getName());
  }
  upsert(table, ns);
}
项目:ditb    文件:TableNamespaceManager.java   
public synchronized void remove(String name) throws IOException {
  if (get(name) == null) {
    throw new NamespaceNotFoundException(name);
  }
  if (NamespaceDescriptor.RESERVED_NAMESPACES.contains(name)) {
    throw new ConstraintException("Reserved namespace "+name+" cannot be removed.");
  }
  int tableCount;
  try {
    tableCount = masterServices.listTableDescriptorsByNamespace(name).size();
  } catch (FileNotFoundException fnfe) {
    throw new NamespaceNotFoundException(name);
  }
  if (tableCount > 0) {
    throw new ConstraintException("Only empty namespaces can be removed. " +
        "Namespace "+name+" has "+tableCount+" tables");
  }
  Delete d = new Delete(Bytes.toBytes(name));
  getNamespaceTable().delete(d);
  //don't abort if cleanup isn't complete
  //it will be replaced on new namespace creation
  zkNamespaceManager.remove(name);
  FileSystem fs = masterServices.getMasterFileSystem().getFileSystem();
  for(FileStatus status :
          fs.listStatus(FSUtils.getNamespaceDir(
              masterServices.getMasterFileSystem().getRootDir(), name))) {
    if (!HConstants.HBASE_NON_TABLE_DIRS.contains(status.getPath().getName())) {
      throw new IOException("Namespace directory contains table dir: "+status.getPath());
    }
  }
  if (!fs.delete(FSUtils.getNamespaceDir(
      masterServices.getMasterFileSystem().getRootDir(), name), true)) {
    throw new IOException("Failed to remove namespace: "+name);
  }
  this.masterServices.getMasterQuotaManager().removeNamespaceQuota(name);
}
项目:ColumnManagerForHBase    文件:Repository.java   
static boolean namespaceExists(Admin hbaseAdmin, NamespaceDescriptor nd)
        throws IOException {
  try {
    hbaseAdmin.getNamespaceDescriptor(nd.getName());
  } catch (NamespaceNotFoundException e) {
    return false;
  }
  return true;
}
项目:ColumnManagerForHBase    文件:Repository.java   
boolean namespaceExists(String namespaceName) throws IOException {
  try {
    getAdmin().getNamespaceDescriptor(namespaceName);
  } catch (NamespaceNotFoundException e) {
    return false;
  }
  return true;
}
项目:ColumnManagerForHBase    文件:TestMConnectionFactory.java   
static boolean namespaceExists(Admin hbaseAdmin, NamespaceDescriptor nd)
        throws IOException {
  try {
    hbaseAdmin.getNamespaceDescriptor(nd.getName());
  } catch (NamespaceNotFoundException e) {
    return false;
  }
  return true;
}
项目:pbase    文件:HMaster.java   
/**
 * Ensure that the specified namespace exists, otherwise throws a NamespaceNotFoundException
 *
 * @param name the namespace to check
 * @throws IOException                if the namespace manager is not ready yet.
 * @throws NamespaceNotFoundException if the namespace does not exists
 */
private void ensureNamespaceExists(final String name)
        throws IOException, NamespaceNotFoundException {
    checkNamespaceManagerReady();
    NamespaceDescriptor nsd = tableNamespaceManager.get(name);
    if (nsd == null) {
        throw new NamespaceNotFoundException(name);
    }
}
项目:pbase    文件:TableNamespaceManager.java   
public synchronized void update(NamespaceDescriptor ns) throws IOException {
  Table table = getNamespaceTable();
  if (get(table, ns.getName()) == null) {
    throw new NamespaceNotFoundException(ns.getName());
  }
  upsert(table, ns);
}
项目:pbase    文件:TableNamespaceManager.java   
public synchronized void remove(String name) throws IOException {
  if (get(name) == null) {
    throw new NamespaceNotFoundException(name);
  }
  if (NamespaceDescriptor.RESERVED_NAMESPACES.contains(name)) {
    throw new ConstraintException("Reserved namespace "+name+" cannot be removed.");
  }
  int tableCount;
  try {
    tableCount = masterServices.listTableDescriptorsByNamespace(name).size();
  } catch (FileNotFoundException fnfe) {
    throw new NamespaceNotFoundException(name);
  }
  if (tableCount > 0) {
    throw new ConstraintException("Only empty namespaces can be removed. " +
        "Namespace "+name+" has "+tableCount+" tables");
  }
  Delete d = new Delete(Bytes.toBytes(name));
  getNamespaceTable().delete(d);
  //don't abort if cleanup isn't complete
  //it will be replaced on new namespace creation
  zkNamespaceManager.remove(name);
  FileSystem fs = masterServices.getMasterFileSystem().getFileSystem();
  for(FileStatus status :
          fs.listStatus(FSUtils.getNamespaceDir(
              masterServices.getMasterFileSystem().getRootDir(), name))) {
    if (!HConstants.HBASE_NON_TABLE_DIRS.contains(status.getPath().getName())) {
      throw new IOException("Namespace directory contains table dir: "+status.getPath());
    }
  }
  if (!fs.delete(FSUtils.getNamespaceDir(
      masterServices.getMasterFileSystem().getRootDir(), name), true)) {
    throw new IOException("Failed to remove namespace: "+name);
  }
}
项目:HIndex    文件:HMaster.java   
@Override
public NamespaceDescriptor getNamespaceDescriptor(String name) throws IOException {
  boolean ready = tableNamespaceManager != null &&
      tableNamespaceManager.isTableAvailableAndInitialized();
  if (!ready) {
    throw new IOException("Table Namespace Manager not ready yet, try again later");
  }
  NamespaceDescriptor nsd = tableNamespaceManager.get(name);
  if (nsd == null) {
    throw new NamespaceNotFoundException(name);
  }
  return nsd;
}
项目:HIndex    文件:TableNamespaceManager.java   
public synchronized void update(NamespaceDescriptor ns) throws IOException {
  HTable table = getNamespaceTable();
  if (get(table, ns.getName()) == null) {
    throw new NamespaceNotFoundException(ns.getName());
  }
  upsert(table, ns);
}
项目:HIndex    文件:TableNamespaceManager.java   
public synchronized void remove(String name) throws IOException {
  if (get(name) == null) {
    throw new NamespaceNotFoundException(name);
  }
  if (NamespaceDescriptor.RESERVED_NAMESPACES.contains(name)) {
    throw new ConstraintException("Reserved namespace "+name+" cannot be removed.");
  }
  int tableCount;
  try {
    tableCount = masterServices.listTableDescriptorsByNamespace(name).size();
  } catch (FileNotFoundException fnfe) {
    throw new NamespaceNotFoundException(name);
  }
  if (tableCount > 0) {
    throw new ConstraintException("Only empty namespaces can be removed. " +
        "Namespace "+name+" has "+tableCount+" tables");
  }
  Delete d = new Delete(Bytes.toBytes(name));
  getNamespaceTable().delete(d);
  //don't abort if cleanup isn't complete
  //it will be replaced on new namespace creation
  zkNamespaceManager.remove(name);
  FileSystem fs = masterServices.getMasterFileSystem().getFileSystem();
  for(FileStatus status :
          fs.listStatus(FSUtils.getNamespaceDir(
              masterServices.getMasterFileSystem().getRootDir(), name))) {
    if (!HConstants.HBASE_NON_TABLE_DIRS.contains(status.getPath().getName())) {
      throw new IOException("Namespace directory contains table dir: "+status.getPath());
    }
  }
  if (!fs.delete(FSUtils.getNamespaceDir(
      masterServices.getMasterFileSystem().getRootDir(), name), true)) {
    throw new IOException("Failed to remove namespace: "+name);
  }
}
项目:hbase    文件:ModifyNamespaceProcedure.java   
/**
 * Action before any real action of adding namespace.
 * @param env MasterProcedureEnv
 * @throws IOException
 */
private void prepareModify(final MasterProcedureEnv env) throws IOException {
  if (getTableNamespaceManager(env).doesNamespaceExist(newNsDescriptor.getName()) == false) {
    throw new NamespaceNotFoundException(newNsDescriptor.getName());
  }
  getTableNamespaceManager(env).validateTableAndRegionCount(newNsDescriptor);

  // This is used for rollback
  oldNsDescriptor = getTableNamespaceManager(env).get(newNsDescriptor.getName());
}
项目:hbase    文件:TestModifyNamespaceProcedure.java   
@Test(timeout=60000)
public void testModifyNonExistNamespace() throws Exception {
  final String namespaceName = "testModifyNonExistNamespace";
  final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();

  try {
    NamespaceDescriptor nsDescriptor = UTIL.getAdmin().getNamespaceDescriptor(namespaceName);
    assertNull(nsDescriptor);
  } catch (NamespaceNotFoundException nsnfe) {
    // Expected
    LOG.debug("The namespace " + namespaceName + " does not exist.  This is expected.");
  }

  final NamespaceDescriptor nsd = NamespaceDescriptor.create(namespaceName).build();

  long procId = procExec.submitProcedure(
    new ModifyNamespaceProcedure(procExec.getEnvironment(), nsd));
  // Wait the completion
  ProcedureTestingUtility.waitProcedure(procExec, procId);

  // Expect fail with NamespaceNotFoundException
  Procedure<?> result = procExec.getResult(procId);
  assertTrue(result.isFailed());
  LOG.debug("modify namespace failed with exception: " + result.getException());
  assertTrue(
    ProcedureTestingUtility.getExceptionCause(result) instanceof NamespaceNotFoundException);
}
项目:hbase    文件:TestDeleteNamespaceProcedure.java   
public static void validateNamespaceNotExist(final String nsName) throws IOException {
  try {
    NamespaceDescriptor nsDescriptor = UTIL.getAdmin().getNamespaceDescriptor(nsName);
    assertNull(nsDescriptor);
  } catch (NamespaceNotFoundException nsnfe) {
    // Expected
  }
}
项目:hbase    文件:HBaseAdmin.java   
@Override
public NamespaceDescriptor getNamespaceDescriptor(final String name)
    throws NamespaceNotFoundException, IOException {
  return executeCallable(new MasterCallable<NamespaceDescriptor>(getConnection(),
      getRpcControllerFactory()) {
    @Override
    protected NamespaceDescriptor rpcCall() throws Exception {
      return ProtobufUtil.toNamespaceDescriptor(
          master.getNamespaceDescriptor(getRpcController(),
              GetNamespaceDescriptorRequest.newBuilder().
                setNamespaceName(name).build()).getNamespaceDescriptor());
    }
  });
}
项目:hbase    文件:HelloHBase.java   
/**
 * Checks to see whether a namespace exists.
 *
 * @param admin Standard Admin object
 * @param namespaceName Name of namespace
 * @return true If namespace exists
 * @throws IOException If IO problem encountered
 */
static boolean namespaceExists(final Admin admin, final String namespaceName)
        throws IOException {
  try {
    admin.getNamespaceDescriptor(namespaceName);
  } catch (NamespaceNotFoundException e) {
    return false;
  }
  return true;
}
项目:hbase    文件:HelloHBase.java   
/**
 * Checks to see whether a namespace exists.
 *
 * @param admin Standard Admin object
 * @param namespaceName Name of namespace
 * @return true If namespace exists
 * @throws IOException If IO problem encountered
 */
static boolean namespaceExists(final Admin admin, final String namespaceName)
        throws IOException {
  try {
    admin.getNamespaceDescriptor(namespaceName);
  } catch (NamespaceNotFoundException e) {
    return false;
  }
  return true;
}
项目:PyroDB    文件:HMaster.java   
@Override
public NamespaceDescriptor getNamespaceDescriptor(String name) throws IOException {
  checkNamespaceManagerReady();
  NamespaceDescriptor nsd = tableNamespaceManager.get(name);
  if (nsd == null) {
    throw new NamespaceNotFoundException(name);
  }
  return nsd;
}
项目:PyroDB    文件:TableNamespaceManager.java   
public synchronized void update(NamespaceDescriptor ns) throws IOException {
  HTable table = getNamespaceTable();
  if (get(table, ns.getName()) == null) {
    throw new NamespaceNotFoundException(ns.getName());
  }
  upsert(table, ns);
}
项目:PyroDB    文件:TableNamespaceManager.java   
public synchronized void remove(String name) throws IOException {
  if (get(name) == null) {
    throw new NamespaceNotFoundException(name);
  }
  if (NamespaceDescriptor.RESERVED_NAMESPACES.contains(name)) {
    throw new ConstraintException("Reserved namespace "+name+" cannot be removed.");
  }
  int tableCount;
  try {
    tableCount = masterServices.listTableDescriptorsByNamespace(name).size();
  } catch (FileNotFoundException fnfe) {
    throw new NamespaceNotFoundException(name);
  }
  if (tableCount > 0) {
    throw new ConstraintException("Only empty namespaces can be removed. " +
        "Namespace "+name+" has "+tableCount+" tables");
  }
  Delete d = new Delete(Bytes.toBytes(name));
  getNamespaceTable().delete(d);
  //don't abort if cleanup isn't complete
  //it will be replaced on new namespace creation
  zkNamespaceManager.remove(name);
  FileSystem fs = masterServices.getMasterFileSystem().getFileSystem();
  for(FileStatus status :
          fs.listStatus(FSUtils.getNamespaceDir(
              masterServices.getMasterFileSystem().getRootDir(), name))) {
    if (!HConstants.HBASE_NON_TABLE_DIRS.contains(status.getPath().getName())) {
      throw new IOException("Namespace directory contains table dir: "+status.getPath());
    }
  }
  if (!fs.delete(FSUtils.getNamespaceDir(
      masterServices.getMasterFileSystem().getRootDir(), name), true)) {
    throw new IOException("Failed to remove namespace: "+name);
  }
}
项目:c5    文件:HMaster.java   
@Override
public NamespaceDescriptor getNamespaceDescriptor(String name) throws IOException {
  if (!isTableNamespaceManagerReady()) {
    throw new IOException("Table Namespace Manager not ready yet, try again later");
  }
  NamespaceDescriptor nsd = tableNamespaceManager.get(name);
  if (nsd == null) {
    throw new NamespaceNotFoundException(name);
  }
  return nsd;
}
项目:c5    文件:TableNamespaceManager.java   
public synchronized void update(NamespaceDescriptor ns) throws IOException {
  HTable table = getNamespaceTable();
  if (get(table, ns.getName()) == null) {
    throw new NamespaceNotFoundException(ns.getName());
  }
  upsert(table, ns);
}
项目:c5    文件:TableNamespaceManager.java   
public synchronized void remove(String name) throws IOException {
  if (get(name) == null) {
    throw new NamespaceNotFoundException(name);
  }
  if (NamespaceDescriptor.RESERVED_NAMESPACES.contains(name)) {
    throw new ConstraintException("Reserved namespace "+name+" cannot be removed.");
  }
  int tableCount;
  try {
    tableCount = masterServices.listTableDescriptorsByNamespace(name).size();
  } catch (FileNotFoundException fnfe) {
    throw new NamespaceNotFoundException(name);
  }
  if (tableCount > 0) {
    throw new ConstraintException("Only empty namespaces can be removed. " +
        "Namespace "+name+" has "+tableCount+" tables");
  }
  Delete d = new Delete(Bytes.toBytes(name));
  getNamespaceTable().delete(d);
  //don't abort if cleanup isn't complete
  //it will be replaced on new namespace creation
  zkNamespaceManager.remove(name);
  FileSystem fs = masterServices.getMasterFileSystem().getFileSystem();
  for(FileStatus status :
          fs.listStatus(FSUtils.getNamespaceDir(
              masterServices.getMasterFileSystem().getRootDir(), name))) {
    if (!HConstants.HBASE_NON_TABLE_DIRS.contains(status.getPath().getName())) {
      throw new IOException("Namespace directory contains table dir: "+status.getPath());
    }
  }
  if (!fs.delete(FSUtils.getNamespaceDir(
      masterServices.getMasterFileSystem().getRootDir(), name), true)) {
    throw new IOException("Failed to remove namespace: "+name);
  }
}
项目:ditb    文件:TestCloneSnapshotFromClient.java   
@Test(expected = NamespaceNotFoundException.class)
public void testCloneOnMissingNamespace() throws IOException, InterruptedException {
  TableName clonedTableName = TableName.valueOf("unknownNS:clonetb");
  admin.cloneSnapshot(snapshotName1, clonedTableName);
}
项目:pbase    文件:TestCloneSnapshotFromClient.java   
@Test(expected = NamespaceNotFoundException.class)
public void testCloneOnMissingNamespace() throws IOException, InterruptedException {
  TableName clonedTableName = TableName.valueOf("unknownNS:clonetb");
  admin.cloneSnapshot(snapshotName1, clonedTableName);
}
项目:HIndex    文件:TestCloneSnapshotFromClient.java   
@Test(expected = NamespaceNotFoundException.class)
public void testCloneOnMissingNamespace() throws IOException, InterruptedException {
  TableName clonedTableName = TableName.valueOf("unknownNS:clonetb");
  admin.cloneSnapshot(snapshotName1, clonedTableName);
}
项目:hbase    文件:ClusterSchemaServiceImpl.java   
@Override
public NamespaceDescriptor getNamespace(String name) throws IOException {
  NamespaceDescriptor nsd = getTableNamespaceManager().get(name);
  if (nsd == null) throw new NamespaceNotFoundException(name);
  return nsd;
}
项目:hbase    文件:TestAsyncNamespaceAdminApi.java   
@Test(timeout = 60000)
public void testNamespaceOperations() throws Exception {
  admin.createNamespace(NamespaceDescriptor.create(prefix + "ns1").build()).join();
  admin.createNamespace(NamespaceDescriptor.create(prefix + "ns2").build()).join();

  // create namespace that already exists
  runWithExpectedException(new Callable<Void>() {
    @Override
    public Void call() throws Exception {
      admin.createNamespace(NamespaceDescriptor.create(prefix + "ns1").build()).join();
      return null;
    }
  }, NamespaceExistException.class);

  // create a table in non-existing namespace
  runWithExpectedException(new Callable<Void>() {
    @Override
    public Void call() throws Exception {
      HTableDescriptor htd = new HTableDescriptor(TableName.valueOf("non_existing_namespace",
        "table1"));
      htd.addFamily(new HColumnDescriptor("family1"));
      admin.createTable(htd).join();
      return null;
    }
  }, NamespaceNotFoundException.class);

  // get descriptor for existing namespace
  NamespaceDescriptor ns1 = admin.getNamespaceDescriptor(prefix + "ns1").get();
  assertEquals(prefix + "ns1", ns1.getName());

  // get descriptor for non-existing namespace
  runWithExpectedException(new Callable<NamespaceDescriptor>() {
    @Override
    public NamespaceDescriptor call() throws Exception {
      return admin.getNamespaceDescriptor("non_existing_namespace").get();
    }
  }, NamespaceNotFoundException.class);

  // delete descriptor for existing namespace
  admin.deleteNamespace(prefix + "ns2").join();

  // delete descriptor for non-existing namespace
  runWithExpectedException(new Callable<Void>() {
    @Override
    public Void call() throws Exception {
      admin.deleteNamespace("non_existing_namespace").join();
      return null;
    }
  }, NamespaceNotFoundException.class);

  // modify namespace descriptor for existing namespace
  ns1 = admin.getNamespaceDescriptor(prefix + "ns1").get();
  ns1.setConfiguration("foo", "bar");
  admin.modifyNamespace(ns1).join();
  ns1 = admin.getNamespaceDescriptor(prefix + "ns1").get();
  assertEquals("bar", ns1.getConfigurationValue("foo"));

  // modify namespace descriptor for non-existing namespace
  runWithExpectedException(new Callable<Void>() {
    @Override
    public Void call() throws Exception {
      admin.modifyNamespace(NamespaceDescriptor.create("non_existing_namespace").build()).join();
      return null;
    }
  }, NamespaceNotFoundException.class);

  admin.deleteNamespace(prefix + "ns1").join();
}
项目:hbase    文件:TestCloneSnapshotFromClient.java   
@Test(expected = NamespaceNotFoundException.class)
public void testCloneOnMissingNamespace() throws IOException, InterruptedException {
  final TableName clonedTableName = TableName.valueOf("unknownNS:" + name.getMethodName());
  admin.cloneSnapshot(snapshotName1, clonedTableName);
}
项目:PyroDB    文件:TestCloneSnapshotFromClient.java   
@Test(expected = NamespaceNotFoundException.class)
public void testCloneOnMissingNamespace() throws IOException, InterruptedException {
  TableName clonedTableName = TableName.valueOf("unknownNS:clonetb");
  admin.cloneSnapshot(snapshotName1, clonedTableName);
}
项目:hbase    文件:Admin.java   
/**
 * Get a namespace descriptor by name.
 *
 * @param name name of namespace descriptor
 * @return A descriptor
 * @throws org.apache.hadoop.hbase.NamespaceNotFoundException
 * @throws IOException if a remote or network exception occurs
 */
NamespaceDescriptor getNamespaceDescriptor(String name)
throws NamespaceNotFoundException, IOException;