@InterfaceAudience.Private public class RpcRetryingCallerImpl<T> extends Object implements RpcRetryingCaller<T>
RetryingCallable
. Sets into rpc client
threadlocal outstanding timeouts as so we don't persist too much.
Dynamic rather than static so can set the generic appropriately.
This object has a state. It should not be used by in parallel by different threads.
Reusing it is possible however, even between multiple threads. However, the user will
have to manage the synchronization on its side: there is no synchronization inside the class.Modifier and Type | Field and Description |
---|---|
private AtomicBoolean |
cancelled |
private RetryingCallerInterceptorContext |
context |
private RetryingCallerInterceptor |
interceptor |
static org.slf4j.Logger |
LOG |
private int |
maxAttempts |
private long |
pause |
private long |
pauseForCQTBE |
private int |
rpcTimeout |
private int |
startLogErrorsCnt
How many retries are allowed before we start to log
|
private RetryingTimeTracker |
tracker |
Constructor and Description |
---|
RpcRetryingCallerImpl(long pause,
long pauseForCQTBE,
int retries,
int startLogErrorsCnt) |
RpcRetryingCallerImpl(long pause,
long pauseForCQTBE,
int retries,
RetryingCallerInterceptor interceptor,
int startLogErrorsCnt,
int rpcTimeout) |
Modifier and Type | Method and Description |
---|---|
T |
callWithoutRetries(RetryingCallable<T> callable,
int callTimeout)
Call the server once only.
|
T |
callWithRetries(RetryingCallable<T> callable,
int callTimeout)
Retries if invocation fails.
|
void |
cancel() |
private int |
getTimeout(int callTimeout) |
private long |
singleCallDuration(long expectedSleep) |
String |
toString() |
(package private) static Throwable |
translateException(Throwable t)
Get the good or the remote exception if any, throws the DoNotRetryIOException.
|
public static final org.slf4j.Logger LOG
private final int startLogErrorsCnt
private final long pause
private final long pauseForCQTBE
private final int maxAttempts
private final int rpcTimeout
private final AtomicBoolean cancelled
private final RetryingCallerInterceptor interceptor
private final RetryingCallerInterceptorContext context
private final RetryingTimeTracker tracker
public RpcRetryingCallerImpl(long pause, long pauseForCQTBE, int retries, int startLogErrorsCnt)
public RpcRetryingCallerImpl(long pause, long pauseForCQTBE, int retries, RetryingCallerInterceptor interceptor, int startLogErrorsCnt, int rpcTimeout)
public void cancel()
cancel
in interface RpcRetryingCaller<T>
public T callWithRetries(RetryingCallable<T> callable, int callTimeout) throws IOException, RuntimeException
RpcRetryingCaller
callWithRetries
in interface RpcRetryingCaller<T>
callable
- The RetryingCallable
to run.callTimeout
- Timeout for this callIOException
- if a remote or network exception occursRuntimeException
- other unspecified errorprivate long singleCallDuration(long expectedSleep)
public T callWithoutRetries(RetryingCallable<T> callable, int callTimeout) throws IOException, RuntimeException
RpcRetryingCaller
RetryingCallable
has a strange shape so we can do retries. Use this invocation if you
want to do a single call only (A call to RetryingCallable.call(int)
will not likely
succeed).callWithoutRetries
in interface RpcRetryingCaller<T>
IOException
- if a remote or network exception occursRuntimeException
- other unspecified errorstatic Throwable translateException(Throwable t) throws DoNotRetryIOException
t
- the throwable to analyzeDoNotRetryIOException
- - if we find it, we throw it instead of translating.private int getTimeout(int callTimeout)
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.