use of org.apache.accumulo.core.clientImpl.thrift.ThriftTableOperationException in project accumulo by apache.
the class ThriftClientHandler method startGetSummaries.
@Override
public TSummaries startGetSummaries(TInfo tinfo, TCredentials credentials, TSummaryRequest request) throws ThriftSecurityException, ThriftTableOperationException, TException {
NamespaceId namespaceId;
TableId tableId = TableId.of(request.getTableId());
try {
namespaceId = server.getContext().getNamespaceId(tableId);
} catch (TableNotFoundException e1) {
throw new ThriftTableOperationException(tableId.canonical(), null, null, TableOperationExceptionType.NOTFOUND, null);
}
if (!security.canGetSummaries(credentials, tableId, namespaceId)) {
throw new AccumuloSecurityException(credentials.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED).asThriftException();
}
ExecutorService es = server.resourceManager.getSummaryPartitionExecutor();
Future<SummaryCollection> future = new Gatherer(server.getContext(), request, context.getTableConfiguration(tableId), context.getCryptoService()).gather(es);
return startSummaryOperation(credentials, future);
}
use of org.apache.accumulo.core.clientImpl.thrift.ThriftTableOperationException in project accumulo by apache.
the class ClientServiceHandler method checkNamespaceClass.
@Override
public boolean checkNamespaceClass(TInfo tinfo, TCredentials credentials, String ns, String className, String interfaceMatch) throws TException, ThriftTableOperationException, ThriftSecurityException {
security.authenticateUser(credentials, credentials);
NamespaceId namespaceId = checkNamespaceId(context, ns, null);
ClassLoader loader = getClass().getClassLoader();
Class<?> shouldMatch;
try {
shouldMatch = loader.loadClass(interfaceMatch);
AccumuloConfiguration conf = context.getNamespaceConfiguration(namespaceId);
String context = ClassLoaderUtil.tableContext(conf);
Class<?> test = ClassLoaderUtil.loadClass(context, className, shouldMatch);
test.getDeclaredConstructor().newInstance();
return true;
} catch (Exception e) {
log.warn("Error checking object types", e);
return false;
}
}
use of org.apache.accumulo.core.clientImpl.thrift.ThriftTableOperationException in project accumulo by apache.
the class ClientServiceHandler method checkNamespaceId.
public static NamespaceId checkNamespaceId(ClientContext context, String namespaceName, TableOperation operation) throws ThriftTableOperationException {
NamespaceId namespaceId = Namespaces.lookupNamespaceId(context, namespaceName);
if (namespaceId == null) {
// maybe the namespace exists, but the cache was not updated yet... so try to clear the cache
// and check again
context.clearTableListCache();
namespaceId = Namespaces.lookupNamespaceId(context, namespaceName);
if (namespaceId == null)
throw new ThriftTableOperationException(null, namespaceName, operation, TableOperationExceptionType.NAMESPACE_NOTFOUND, null);
}
return namespaceId;
}
use of org.apache.accumulo.core.clientImpl.thrift.ThriftTableOperationException in project accumulo by apache.
the class ClientServiceHandler method bulkImportFiles.
@Override
public List<String> bulkImportFiles(TInfo tinfo, final TCredentials credentials, final long tid, final String tableId, final List<String> files, final String errorDir, final boolean setTime) throws ThriftSecurityException, ThriftTableOperationException, TException {
try {
if (!security.canPerformSystemActions(credentials))
throw new AccumuloSecurityException(credentials.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED);
bulkImportStatus.updateBulkImportStatus(files, BulkImportState.INITIAL);
log.debug("Got request to bulk import files to table({}): {}", tableId, files);
bulkImportStatus.updateBulkImportStatus(files, BulkImportState.PROCESSING);
try {
return BulkImporter.bulkLoad(context, tid, tableId, files, setTime);
} finally {
bulkImportStatus.removeBulkImportStatus(files);
}
} catch (AccumuloSecurityException e) {
throw e.asThriftException();
} catch (Exception ex) {
throw new TException(ex);
}
}
use of org.apache.accumulo.core.clientImpl.thrift.ThriftTableOperationException 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