Package org.apache.hadoop.hbase.client
Class RpcRetryingCallerImpl<T>
java.lang.Object
org.apache.hadoop.hbase.client.RpcRetryingCallerImpl<T>
- All Implemented Interfaces:
RpcRetryingCaller<T>
Runs an rpc'ing
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.-
Field Summary
Modifier and TypeFieldDescriptionprivate final AtomicBoolean
private final RetryingCallerInterceptorContext
private final RetryingCallerInterceptor
static final org.slf4j.Logger
private final int
private final MetricsConnection
private final long
private final long
private final int
private final int
How many retries are allowed before we start to logprivate final RetryingTimeTracker
-
Constructor Summary
ConstructorDescriptionRpcRetryingCallerImpl
(long pause, long pauseForServerOverloaded, int retries, RetryingCallerInterceptor interceptor, int startLogErrorsCnt, int rpcTimeout, MetricsConnection metricsConnection) -
Method Summary
Modifier and TypeMethodDescriptioncallWithoutRetries
(RetryingCallable<T> callable, int callTimeout) Call the server once only.callWithRetries
(RetryingCallable<T> callable, int callTimeout) Retries if invocation fails.void
cancel()
private int
getTimeout
(int callTimeout) private long
singleCallDuration
(long expectedSleep) Returns Calculate how long a single call tooktoString()
(package private) static Throwable
Get the good or the remote exception if any, throws the DoNotRetryIOException.
-
Field Details
-
LOG
-
startLogErrorsCnt
How many retries are allowed before we start to log -
pause
-
pauseForServerOverloaded
-
maxAttempts
-
rpcTimeout
-
cancelled
-
interceptor
-
context
-
tracker
-
metrics
-
-
Constructor Details
-
RpcRetryingCallerImpl
public RpcRetryingCallerImpl(long pause, long pauseForServerOverloaded, int retries, RetryingCallerInterceptor interceptor, int startLogErrorsCnt, int rpcTimeout, MetricsConnection metricsConnection)
-
-
Method Details
-
cancel
- Specified by:
cancel
in interfaceRpcRetryingCaller<T>
-
callWithRetries
public T callWithRetries(RetryingCallable<T> callable, int callTimeout) throws IOException, RuntimeException Description copied from interface:RpcRetryingCaller
Retries if invocation fails.- Specified by:
callWithRetries
in interfaceRpcRetryingCaller<T>
- Parameters:
callable
- TheRetryingCallable
to run.callTimeout
- Timeout for this call- Returns:
- an object of type T
- Throws:
IOException
- if a remote or network exception occursRuntimeException
- other unspecified error
-
singleCallDuration
Returns Calculate how long a single call took -
callWithoutRetries
public T callWithoutRetries(RetryingCallable<T> callable, int callTimeout) throws IOException, RuntimeException Description copied from interface:RpcRetryingCaller
Call the server once only.RetryingCallable
has a strange shape so we can do retries. Use this invocation if you want to do a single call only (A call toRetryingCallable.call(int)
will not likely succeed).- Specified by:
callWithoutRetries
in interfaceRpcRetryingCaller<T>
- Returns:
- an object of type T
- Throws:
IOException
- if a remote or network exception occursRuntimeException
- other unspecified error
-
translateException
Get the good or the remote exception if any, throws the DoNotRetryIOException.- Parameters:
t
- the throwable to analyze- Returns:
- the translated exception, if it's not a DoNotRetryIOException
- Throws:
DoNotRetryIOException
- - if we find it, we throw it instead of translating.
-
getTimeout
-
toString
-