Search in sources :

Example 31 with NamespaceId

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

the class ClientServiceHandler method getDiskUsage.

@Override
public List<TDiskUsage> getDiskUsage(Set<String> tables, TCredentials credentials) throws ThriftTableOperationException, ThriftSecurityException, TException {
    try {
        HashSet<TableId> tableIds = new HashSet<>();
        for (String table : tables) {
            // ensure that table table exists
            TableId tableId = checkTableId(context, table, null);
            tableIds.add(tableId);
            NamespaceId namespaceId = context.getNamespaceId(tableId);
            if (!security.canScan(credentials, tableId, namespaceId))
                throw new ThriftSecurityException(credentials.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED);
        }
        // use the same set of tableIds that were validated above to avoid race conditions
        Map<TreeSet<String>, Long> diskUsage = TableDiskUsage.getDiskUsage(tableIds, context.getVolumeManager(), context);
        List<TDiskUsage> retUsages = new ArrayList<>();
        for (Map.Entry<TreeSet<String>, Long> usageItem : diskUsage.entrySet()) {
            retUsages.add(new TDiskUsage(new ArrayList<>(usageItem.getKey()), usageItem.getValue()));
        }
        return retUsages;
    } catch (TableNotFoundException | IOException e) {
        throw new TException(e);
    }
}
Also used : TableId(org.apache.accumulo.core.data.TableId) TException(org.apache.thrift.TException) ArrayList(java.util.ArrayList) IOException(java.io.IOException) ThriftSecurityException(org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) TreeSet(java.util.TreeSet) TDiskUsage(org.apache.accumulo.core.clientImpl.thrift.TDiskUsage) NamespaceId(org.apache.accumulo.core.data.NamespaceId) Map(java.util.Map) HashMap(java.util.HashMap) HashSet(java.util.HashSet)

Example 32 with NamespaceId

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

the class Compactor method cancel.

@Override
public void cancel(TInfo tinfo, TCredentials credentials, String externalCompactionId) throws TException {
    TableId tableId = JOB_HOLDER.getTableId();
    try {
        NamespaceId nsId = getContext().getNamespaceId(tableId);
        if (!security.canCompact(credentials, tableId, nsId)) {
            throw new AccumuloSecurityException(credentials.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED).asThriftException();
        }
    } catch (TableNotFoundException e) {
        throw new ThriftTableOperationException(tableId.canonical(), null, TableOperation.COMPACT_CANCEL, TableOperationExceptionType.NOTFOUND, e.getMessage());
    }
    cancel(externalCompactionId);
}
Also used : TableId(org.apache.accumulo.core.data.TableId) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) ThriftTableOperationException(org.apache.accumulo.core.clientImpl.thrift.ThriftTableOperationException) 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