use of org.apache.accumulo.core.data.TableId in project accumulo by apache.
the class ClientServiceHandler method grantTablePermission.
@Override
public void grantTablePermission(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.grantTablePermission(credentials, user, tableId, TablePermission.getPermissionById(permission), namespaceId);
}
use of org.apache.accumulo.core.data.TableId 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.TableId in project accumulo by apache.
the class TableConfiguration method createCompactionDispatcher.
private static CompactionDispatcher createCompactionDispatcher(AccumuloConfiguration conf, ServerContext context, TableId tableId) {
CompactionDispatcher newDispatcher = Property.createTableInstanceFromPropertyName(conf, Property.TABLE_COMPACTION_DISPATCHER, CompactionDispatcher.class, null);
Map<String, String> opts = conf.getAllPropertiesWithPrefixStripped(Property.TABLE_COMPACTION_DISPATCHER_OPTS);
newDispatcher.init(new CompactionDispatcher.InitParameters() {
private final ServiceEnvironment senv = new ServiceEnvironmentImpl(context);
@Override
public TableId getTableId() {
return tableId;
}
@Override
public Map<String, String> getOptions() {
return opts;
}
@Override
public ServiceEnvironment getServiceEnv() {
return senv;
}
});
return newDispatcher;
}
use of org.apache.accumulo.core.data.TableId in project accumulo by apache.
the class TableConfiguration method createScanDispatcher.
private static ScanDispatcher createScanDispatcher(AccumuloConfiguration conf, ServerContext context, TableId tableId) {
ScanDispatcher newDispatcher = Property.createTableInstanceFromPropertyName(conf, Property.TABLE_SCAN_DISPATCHER, ScanDispatcher.class, null);
Map<String, String> opts = conf.getAllPropertiesWithPrefixStripped(Property.TABLE_SCAN_DISPATCHER_OPTS);
newDispatcher.init(new ScanDispatcher.InitParameters() {
private final ServiceEnvironment senv = new ServiceEnvironmentImpl(context);
@Override
public TableId getTableId() {
return tableId;
}
@Override
public Map<String, String> getOptions() {
return opts;
}
@Override
public ServiceEnvironment getServiceEnv() {
return senv;
}
});
return newDispatcher;
}
use of org.apache.accumulo.core.data.TableId in project accumulo by apache.
the class CheckForMetadataProblems method checkMetadataAndRootTableEntries.
private static void checkMetadataAndRootTableEntries(String tableNameToCheck, ServerUtilOpts opts) throws Exception {
TableId tableCheckId = opts.getServerContext().getTableId(tableNameToCheck);
System.out.println("Checking tables whose metadata is found in: " + tableNameToCheck + " (" + tableCheckId + ")");
Map<TableId, TreeSet<KeyExtent>> tables = new HashMap<>();
try (AccumuloClient client = Accumulo.newClient().from(opts.getClientProps()).build();
Scanner scanner = client.createScanner(tableNameToCheck, Authorizations.EMPTY)) {
scanner.setRange(TabletsSection.getRange());
TabletColumnFamily.PREV_ROW_COLUMN.fetch(scanner);
scanner.fetchColumnFamily(CurrentLocationColumnFamily.NAME);
Text colf = new Text();
Text colq = new Text();
boolean justLoc = false;
int count = 0;
for (Entry<Key, Value> entry : scanner) {
colf = entry.getKey().getColumnFamily(colf);
colq = entry.getKey().getColumnQualifier(colq);
count++;
TableId tableId = KeyExtent.fromMetaRow(entry.getKey().getRow()).tableId();
TreeSet<KeyExtent> tablets = tables.get(tableId);
if (tablets == null) {
tables.forEach(CheckForMetadataProblems::checkTable);
tables.clear();
tablets = new TreeSet<>();
tables.put(tableId, tablets);
}
if (TabletColumnFamily.PREV_ROW_COLUMN.equals(colf, colq)) {
KeyExtent tabletKe = KeyExtent.fromMetaPrevRow(entry);
tablets.add(tabletKe);
justLoc = false;
} else if (colf.equals(CurrentLocationColumnFamily.NAME)) {
if (justLoc) {
System.out.println("Problem at key " + entry.getKey());
sawProblems = true;
}
justLoc = true;
}
}
if (count == 0) {
System.err.println("ERROR : table " + tableNameToCheck + " (" + tableCheckId + ") is empty");
sawProblems = true;
}
}
tables.forEach(CheckForMetadataProblems::checkTable);
if (!sawProblems) {
System.out.println("No problems found in " + tableNameToCheck + " (" + tableCheckId + ")");
}
// end METADATA table sanity check
}
Aggregations