/** * Closes the connection with the remote permanently. This instance should be not be reused after * closing. */ @Override public synchronized void close() { disconnect(); mClosed = true; }
private synchronized <V> V retryRPCInternal(RpcCallable<V> rpc, Supplier<Void> onRetry) throws AlluxioStatusException { RetryPolicy retryPolicy = mRetryPolicySupplier.get(); Exception ex = null; while (retryPolicy.attempt()) { if (mClosed) { throw new FailedPreconditionException("Client is closed"); } connect(); try { return rpc.call(); } catch (StatusRuntimeException e) { AlluxioStatusException se = GrpcExceptionUtils.fromGrpcStatusException(e); if (se.getStatus() == Status.UNAVAILABLE || se.getStatus() == Status.CANCELED || se.getStatus() == Status.UNAUTHENTICATED) { ex = se; } else { throw se; } } LOG.info("Rpc failed ({}): {}", retryPolicy.getAttemptCount(), ex.toString()); onRetry.get(); disconnect(); } throw new UnavailableException("Failed after " + retryPolicy.getAttemptCount() + " attempts: " + ex.toString(), ex); }
return; disconnect(); Preconditions.checkState(!mClosed, "Client is closed, will not try to connect.");
/** * Closes the connection with the remote permanently. This instance should be not be reused after * closing. */ @Override public synchronized void close() { disconnect(); mClosed = true; }
private synchronized <V> V retryRPCInternal(RpcCallable<V> rpc, Supplier<Void> onRetry) throws AlluxioStatusException { RetryPolicy retryPolicy = mRetryPolicySupplier.get(); Exception ex = null; while (retryPolicy.attempt()) { if (mClosed) { throw new FailedPreconditionException("Client is closed"); } connect(); try { return rpc.call(); } catch (AlluxioTException e) { AlluxioStatusException se = AlluxioStatusException.fromThrift(e); if (se.getStatus() == Status.UNAVAILABLE) { ex = se; } else { throw se; } } catch (TException e) { ex = e; } LOG.info("Rpc failed ({}): {}", retryPolicy.getAttemptCount(), ex.toString()); onRetry.get(); disconnect(); } throw new UnavailableException("Failed after " + retryPolicy.getAttemptCount() + " attempts: " + ex.toString(), ex); }
return; disconnect(); Preconditions.checkState(!mClosed, "Client is closed, will not try to connect.");