Search in sources :

Example 56 with AlluxioException

use of alluxio.exception.AlluxioException in project alluxio by Alluxio.

the class AbstractThriftClient method retryRPC.

/**
   * Tries to execute an RPC defined as a {@link RpcCallable}.
   *
   * @param rpc the RPC call to be executed
   * @param <V> type of return value of the RPC call
   * @return the return value of the RPC call
   * @throws IOException when retries exceeds {@link #RPC_MAX_NUM_RETRY} or some server
   *         side IOException occurred.
   */
protected <V> V retryRPC(RpcCallable<V, C> rpc) throws IOException {
    TException exception;
    RetryPolicy retryPolicy = new ExponentialBackoffRetry(BASE_SLEEP_MS, MAX_SLEEP_MS, RPC_MAX_NUM_RETRY);
    do {
        C client = acquireClient();
        try {
            return rpc.call(client);
        } catch (ThriftIOException e) {
            throw new IOException(e);
        } catch (AlluxioTException e) {
            AlluxioException ae = AlluxioException.fromThrift(e);
            try {
                processException(client, ae);
            } catch (AlluxioException ee) {
                throw new IOException(ee);
            }
            exception = new TException(ae);
        } catch (TException e) {
            LOG.warn(e.getMessage());
            closeClient(client);
            exception = e;
        } finally {
            releaseClient(client);
        }
    } while (retryPolicy.attemptRetry());
    LOG.error("Failed after " + retryPolicy.getRetryCount() + " retries.");
    Preconditions.checkNotNull(exception);
    throw new IOException(exception);
}
Also used : AlluxioTException(alluxio.thrift.AlluxioTException) TException(org.apache.thrift.TException) AlluxioTException(alluxio.thrift.AlluxioTException) ThriftIOException(alluxio.thrift.ThriftIOException) ExponentialBackoffRetry(alluxio.retry.ExponentialBackoffRetry) ThriftIOException(alluxio.thrift.ThriftIOException) IOException(java.io.IOException) RetryPolicy(alluxio.retry.RetryPolicy) AlluxioException(alluxio.exception.AlluxioException)

Aggregations

AlluxioException (alluxio.exception.AlluxioException)56 IOException (java.io.IOException)54 AlluxioURI (alluxio.AlluxioURI)33 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)15 URIStatus (alluxio.client.file.URIStatus)13 ArrayList (java.util.ArrayList)11 InvalidPathException (alluxio.exception.InvalidPathException)9 Closer (com.google.common.io.Closer)8 FileOutStream (alluxio.client.file.FileOutStream)5 FileAlreadyExistsException (alluxio.exception.FileAlreadyExistsException)5 WorkerNetAddress (alluxio.wire.WorkerNetAddress)5 LockBlockResult (alluxio.wire.LockBlockResult)4 BlockWorkerClient (alluxio.client.block.BlockWorkerClient)3 Mode (alluxio.security.authorization.Mode)3 AlluxioTException (alluxio.thrift.AlluxioTException)3 ThriftIOException (alluxio.thrift.ThriftIOException)3 File (java.io.File)3 WorkerStorageTierAssoc (alluxio.WorkerStorageTierAssoc)2 LockBlockOptions (alluxio.client.block.options.LockBlockOptions)2 SetAttributeOptions (alluxio.client.file.options.SetAttributeOptions)2