Package org.apache.hadoop.hbase.client
Class RpcRetryingCallerWithReadReplicas
java.lang.Object
org.apache.hadoop.hbase.client.RpcRetryingCallerWithReadReplicas
Caller that goes to replica if the primary region does no answer within a configurable timeout.
If the timeout is reached, it calls all the secondary replicas, and returns the first answer. If
the answer comes from one of the secondary replica, it will be marked as stale.
-
Nested Class Summary
Modifier and TypeClassDescription(package private) class
A RegionServerCallable that takes into account the replicas, i.e. -
Field Summary
Modifier and TypeFieldDescriptionprotected final ClusterConnection
protected final org.apache.hadoop.conf.Configuration
protected final Get
private static final org.slf4j.Logger
private final int
protected final ExecutorService
private final int
private final RpcControllerFactory
private final RpcRetryingCallerFactory
private final int
protected final TableName
protected final int
-
Constructor Summary
ConstructorDescriptionRpcRetryingCallerWithReadReplicas
(RpcControllerFactory rpcControllerFactory, TableName tableName, ClusterConnection cConnection, Get get, ExecutorService pool, int retries, int operationTimeout, int rpcTimeout, int timeBeforeReplicas, Map<String, byte[]> requestAttributes) -
Method Summary
Modifier and TypeMethodDescriptionprivate void
addCallsForReplica
(ResultBoundedCompletionService<Result> cs, RegionLocations rl, int min, int max) Creates the calls and submit themcall
(int operationTimeout) Algo: - we put the query into the execution pool.(package private) static RegionLocations
getRegionLocations
(boolean useCache, int replicaId, ClusterConnection cConnection, TableName tableName, byte[] row) (package private) static void
throwEnrichedException
(ExecutionException e, int retries) Extract the real exception from the ExecutionException, and throws what makes more sense.
-
Field Details
-
LOG
-
pool
-
cConnection
-
conf
-
get
-
tableName
-
timeBeforeReplicas
-
operationTimeout
-
rpcTimeout
-
retries
-
rpcControllerFactory
-
rpcRetryingCallerFactory
-
requestAttributes
-
-
Constructor Details
-
RpcRetryingCallerWithReadReplicas
public RpcRetryingCallerWithReadReplicas(RpcControllerFactory rpcControllerFactory, TableName tableName, ClusterConnection cConnection, Get get, ExecutorService pool, int retries, int operationTimeout, int rpcTimeout, int timeBeforeReplicas, Map<String, byte[]> requestAttributes)
-
-
Method Details
-
call
public Result call(int operationTimeout) throws DoNotRetryIOException, InterruptedIOException, RetriesExhaustedException Algo: - we put the query into the execution pool. - after x ms, if we don't have a result, we add the queries for the secondary replicas - we take the first answer - when done, we cancel what's left. Cancelling means: - removing from the pool if the actual call was not started - interrupting the call if it has started Client side, we need to take into account - a call is not executed immediately after being put into the pool - a call is a thread. Let's not multiply the number of thread by the number of replicas. Server side, if we can cancel when it's still in the handler pool, it's much better, as a call can take some i/o.
Globally, the number of retries, timeout and so on still applies, but it's per replica, not global. We continue until all retries are done, or all timeouts are exceeded. -
throwEnrichedException
static void throwEnrichedException(ExecutionException e, int retries) throws RetriesExhaustedException, DoNotRetryIOException Extract the real exception from the ExecutionException, and throws what makes more sense. -
addCallsForReplica
private void addCallsForReplica(ResultBoundedCompletionService<Result> cs, RegionLocations rl, int min, int max) Creates the calls and submit them- Parameters:
cs
- - the completion service to use for submittingrl
- - the region locationsmin
- - the id of the first replica, inclusivemax
- - the id of the last replica, inclusive.
-
getRegionLocations
static RegionLocations getRegionLocations(boolean useCache, int replicaId, ClusterConnection cConnection, TableName tableName, byte[] row) throws RetriesExhaustedException, DoNotRetryIOException, InterruptedIOException
-