protected void doTableOp(final Shell shellState, final String namespace, boolean force) throws Exception { boolean resetContext = false; String currentTable = shellState.getTableName(); Namespace.ID namespaceId = Namespaces.getNamespaceId(shellState.getContext(), namespace); List<String> tables = Namespaces.getTableNames(shellState.getContext(), namespaceId); resetContext = tables.contains(currentTable); if (force) for (String table : shellState.getAccumuloClient().tableOperations().list()) if (table.startsWith(namespace + ".")) shellState.getAccumuloClient().tableOperations().delete(table); shellState.getAccumuloClient().namespaceOperations().delete(namespace); if (resetContext) { shellState.setTableName(""); } }
@Test(expected = AccumuloSecurityException.class) public void deleteAccumuloNamespace() throws Exception { c.namespaceOperations().delete(Namespaces.ACCUMULO_NAMESPACE); // should fail }
@Test(expected = AccumuloSecurityException.class) public void deleteDefaultNamespace() throws Exception { c.namespaceOperations().delete(Namespaces.DEFAULT_NAMESPACE); // should fail }
@Override public void visit(State state, Environment env, Properties props) throws Exception { Connector conn = env.getConnector(); Random rand = (Random) state.get("rand"); @SuppressWarnings("unchecked") List<String> namespaces = (List<String>) state.get("namespaces"); String namespace = namespaces.get(rand.nextInt(namespaces.size())); try { conn.namespaceOperations().delete(namespace); log.debug("Deleted namespace " + namespace); } catch (NamespaceNotFoundException e) { log.debug("Delete namespace " + namespace + " failed, doesnt exist"); } catch (NamespaceNotEmptyException e) { log.debug("Delete namespace " + namespace + " failed, not empty"); } } }
assertNotNull(map.get(namespace)); c.namespaceOperations().delete(namespace); namespaces = c.namespaceOperations().list(); map = c.namespaceOperations().namespaceIdMap();
@After public void swingMjölnir() throws Exception { if (null == c) { return; } // clean up any added tables, namespaces, and users, after each test for (String t : c.tableOperations().list()) if (!Tables.qualify(t).getFirst().equals(Namespaces.ACCUMULO_NAMESPACE)) c.tableOperations().delete(t); assertEquals(3, c.tableOperations().list().size()); for (String n : c.namespaceOperations().list()) if (!n.equals(Namespaces.ACCUMULO_NAMESPACE) && !n.equals(Namespaces.DEFAULT_NAMESPACE)) c.namespaceOperations().delete(n); assertEquals(2, c.namespaceOperations().list().size()); for (String u : c.securityOperations().listLocalUsers()) if (!getAdminPrincipal().equals(u)) c.securityOperations().dropLocalUser(u); assertEquals(1, c.securityOperations().listLocalUsers().size()); }
@Override public void deleteNamespace(ByteBuffer login, String namespaceName) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.NamespaceNotFoundException, org.apache.accumulo.proxy.thrift.NamespaceNotEmptyException, TException { try { getConnector(login).namespaceOperations().delete(namespaceName); } catch (NamespaceNotFoundException e) { throw new org.apache.accumulo.proxy.thrift.NamespaceNotFoundException(e.toString()); } catch (NamespaceNotEmptyException e) { throw new org.apache.accumulo.proxy.thrift.NamespaceNotEmptyException(e.toString()); } catch (Exception e) { handleException(e); } }
protected void doTableOp(final Shell shellState, final String namespace, boolean force) throws Exception { boolean resetContext = false; String currentTable = shellState.getTableName(); if (!Namespaces.getNameToIdMap(shellState.getInstance()).containsKey(namespace)) { throw new NamespaceNotFoundException(null, namespace, null); } String namespaceId = Namespaces.getNamespaceId(shellState.getInstance(), namespace); List<String> tables = Namespaces.getTableNames(shellState.getInstance(), namespaceId); resetContext = tables.contains(currentTable); if (force) for (String table : shellState.getConnector().tableOperations().list()) if (table.startsWith(namespace + ".")) shellState.getConnector().tableOperations().delete(table); shellState.getConnector().namespaceOperations().delete(namespace); if (resetContext) { shellState.setTableName(""); } }
log.debug("Dropping namespace: " + secNamespaceName); conn.namespaceOperations().delete(secNamespaceName);
NamespacePermission.READ)); c.namespaceOperations().delete(namespace);
@Test(expected = NamespaceNotEmptyException.class) public void deleteNonEmptyNamespace() throws Exception { String tableName1 = namespace + ".1"; assertFalse(c.namespaceOperations().exists(namespace)); assertFalse(c.tableOperations().exists(tableName1)); c.namespaceOperations().create(namespace); c.tableOperations().create(tableName1); assertTrue(c.namespaceOperations().exists(namespace)); assertTrue(c.tableOperations().exists(tableName1)); c.namespaceOperations().delete(namespace); // should fail }
break; case 3: ops.delete(namespace); fail(); break;
root_conn.namespaceOperations().create(namespace); loginAs(testUser); test_user_conn.namespaceOperations().delete(namespace); loginAs(rootUser); if (root_conn.namespaceOperations().list().contains(namespace))
try { loginAs(testUser); test_user_conn.namespaceOperations().delete(namespace); throw new IllegalStateException("Should NOT be able to delete a namespace"); } catch (AccumuloSecurityException e) {
assertFalse(c.tableOperations().exists(t2)); try { c.namespaceOperations().delete(namespace); } catch (NamespaceNotFoundException e) {} try { assertFalse(c.tableOperations().exists(t1)); assertFalse(c.tableOperations().exists(t2)); c.namespaceOperations().delete(namespace); assertFalse(c.namespaceOperations().exists(namespace)); assertFalse(c.tableOperations().exists(t1));
loginAs(user1); try { user1Con.namespaceOperations().delete(n2); fail(); } catch (AccumuloSecurityException e) { c.securityOperations().grantSystemPermission(u1, SystemPermission.DROP_NAMESPACE); loginAs(user1); user1Con.namespaceOperations().delete(n2); loginAs(root); c.securityOperations().revokeSystemPermission(u1, SystemPermission.DROP_NAMESPACE);
c.tableOperations().delete(t2); c.tableOperations().delete(t0); c.namespaceOperations().delete(namespace);