Search in sources :

Example 46 with TableNotFoundException

use of org.apache.accumulo.core.client.TableNotFoundException in project accumulo by apache.

the class TableOperationsImpl method doFateOperation.

String doFateOperation(FateOperation op, List<ByteBuffer> args, Map<String, String> opts, String tableOrNamespaceName, boolean wait) throws AccumuloSecurityException, TableExistsException, TableNotFoundException, AccumuloException, NamespaceExistsException, NamespaceNotFoundException {
    Long opid = null;
    try {
        opid = beginFateOperation();
        executeFateOperation(opid, op, args, opts, !wait);
        if (!wait) {
            opid = null;
            return null;
        }
        String ret = waitForFateOperation(opid);
        return ret;
    } catch (ThriftSecurityException e) {
        switch(e.getCode()) {
            case TABLE_DOESNT_EXIST:
                throw new TableNotFoundException(null, tableOrNamespaceName, "Target table does not exist");
            case NAMESPACE_DOESNT_EXIST:
                throw new NamespaceNotFoundException(null, tableOrNamespaceName, "Target namespace does not exist");
            default:
                String tableInfo = Tables.getPrintableTableInfoFromName(context.getInstance(), tableOrNamespaceName);
                throw new AccumuloSecurityException(e.user, e.code, tableInfo, e);
        }
    } catch (ThriftTableOperationException e) {
        switch(e.getType()) {
            case EXISTS:
                throw new TableExistsException(e);
            case NOTFOUND:
                throw new TableNotFoundException(e);
            case NAMESPACE_EXISTS:
                throw new NamespaceExistsException(e);
            case NAMESPACE_NOTFOUND:
                throw new NamespaceNotFoundException(e);
            case OFFLINE:
                throw new TableOfflineException(context.getInstance(), Tables.getTableId(context.getInstance(), tableOrNamespaceName).canonicalID());
            default:
                throw new AccumuloException(e.description, e);
        }
    } catch (Exception e) {
        throw new AccumuloException(e.getMessage(), e);
    } finally {
        Tables.clearCache(context.getInstance());
        // always finish table op, even when exception
        if (opid != null)
            try {
                finishFateOperation(opid);
            } catch (Exception e) {
                log.warn("Exception thrown while finishing fate table operation", e);
            }
    }
}
Also used : TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) AccumuloException(org.apache.accumulo.core.client.AccumuloException) TableOfflineException(org.apache.accumulo.core.client.TableOfflineException) TableExistsException(org.apache.accumulo.core.client.TableExistsException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) ThriftTableOperationException(org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException) ThriftSecurityException(org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException) NamespaceExistsException(org.apache.accumulo.core.client.NamespaceExistsException) NamespaceNotFoundException(org.apache.accumulo.core.client.NamespaceNotFoundException) TableOfflineException(org.apache.accumulo.core.client.TableOfflineException) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) NamespaceNotFoundException(org.apache.accumulo.core.client.NamespaceNotFoundException) ThriftNotActiveServiceException(org.apache.accumulo.core.client.impl.thrift.ThriftNotActiveServiceException) ThriftSecurityException(org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException) TableExistsException(org.apache.accumulo.core.client.TableExistsException) TableDeletedException(org.apache.accumulo.core.client.TableDeletedException) TException(org.apache.thrift.TException) IOException(java.io.IOException) ThriftTableOperationException(org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException) TTransportException(org.apache.thrift.transport.TTransportException) NamespaceExistsException(org.apache.accumulo.core.client.NamespaceExistsException) FileNotFoundException(java.io.FileNotFoundException) NotServingTabletException(org.apache.accumulo.core.tabletserver.thrift.NotServingTabletException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) TApplicationException(org.apache.thrift.TApplicationException) AccumuloException(org.apache.accumulo.core.client.AccumuloException)

Example 47 with TableNotFoundException

use of org.apache.accumulo.core.client.TableNotFoundException in project accumulo by apache.

the class Tables method getNamespaceId.

