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
Nested ClassesModifier and TypeClassDescription(package private) classA RegionServerCallable that takes into account the replicas, i.e. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ClusterConnectionprotected final org.apache.hadoop.conf.Configurationprotected final Getprivate static final org.slf4j.Loggerprivate final intprotected final ExecutorServiceprivate final intprivate final RpcControllerFactoryprivate final RpcRetryingCallerFactoryprivate final intprotected final TableNameprotected final int -
Constructor Summary
ConstructorsConstructorDescriptionRpcRetryingCallerWithReadReplicas(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 voidaddCallsForReplica(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 RegionLocationsgetRegionLocations(boolean useCache, int replicaId, ClusterConnection cConnection, TableName tableName, byte[] row) (package private) static voidthrowEnrichedException(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
-