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);
}
}
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);
}
Aggregations