/**
 * Returns the namespace id for a given table ID.
 *
 * @param instance
 *          The Accumulo Instance
 * @param tableId
 *          The tableId
 * @return The namespace id which this table resides in.
 * @throws IllegalArgumentException
 *           if the table doesn't exist in ZooKeeper
 */
public static Namespace.ID getNamespaceId(Instance instance, Table.ID tableId) throws TableNotFoundException {
    checkArgument(instance != null, "instance is null");
    checkArgument(tableId != null, "tableId is null");
    ZooCache zc = getZooCache(instance);
    byte[] n = zc.get(ZooUtil.getRoot(instance) + Constants.ZTABLES + "/" + tableId + Constants.ZTABLE_NAMESPACE);
    // We might get null out of ZooCache if this tableID doesn't exist
    if (null == n) {
        throw new TableNotFoundException(tableId.canonicalID(), null, null);
    }
    return Namespace.ID.of(new String(n, UTF_8));
}
Also used : TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) ZooCache(org.apache.accumulo.fate.zookeeper.ZooCache)

Example 48 with TableNotFoundException

use of org.apache.accumulo.core.client.TableNotFoundException in project accumulo by apache.

the class ReplicationOperationsImpl method getTableId.

protected Table.ID getTableId(Connector conn, String tableName) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
    TableOperations tops = conn.tableOperations();
    if (!conn.tableOperations().exists(tableName)) {
        throw new TableNotFoundException(null, tableName, null);
    }
    String tableId = null;
    while (null == tableId) {
        tableId = tops.tableIdMap().get(tableName);
        if (null == tableId) {
            sleepUninterruptibly(200, TimeUnit.MILLISECONDS);
        }
    }
    return Table.ID.of(tableId);
}
Also used : TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) TableOperations(org.apache.accumulo.core.client.admin.TableOperations)

Example 49 with TableNotFoundException

use of org.apache.accumulo.core.client.TableNotFoundException in project accumulo by apache.

the class SecurityOperationsImpl method getDelegationToken.

@Override
public DelegationToken getDelegationToken(DelegationTokenConfig cfg) throws AccumuloException, AccumuloSecurityException {
    final TDelegationTokenConfig tConfig;
    if (null != cfg) {
        tConfig = DelegationTokenConfigSerializer.serialize(cfg);
    } else {
        tConfig = new TDelegationTokenConfig();
    }
    TDelegationToken thriftToken;
    try {
        thriftToken = MasterClient.execute(context, new ClientExecReturn<TDelegationToken, Client>() {

            @Override
            public TDelegationToken execute(Client client) throws Exception {
                return client.getDelegationToken(Tracer.traceInfo(), context.rpcCreds(), tConfig);
            }
        });
    } catch (TableNotFoundException e) {
        // should never happen
        throw new AssertionError("Received TableNotFoundException on method which should not throw that exception", e);
    }
    AuthenticationTokenIdentifier identifier = new AuthenticationTokenIdentifier(thriftToken.getIdentifier());
    // Get the password out of the thrift delegation token
    return new DelegationTokenImpl(thriftToken.getPassword(), identifier);
}
Also used : TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) TDelegationTokenConfig(org.apache.accumulo.core.security.thrift.TDelegationTokenConfig) TDelegationToken(org.apache.accumulo.core.security.thrift.TDelegationToken) Client(org.apache.accumulo.core.master.thrift.MasterClientService.Client)

Example 50 with TableNotFoundException

use of org.apache.accumulo.core.client.TableNotFoundException in project accumulo by apache.

the class TableOperationsImpl method _flush.

