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
FieldsModifier and TypeFieldDescriptionprivate final AtomicBooleanprivate final RetryingCallerInterceptorContextprivate final RetryingCallerInterceptorstatic final org.slf4j.Loggerprivate final intprivate final MetricsConnectionprivate final longprivate final longprivate final intprivate final intHow many retries are allowed before we start to logprivate final RetryingTimeTracker -
Constructor Summary
ConstructorsConstructorDescriptionRpcRetryingCallerImpl(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.voidcancel()private intgetTimeout(int callTimeout) private longsingleCallDuration(long expectedSleep) Returns Calculate how long a single call tooktoString()(package private) static ThrowableGet 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:
cancelin interfaceRpcRetryingCaller<T>
-
callWithRetries
public T callWithRetries(RetryingCallable<T> callable, int callTimeout) throws IOException, RuntimeException Description copied from interface:RpcRetryingCallerRetries if invocation fails.- Specified by:
callWithRetriesin interfaceRpcRetryingCaller<T>- Parameters:
callable- TheRetryingCallableto 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:RpcRetryingCallerCall the server once only.RetryingCallablehas 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:
callWithoutRetriesin 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
-