Search in sources :

Example 1 with ThriftIOException

use of alluxio.thrift.ThriftIOException in project alluxio by Alluxio.

the class RetryHandlingFileSystemWorkerClient method sessionHeartbeat.

@Override
public void sessionHeartbeat(RetryPolicy retryPolicy) throws IOException, InterruptedException {
    TException exception;
    do {
        FileSystemWorkerClientService.Client client = mClientHeartbeatPool.acquire();
        try {
            client.sessionHeartbeat(mSessionId, null);
            Metrics.FILE_SYSTEM_WORKER_HEARTBEATS.inc();
            return;
        } catch (AlluxioTException | ThriftIOException e) {
            exception = e;
            LOG.warn(e.getMessage());
        } catch (TException e) {
            client.getOutputProtocol().getTransport().close();
            exception = e;
            LOG.warn(e.getMessage());
        } finally {
            mClientHeartbeatPool.release(client);
        }
    } while (retryPolicy.attemptRetry());
    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) FileSystemWorkerClientService(alluxio.thrift.FileSystemWorkerClientService) ThriftIOException(alluxio.thrift.ThriftIOException) IOException(java.io.IOException)

Example 2 with ThriftIOException

use of alluxio.thrift.ThriftIOException in project alluxio by Alluxio.

the class RetryHandlingBlockWorkerClient method sessionHeartbeat.

/**
   * sessionHeartbeat is not retried because it is supposed to be called periodically.
   *
   * @throws IOException if it fails to heartbeat
   * @throws InterruptedException if heartbeat is interrupted
   */
@Override
public void sessionHeartbeat(RetryPolicy retryPolicy) throws IOException, InterruptedException {
    TException exception;
    do {
        BlockWorkerClientService.Client client = mClientHeartbeatPool.acquire();
        try {
            client.sessionHeartbeat(mSessionId, null);
            Metrics.BLOCK_WORKER_HEATBEATS.inc();
            return;
        } catch (AlluxioTException e) {
            AlluxioException ae = AlluxioException.fromThrift(e);
            LOG.warn(ae.getMessage());
            throw new IOException(ae);
        } catch (ThriftIOException e) {
            LOG.warn(e.getMessage());
            throw new IOException(e);
        } catch (TException e) {
            client.getOutputProtocol().getTransport().close();
            exception = e;
            LOG.warn(e.getMessage());
        } finally {
            mClientHeartbeatPool.release(client);
        }
    } while (retryPolicy.attemptRetry());
    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) BlockWorkerClientService(alluxio.thrift.BlockWorkerClientService) ThriftIOException(alluxio.thrift.ThriftIOException) IOException(java.io.IOException) AlluxioException(alluxio.exception.AlluxioException)

Example 3 with ThriftIOException

use of alluxio.thrift.ThriftIOException in project alluxio by Alluxio.

the class AbstractThriftClient method retryRPC.

/**
   * Similar to {@link #retryRPC(RpcCallable)} except that the RPC call may throw
   * {@link AlluxioTException} and once it is thrown, it will be transformed into
   * {@link AlluxioException} and be thrown.
   *
   * @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 AlluxioException when {@link AlluxioTException} is thrown by the RPC call
   * @throws IOException when retries exceeds {@link #RPC_MAX_NUM_RETRY} or some server
   *         side IOException occurred.
   */
protected <V> V retryRPC(RpcCallableThrowsAlluxioTException<V, C> rpc) throws AlluxioException, IOException {
    TException exception = null;
    RetryPolicy retryPolicy = new ExponentialBackoffRetry(BASE_SLEEP_MS, MAX_SLEEP_MS, RPC_MAX_NUM_RETRY);
    do {
        C client = acquireClient();
        try {
            return rpc.call(client);
        } catch (AlluxioTException e) {
            AlluxioException ae = AlluxioException.fromThrift(e);
            processException(client, ae);
            exception = new TException(ae);
        } catch (ThriftIOException e) {
            throw new IOException(e);
        } catch (TException e) {
            LOG.error(e.getMessage(), e);
            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)

Example 4 with ThriftIOException

use of alluxio.thrift.ThriftIOException 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

AlluxioTException (alluxio.thrift.AlluxioTException)4 ThriftIOException (alluxio.thrift.ThriftIOException)4 IOException (java.io.IOException)4 TException (org.apache.thrift.TException)4 AlluxioException (alluxio.exception.AlluxioException)3 ExponentialBackoffRetry (alluxio.retry.ExponentialBackoffRetry)2 RetryPolicy (alluxio.retry.RetryPolicy)2 BlockWorkerClientService (alluxio.thrift.BlockWorkerClientService)1 FileSystemWorkerClientService (alluxio.thrift.FileSystemWorkerClientService)1