Search in sources :

Example 11 with ThriftTableOperationException

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);
}
Also used : TableId(org.apache.accumulo.core.data.TableId) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) Gatherer(org.apache.accumulo.core.summary.Gatherer) ExecutorService(java.util.concurrent.ExecutorService) ThriftTableOperationException(org.apache.accumulo.core.clientImpl.thrift.ThriftTableOperationException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) NamespaceId(org.apache.accumulo.core.data.NamespaceId) SummaryCollection(org.apache.accumulo.core.summary.SummaryCollection)

Example 12 with ThriftTableOperationException

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;
    }
}
Also used : NamespaceId(org.apache.accumulo.core.data.NamespaceId) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) NamespaceNotFoundException(org.apache.accumulo.core.client.NamespaceNotFoundException) ThriftSecurityException(org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) TException(org.apache.thrift.TException) IOException(java.io.IOException) ThriftTableOperationException(org.apache.accumulo.core.clientImpl.thrift.ThriftTableOperationException) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration)

Example 13 with ThriftTableOperationException

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;
}
Also used : ThriftTableOperationException(org.apache.accumulo.core.clientImpl.thrift.ThriftTableOperationException) NamespaceId(org.apache.accumulo.core.data.NamespaceId)

Example 14 with ThriftTableOperationException

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);
    }
}
Also used : TException(org.apache.thrift.TException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) NamespaceNotFoundException(org.apache.accumulo.core.client.NamespaceNotFoundException) ThriftSecurityException(org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) TException(org.apache.thrift.TException) IOException(java.io.IOException) ThriftTableOperationException(org.apache.accumulo.core.clientImpl.thrift.ThriftTableOperationException)

Example 15 with ThriftTableOperationException

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

ThriftTableOperationException (org.apache.accumulo.core.clientImpl.thrift.ThriftTableOperationException)20 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)16 ThriftSecurityException (org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException)14 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)13 NamespaceNotFoundException (org.apache.accumulo.core.client.NamespaceNotFoundException)12 NamespaceId (org.apache.accumulo.core.data.NamespaceId)10 TException (org.apache.thrift.TException)10 IOException (java.io.IOException)8 TableId (org.apache.accumulo.core.data.TableId)7 AccumuloException (org.apache.accumulo.core.client.AccumuloException)6 TTransportException (org.apache.thrift.transport.TTransportException)5 NamespaceExistsException (org.apache.accumulo.core.client.NamespaceExistsException)4 TableExistsException (org.apache.accumulo.core.client.TableExistsException)4 ThriftNotActiveServiceException (org.apache.accumulo.core.clientImpl.thrift.ThriftNotActiveServiceException)4 ManagerClientService (org.apache.accumulo.core.manager.thrift.ManagerClientService)4 FileNotFoundException (java.io.FileNotFoundException)3 HashSet (java.util.HashSet)3 TableOfflineException (org.apache.accumulo.core.client.TableOfflineException)3 NotServingTabletException (org.apache.accumulo.core.tabletserver.thrift.NotServingTabletException)3 Text (org.apache.hadoop.io.Text)3