@InterfaceAudience.Private public class RpcRetryingCallerWithReadReplicas extends Object
Modifier and Type | Class and Description |
---|---|
(package private) class |
RpcRetryingCallerWithReadReplicas.ReplicaRegionServerCallable
A RegionServerCallable that takes into account the replicas, i.e.
|
Modifier and Type | Field and Description |
---|---|
protected ClusterConnection |
cConnection |
protected org.apache.hadoop.conf.Configuration |
conf |
protected Get |
get |
private static org.slf4j.Logger |
LOG |
private int |
operationTimeout |
protected ExecutorService |
pool |
private int |
retries |
private RpcControllerFactory |
rpcControllerFactory |
private RpcRetryingCallerFactory |
rpcRetryingCallerFactory |
private int |
rpcTimeout |
protected TableName |
tableName |
protected int |
timeBeforeReplicas |
Constructor and Description |
---|
RpcRetryingCallerWithReadReplicas(RpcControllerFactory rpcControllerFactory,
TableName tableName,
ClusterConnection cConnection,
Get get,
ExecutorService pool,
int retries,
int operationTimeout,
int rpcTimeout,
int timeBeforeReplicas) |
Modifier and Type | Method and Description |
---|---|
private void |
addCallsForReplica(ResultBoundedCompletionService<Result> cs,
RegionLocations rl,
int min,
int max)
Creates the calls and submit them
|
Result |
call(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.
|
private static final org.slf4j.Logger LOG
protected final ExecutorService pool
protected final ClusterConnection cConnection
protected final org.apache.hadoop.conf.Configuration conf
protected final int timeBeforeReplicas
private final int operationTimeout
private final int rpcTimeout
private final int retries
private final RpcControllerFactory rpcControllerFactory
private final RpcRetryingCallerFactory rpcRetryingCallerFactory
public RpcRetryingCallerWithReadReplicas(RpcControllerFactory rpcControllerFactory, TableName tableName, ClusterConnection cConnection, Get get, ExecutorService pool, int retries, int operationTimeout, int rpcTimeout, int timeBeforeReplicas)
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.static void throwEnrichedException(ExecutionException e, int retries) throws RetriesExhaustedException, DoNotRetryIOException
private void addCallsForReplica(ResultBoundedCompletionService<Result> cs, RegionLocations rl, int min, int max)
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.static RegionLocations getRegionLocations(boolean useCache, int replicaId, ClusterConnection cConnection, TableName tableName, byte[] row) throws RetriesExhaustedException, DoNotRetryIOException, InterruptedIOException
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.