Package org.apache.hadoop.hbase.client
Class ScannerCallableWithReplicas
java.lang.Object
org.apache.hadoop.hbase.client.ScannerCallableWithReplicas
- All Implemented Interfaces:
RetryingCallable<Result[]>
This class has the logic for handling scanners for regions with and without replicas. 1. A scan
is attempted on the default (primary) region, or a specific region. 2. The scanner sends all the
RPCs to the default/specific region until it is done, or, there is a timeout on the
default/specific region (a timeout of zero is disallowed). 3. If there is a timeout in (2) above,
scanner(s) is opened on the non-default replica(s) only for Consistency.TIMELINE without specific
replica id specified. 4. The results from the first successful scanner are taken, and it is
stored which server returned the results. 5. The next RPCs are done on the above stored server
until it is done or there is a timeout, in which case, the other replicas are queried (as in (3)
above).
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final RpcRetryingCaller<Result[]>private final ClusterConnectionprivate org.apache.hadoop.conf.Configuration(package private) ScannerCallableprivate Resultprivate static final org.slf4j.Loggerprivate Set<ScannerCallable>protected final ExecutorServiceprivate final intprivate int(package private) AtomicBooleanprivate final intprivate final Scanprivate final intprivate booleanprivate final TableNameprotected final intprivate final boolean -
Constructor Summary
ConstructorsConstructorDescriptionScannerCallableWithReplicas(TableName tableName, ClusterConnection cConnection, ScannerCallable baseCallable, ExecutorService pool, int timeBeforeReplicas, Scan scan, int retries, int readRpcTimeout, int scannerTimeout, boolean useScannerTimeoutForNextCalls, int caching, org.apache.hadoop.conf.Configuration conf, RpcRetryingCaller<Result[]> caller) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddCallsForCurrentReplica(ResultBoundedCompletionService<Pair<Result[], ScannerCallable>> cs, int rpcTimeout) private voidaddCallsForOtherReplicas(ResultBoundedCompletionService<Pair<Result[], ScannerCallable>> cs, int min, int max, int rpcTimeout) Result[]call(int timeout) Computes a result, or throws an exception if unable to do so.intReturns Some details from the implementation that we would like to add to a terminating exception; i.e.private intAs we have a call sequence for scan, it is useless to have a different rpc timeout which is less than the scan timeout.(package private) booleanbooleanReturns true when the most recent RPC response indicated that the response was a heartbeat message.private booleanvoidprepare(boolean reload) Prepare by setting up any connections to servers, etc., ahead of call invocation.voidsetCaching(int caching) voidsetClose()voidsetRenew(boolean val) private voidsetStartRowForReplicaCallable(ScannerCallable callable) Set the start row for the replica callable based on the state of the last result received.longsleep(long pause, int tries) Sleep and retry.booleanWhen a scanner switches in the middle of scanning (the 'next' call fails for example), the upper layerClientScannerneeds to knowvoidCalled when call throws an exception and we are going to retry; take action to make it so we succeed on next call (clear caches, do relookup of locations, etc.).private voidupdateCurrentlyServingReplica(ScannerCallable scanner, Result[] result, AtomicBoolean done, ExecutorService pool)
-
Field Details
-
LOG
-
currentScannerCallable
-
replicaSwitched
-
cConnection
-
pool
-
useScannerTimeoutForNextCalls
-
timeBeforeReplicas
-
scan
-
retries
-
lastResult
-
caller
-
tableName
-
conf
-
scannerTimeout
-
readRpcTimeout
-
outstandingCallables
-
someRPCcancelled
-
regionReplication
-
-
Constructor Details
-
ScannerCallableWithReplicas
public ScannerCallableWithReplicas(TableName tableName, ClusterConnection cConnection, ScannerCallable baseCallable, ExecutorService pool, int timeBeforeReplicas, Scan scan, int retries, int readRpcTimeout, int scannerTimeout, boolean useScannerTimeoutForNextCalls, int caching, org.apache.hadoop.conf.Configuration conf, RpcRetryingCaller<Result[]> caller)
-
-
Method Details
-
setClose
-
setRenew
-
setCaching
-
getCaching
-
getHRegionInfo
-
moreResultsInRegion
-
moreResultsForScan
-
call
Description copied from interface:RetryingCallableComputes a result, or throws an exception if unable to do so.- Specified by:
callin interfaceRetryingCallable<Result[]>- Parameters:
timeout- - the time available for this call. 0 for infinite.- Returns:
- computed result
- Throws:
IOException
-
updateCurrentlyServingReplica
private void updateCurrentlyServingReplica(ScannerCallable scanner, Result[] result, AtomicBoolean done, ExecutorService pool) -
switchedToADifferentReplica
When a scanner switches in the middle of scanning (the 'next' call fails for example), the upper layerClientScannerneeds to know -
isHeartbeatMessage
Returns true when the most recent RPC response indicated that the response was a heartbeat message. Heartbeat messages are sent back from the server when the processing of the scan request exceeds a certain time threshold. Heartbeats allow the server to avoid timeouts during long running scan operations. -
getCursor
-
addCallsForCurrentReplica
private void addCallsForCurrentReplica(ResultBoundedCompletionService<Pair<Result[], ScannerCallable>> cs, int rpcTimeout) -
getRpcTimeout
As we have a call sequence for scan, it is useless to have a different rpc timeout which is less than the scan timeout. If the server does not respond in time(usually this will not happen as we have heartbeat now), we will get an OutOfOrderScannerNextException when resending the next request and the only way to fix this is to close the scanner and open a new one.The legacy behavior of ScannerCallable has been to use readRpcTimeout despite the above. If using legacy behavior, we always use that.
If new behavior is enabled, we determine the rpc timeout to use based on whether the scanner is open. If scanner is open, use scannerTimeout otherwise use readRpcTimeout.
-
isNextCall
-
addCallsForOtherReplicas
private void addCallsForOtherReplicas(ResultBoundedCompletionService<Pair<Result[], ScannerCallable>> cs, int min, int max, int rpcTimeout) -
setStartRowForReplicaCallable
Set the start row for the replica callable based on the state of the last result received.- Parameters:
callable- The callable to set the start row on
-
isAnyRPCcancelled
boolean isAnyRPCcancelled() -
prepare
Description copied from interface:RetryingCallablePrepare by setting up any connections to servers, etc., ahead of call invocation. TODO: We call prepare before EVERY call. Seems wrong. FIX!!!!- Specified by:
preparein interfaceRetryingCallable<Result[]>- Parameters:
reload- Set this to true if need to requery locations- Throws:
IOException- e
-
throwable
Description copied from interface:RetryingCallableCalled when call throws an exception and we are going to retry; take action to make it so we succeed on next call (clear caches, do relookup of locations, etc.).- Specified by:
throwablein interfaceRetryingCallable<Result[]>- Parameters:
t- throwable which was thrownretrying- True if we are in retrying mode (we are not in retrying mode when max retries == 1; we ARE in retrying mode if retries > 1 even when we are the last attempt)
-
getExceptionMessageAdditionalDetail
Description copied from interface:RetryingCallableReturns Some details from the implementation that we would like to add to a terminating exception; i.e. a fatal exception is being thrown ending retries and we might like to add more implementation-specific detail on to the exception being thrown.- Specified by:
getExceptionMessageAdditionalDetailin interfaceRetryingCallable<Result[]>
-
sleep
Description copied from interface:RetryingCallableSleep and retry.- Specified by:
sleepin interfaceRetryingCallable<Result[]>- Parameters:
pause- time to pausetries- amount of tries until till sleep- Returns:
- Suggestion on how much to sleep between retries
-