private Namespace.ID getNamespaceId(TCredentials credentials, Table.ID tableId) throws ThriftSecurityException { try { return Tables.getNamespaceId(context, tableId); } catch (TableNotFoundException e1) { throw new ThriftSecurityException(credentials.getPrincipal(), SecurityErrorCode.TABLE_DOESNT_EXIST); } }
public NamespaceConfiguration getNamespaceConfigurationForTable(Table.ID tableId) { NamespaceConfiguration conf; synchronized (tableParentConfigs) { conf = tableParentConfigs.get(instanceID).get(tableId); } // can't hold the lock during the construction and validation of the config, // which may result in creating multiple objects for the same id, but that's ok. if (conf == null) { Namespace.ID namespaceId; try { namespaceId = Tables.getNamespaceId(context, tableId); } catch (TableNotFoundException e) { throw new RuntimeException(e); } conf = new NamespaceConfiguration(namespaceId, context, getSystemConfiguration()); ConfigSanityCheck.validate(conf); synchronized (tableParentConfigs) { tableParentConfigs.get(instanceID).put(tableId, conf); } } return conf; }
@Override public List<TDiskUsage> getDiskUsage(Set<String> tables, TCredentials credentials) throws ThriftTableOperationException, ThriftSecurityException, TException { try { HashSet<Table.ID> tableIds = new HashSet<>(); for (String table : tables) { // ensure that table table exists Table.ID tableId = checkTableId(context, table, null); tableIds.add(tableId); Namespace.ID namespaceId = Tables.getNamespaceId(context, 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, fs, 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); } }
private Namespace.ID getNamespaceIdFromTableId(TableOperation tableOp, Table.ID tableId) throws ThriftTableOperationException { Namespace.ID namespaceId; try { namespaceId = Tables.getNamespaceId(master.getContext(), tableId); } catch (TableNotFoundException e) { throw new ThriftTableOperationException(tableId.canonicalID(), null, tableOp, TableOperationExceptionType.NOTFOUND, e.getMessage()); } return namespaceId; }
private Namespace.ID getNamespaceIdFromTableId(TableOperation tableOp, Table.ID tableId) throws ThriftTableOperationException { Namespace.ID namespaceId; try { namespaceId = Tables.getNamespaceId(master.getContext(), tableId); } catch (TableNotFoundException e) { throw new ThriftTableOperationException(tableId.canonicalID(), null, tableOp, TableOperationExceptionType.NOTFOUND, e.getMessage()); } return namespaceId; }
@Override public void revokeTablePermission(TInfo tinfo, TCredentials credentials, String user, String tableName, byte permission) throws TException { Table.ID tableId = checkTableId(context, tableName, TableOperation.PERMISSION); Namespace.ID namespaceId; try { namespaceId = Tables.getNamespaceId(context, tableId); } catch (TableNotFoundException e) { throw new TException(e); } security.revokeTablePermission(credentials, user, tableId, TablePermission.getPermissionById(permission), namespaceId); }
@Override public void grantTablePermission(TInfo tinfo, TCredentials credentials, String user, String tableName, byte permission) throws TException { Table.ID tableId = checkTableId(context, tableName, TableOperation.PERMISSION); Namespace.ID namespaceId; try { namespaceId = Tables.getNamespaceId(context, tableId); } catch (TableNotFoundException e) { throw new TException(e); } security.grantTablePermission(credentials, user, tableId, TablePermission.getPermissionById(permission), namespaceId); }
tableId = keyExtent.getTableId(); if (sameTable || security.canWrite(us.getCredentials(), tableId, Tables.getNamespaceId(context, tableId))) { long t2 = System.currentTimeMillis(); us.authTimes.addStat(t2 - t1);
String n = Namespaces.getNamespaceName(shellState.getContext(), Tables.getNamespaceId( shellState.getContext(), Tables.getTableId(shellState.getContext(), tableName))); for (Entry<String,String> e : shellState.getAccumuloClient().namespaceOperations()
Namespace.ID namespaceId; try { namespaceId = Tables.getNamespaceId(context, tableId); } catch (TableNotFoundException e1) { throw new NotServingTabletException(textent);
@Override public TSummaries startGetSummaries(TInfo tinfo, TCredentials credentials, TSummaryRequest request) throws ThriftSecurityException, ThriftTableOperationException, TException { Namespace.ID namespaceId; Table.ID tableId = Table.ID.of(request.getTableId()); try { namespaceId = Tables.getNamespaceId(context, tableId); } catch (TableNotFoundException e1) { throw new ThriftTableOperationException(tableId.canonicalID(), null, null, TableOperationExceptionType.NOTFOUND, null); } if (!security.canGetSummaries(credentials, tableId, namespaceId)) { throw new AccumuloSecurityException(credentials.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED).asThriftException(); } ServerConfigurationFactory factory = context.getServerConfFactory(); ExecutorService es = resourceManager.getSummaryPartitionExecutor(); Future<SummaryCollection> future = new Gatherer(context, request, factory.getTableConfiguration(tableId), context.getCryptoService()).gather(es); return startSummaryOperation(credentials, future); }