Search in sources :

Example 1 with NamespaceId

use of org.apache.accumulo.core.data.NamespaceId in project accumulo by apache.

the class DeleteNamespaceCommand method doTableOp.

protected void doTableOp(final Shell shellState, final String namespace, boolean force) throws Exception {
    boolean resetContext = false;
    String currentTable = shellState.getTableName();
    NamespaceId 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("");
    }
}
Also used : NamespaceId(org.apache.accumulo.core.data.NamespaceId)

Example 2 with NamespaceId

use of org.apache.accumulo.core.data.NamespaceId in project accumulo by apache.

the class RenameNamespaceCommand method execute.

@Override
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException, TableNotFoundException, TableExistsException, NamespaceNotFoundException, NamespaceExistsException {
    String old = cl.getArgs()[0];
    String newer = cl.getArgs()[1];
    boolean resetContext = false;
    TableId currentTableId = null;
    if (shellState.getTableName() != null && !shellState.getTableName().isEmpty()) {
        NamespaceId namespaceId = Namespaces.getNamespaceId(shellState.getContext(), old);
        List<TableId> tableIds = Namespaces.getTableIds(shellState.getContext(), namespaceId);
        currentTableId = shellState.getContext().getTableId(shellState.getTableName());
        resetContext = tableIds.contains(currentTableId);
    }
    shellState.getAccumuloClient().namespaceOperations().rename(old, newer);
    if (resetContext) {
        shellState.setTableName(shellState.getContext().getTableName(currentTableId));
    }
    return 0;
}
Also used : TableId(org.apache.accumulo.core.data.TableId) NamespaceId(org.apache.accumulo.core.data.NamespaceId)

Example 3 with NamespaceId

use of org.apache.accumulo.core.data.NamespaceId in project accumulo by apache.

the class ClientServiceHandler method getNamespaceConfiguration.

@Override
public Map<String, String> getNamespaceConfiguration(TInfo tinfo, TCredentials credentials, String ns) throws ThriftTableOperationException, TException {
    NamespaceId namespaceId;
    try {
        namespaceId = Namespaces.getNamespaceId(context, ns);
    } catch (NamespaceNotFoundException e) {
        String why = "Could not find namespace while getting configuration.";
        throw new ThriftTableOperationException(null, ns, null, TableOperationExceptionType.NAMESPACE_NOTFOUND, why);
    }
    AccumuloConfiguration config = context.getNamespaceConfiguration(namespaceId);
    return conf(credentials, config);
}
Also used : ThriftTableOperationException(org.apache.accumulo.core.clientImpl.thrift.ThriftTableOperationException) NamespaceId(org.apache.accumulo.core.data.NamespaceId) NamespaceNotFoundException(org.apache.accumulo.core.client.NamespaceNotFoundException) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration)

Example 4 with NamespaceId

use of org.apache.accumulo.core.data.NamespaceId in project accumulo by apache.

the class ClientServiceHandler method revokeTablePermission.

@Override
public void revokeTablePermission(TInfo tinfo, TCredentials credentials, String user, String tableName, byte permission) throws TException {
    TableId tableId = checkTableId(context, tableName, TableOperation.PERMISSION);
    NamespaceId namespaceId;
    try {
        namespaceId = context.getNamespaceId(tableId);
    } catch (TableNotFoundException e) {
        throw new TException(e);
    }
    security.revokeTablePermission(credentials, user, tableId, TablePermission.getPermissionById(permission), namespaceId);
}
Also used : TableId(org.apache.accumulo.core.data.TableId) TException(org.apache.thrift.TException) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) NamespaceId(org.apache.accumulo.core.data.NamespaceId)

Example 5 with NamespaceId

use of org.apache.accumulo.core.data.NamespaceId in project accumulo by apache.

the class ClientServiceHandler method grantNamespacePermission.

@Override
public void grantNamespacePermission(TInfo tinfo, TCredentials credentials, String user, String ns, byte permission) throws ThriftSecurityException, ThriftTableOperationException {
    NamespaceId namespaceId = checkNamespaceId(context, ns, TableOperation.PERMISSION);
    security.grantNamespacePermission(credentials, user, namespaceId, NamespacePermission.getPermissionById(permission));
}
Also used : NamespaceId(org.apache.accumulo.core.data.NamespaceId)

Aggregations

NamespaceId (org.apache.accumulo.core.data.NamespaceId)32 TableId (org.apache.accumulo.core.data.TableId)20 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)16 ThriftTableOperationException (org.apache.accumulo.core.clientImpl.thrift.ThriftTableOperationException)12 ThriftSecurityException (org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException)11 TException (org.apache.thrift.TException)9 IOException (java.io.IOException)7 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)7 HashSet (java.util.HashSet)6 NamespaceNotFoundException (org.apache.accumulo.core.client.NamespaceNotFoundException)5 KeyExtent (org.apache.accumulo.core.dataImpl.KeyExtent)5 TKeyExtent (org.apache.accumulo.core.dataImpl.thrift.TKeyExtent)5 NoNodeException (org.apache.zookeeper.KeeperException.NoNodeException)5 ByteBuffer (java.nio.ByteBuffer)4 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 TreeSet (java.util.TreeSet)4 Authorizations (org.apache.accumulo.core.security.Authorizations)4 NotServingTabletException (org.apache.accumulo.core.tabletserver.thrift.NotServingTabletException)4 ZooReaderWriter (org.apache.accumulo.fate.zookeeper.ZooReaderWriter)4