private void _flush(Table.ID tableId, Text start, Text end, boolean wait) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
    try {
        long flushID;
        while (true) {
            MasterClientService.Iface client = null;
            try {
                client = MasterClient.getConnectionWithRetry(context);
                flushID = client.initiateFlush(Tracer.traceInfo(), context.rpcCreds(), tableId.canonicalID());
                break;
            } catch (TTransportException tte) {
                log.debug("Failed to call initiateFlush, retrying ... ", tte);
                sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
            } catch (ThriftNotActiveServiceException e) {
                // Let it loop, fetching a new location
                log.debug("Contacted a Master which is no longer active, retrying");
                sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
            } finally {
                MasterClient.close(client);
            }
        }
        while (true) {
            MasterClientService.Iface client = null;
            try {
                client = MasterClient.getConnectionWithRetry(context);
                client.waitForFlush(Tracer.traceInfo(), context.rpcCreds(), tableId.canonicalID(), TextUtil.getByteBuffer(start), TextUtil.getByteBuffer(end), flushID, wait ? Long.MAX_VALUE : 1);
                break;
            } catch (TTransportException tte) {
                log.debug("Failed to call initiateFlush, retrying ... ", tte);
                sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
            } catch (ThriftNotActiveServiceException e) {
                // Let it loop, fetching a new location
                log.debug("Contacted a Master which is no longer active, retrying");
                sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
            } finally {
                MasterClient.close(client);
            }
        }
    } catch (ThriftSecurityException e) {
        switch(e.getCode()) {
            case TABLE_DOESNT_EXIST:
                throw new TableNotFoundException(tableId.canonicalID(), null, e.getMessage(), e);
            default:
                log.debug("flush security exception on table id {}", tableId);
                throw new AccumuloSecurityException(e.user, e.code, e);
        }
    } catch (ThriftTableOperationException e) {
        switch(e.getType()) {
            case NOTFOUND:
                throw new TableNotFoundException(e);
            default:
                throw new AccumuloException(e.description, e);
        }
    } catch (Exception e) {
        throw new AccumuloException(e);
    }
}
Also used : TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) AccumuloException(org.apache.accumulo.core.client.AccumuloException) ThriftNotActiveServiceException(org.apache.accumulo.core.client.impl.thrift.ThriftNotActiveServiceException) MasterClientService(org.apache.accumulo.core.master.thrift.MasterClientService) TTransportException(org.apache.thrift.transport.TTransportException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) ThriftTableOperationException(org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException) ThriftSecurityException(org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException) TableOfflineException(org.apache.accumulo.core.client.TableOfflineException) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) NamespaceNotFoundException(org.apache.accumulo.core.client.NamespaceNotFoundException) ThriftNotActiveServiceException(org.apache.accumulo.core.client.impl.thrift.ThriftNotActiveServiceException) ThriftSecurityException(org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException) TableExistsException(org.apache.accumulo.core.client.TableExistsException) TableDeletedException(org.apache.accumulo.core.client.TableDeletedException) TException(org.apache.thrift.TException) IOException(java.io.IOException) ThriftTableOperationException(org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException) TTransportException(org.apache.thrift.transport.TTransportException) NamespaceExistsException(org.apache.accumulo.core.client.NamespaceExistsException) FileNotFoundException(java.io.FileNotFoundException) NotServingTabletException(org.apache.accumulo.core.tabletserver.thrift.NotServingTabletException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) TApplicationException(org.apache.thrift.TApplicationException) AccumuloException(org.apache.accumulo.core.client.AccumuloException)

Aggregations

TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)160 AccumuloException (org.apache.accumulo.core.client.AccumuloException)100 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)89 Text (org.apache.hadoop.io.Text)51 Value (org.apache.accumulo.core.data.Value)46 Key (org.apache.accumulo.core.data.Key)42 Scanner (org.apache.accumulo.core.client.Scanner)36 IOException (java.io.IOException)34 BatchWriter (org.apache.accumulo.core.client.BatchWriter)31 BatchWriterConfig (org.apache.accumulo.core.client.BatchWriterConfig)31 Connector (org.apache.accumulo.core.client.Connector)30 Mutation (org.apache.accumulo.core.data.Mutation)29 Range (org.apache.accumulo.core.data.Range)28 Authorizations (org.apache.accumulo.core.security.Authorizations)26 ArrayList (java.util.ArrayList)25 Entry (java.util.Map.Entry)25 TableExistsException (org.apache.accumulo.core.client.TableExistsException)25 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)23 MutationsRejectedException (org.apache.accumulo.core.client.MutationsRejectedException)23 HashMap (java.util.HashMap)19