org.apache.hadoop.hbase.NamespaceNotFoundException Java Examples
The following examples show how to use
org.apache.hadoop.hbase.NamespaceNotFoundException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ModifyNamespaceProcedure.java From hbase with Apache License 2.0 | 6 votes |
/** * Action before any real action of adding namespace. */ private boolean prepareModify(final MasterProcedureEnv env) throws IOException { if (!getTableNamespaceManager(env).doesNamespaceExist(newNsDescriptor.getName())) { setFailure("master-modify-namespace", new NamespaceNotFoundException(newNsDescriptor.getName())); return false; } getTableNamespaceManager(env).validateTableAndRegionCount(newNsDescriptor); // This is used for rollback oldNsDescriptor = getTableNamespaceManager(env).get(newNsDescriptor.getName()); if (!Objects.equals( oldNsDescriptor.getConfigurationValue(RSGroupInfo.NAMESPACE_DESC_PROP_GROUP), newNsDescriptor.getConfigurationValue(RSGroupInfo.NAMESPACE_DESC_PROP_GROUP))) { checkNamespaceRSGroup(env, newNsDescriptor); } return true; }
Example #2
Source File: TestCreateNamespaceProcedure.java From hbase with Apache License 2.0 | 6 votes |
@Test 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 lastStep = 2; // failing before CREATE_NAMESPACE_CREATE_DIRECTORY MasterProcedureTestingUtility.testRollbackAndDoubleExecution(procExec, procId, lastStep); // 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."); } }
Example #3
Source File: TestDeleteNamespaceProcedure.java From hbase with Apache License 2.0 | 6 votes |
@Test 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); }
Example #4
Source File: ThriftAdmin.java From hbase with Apache License 2.0 | 5 votes |
@Override public NamespaceDescriptor getNamespaceDescriptor(String name) throws NamespaceNotFoundException, IOException { try { TNamespaceDescriptor tNamespaceDescriptor = client.getNamespaceDescriptor(name); return ThriftUtilities.namespaceDescriptorFromThrift(tNamespaceDescriptor); } catch (TException e) { throw new IOException(e); } }
Example #5
Source File: DeleteNamespaceProcedure.java From hbase with Apache License 2.0 | 5 votes |
/** * Action before any real action of deleting namespace. * @param env MasterProcedureEnv */ private boolean prepareDelete(final MasterProcedureEnv env) throws IOException { if (getTableNamespaceManager(env).doesNamespaceExist(namespaceName) == false) { setFailure("master-delete-namespace", new NamespaceNotFoundException(namespaceName)); return false; } if (NamespaceDescriptor.RESERVED_NAMESPACES.contains(namespaceName)) { setFailure("master-delete-namespace", new ConstraintException("Reserved namespace " + namespaceName + " cannot be removed.")); return false; } int tableCount = 0; try { tableCount = env.getMasterServices().listTableDescriptorsByNamespace(namespaceName).size(); } catch (FileNotFoundException fnfe) { setFailure("master-delete-namespace", new NamespaceNotFoundException(namespaceName)); return false; } if (tableCount > 0) { setFailure("master-delete-namespace", new ConstraintException("Only empty namespaces can be removed. Namespace " + namespaceName + " has " + tableCount + " tables")); return false; } // This is used for rollback nsDescriptor = getTableNamespaceManager(env).get(namespaceName); return true; }
Example #6
Source File: TestModifyNamespaceProcedure.java From hbase with Apache License 2.0 | 5 votes |
@Test 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); }
Example #7
Source File: TestDeleteNamespaceProcedure.java From hbase with Apache License 2.0 | 5 votes |
public static void validateNamespaceNotExist(final String nsName) throws IOException { try { NamespaceDescriptor nsDescriptor = UTIL.getAdmin().getNamespaceDescriptor(nsName); assertNull(nsDescriptor); } catch (NamespaceNotFoundException nsnfe) { // Expected } }
Example #8
Source File: HelloHBase.java From hbase with Apache License 2.0 | 5 votes |
/** * 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; }
Example #9
Source File: HelloHBase.java From hbase with Apache License 2.0 | 5 votes |
/** * 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; }
Example #10
Source File: SystemCatalogCreationOnConnectionIT.java From phoenix with Apache License 2.0 | 5 votes |
private boolean isSystemNamespaceCreated() throws IOException { try { testUtil.getAdmin().getNamespaceDescriptor(SYSTEM_CATALOG_SCHEMA); } catch (NamespaceNotFoundException ex) { return false; } return true; }
Example #11
Source File: ClusterSchemaServiceImpl.java From hbase with Apache License 2.0 | 4 votes |
@Override public NamespaceDescriptor getNamespace(String name) throws IOException { NamespaceDescriptor nsd = getTableNamespaceManager().get(name); if (nsd == null) throw new NamespaceNotFoundException(name); return nsd; }
Example #12
Source File: TestAsyncNamespaceAdminApi.java From hbase with Apache License 2.0 | 4 votes |
@Test 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 { TableDescriptorBuilder tableDescriptorBuilder = TableDescriptorBuilder.newBuilder(TableName.valueOf("non_existing_namespace", "table1")); ColumnFamilyDescriptor columnFamilyDescriptor = ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes("family1")).build(); tableDescriptorBuilder.setColumnFamily(columnFamilyDescriptor); admin.createTable(tableDescriptorBuilder.build()).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(); }
Example #13
Source File: CloneSnapshotFromClientErrorTestBase.java From hbase with Apache License 2.0 | 4 votes |
@Test(expected = NamespaceNotFoundException.class) public void testCloneOnMissingNamespace() throws IOException, InterruptedException { final TableName clonedTableName = TableName.valueOf("unknownNS:" + getValidMethodName()); admin.cloneSnapshot(snapshotName1, clonedTableName); }
Example #14
Source File: VerifyingRSGroupAdmin.java From hbase with Apache License 2.0 | 4 votes |
public NamespaceDescriptor getNamespaceDescriptor(String name) throws NamespaceNotFoundException, IOException { return admin.getNamespaceDescriptor(name); }
Example #15
Source File: AdminOverAsyncAdmin.java From hbase with Apache License 2.0 | 4 votes |
@Override public NamespaceDescriptor getNamespaceDescriptor(String name) throws NamespaceNotFoundException, IOException { return get(admin.getNamespaceDescriptor(name)); }
Example #16
Source File: Admin.java From hbase with Apache License 2.0 | 2 votes |
/** * 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;