Package org.apache.hadoop.hbase.client
Class ClientScanner
java.lang.Object
org.apache.hadoop.hbase.client.AbstractClientScanner
org.apache.hadoop.hbase.client.ClientScanner
- All Implemented Interfaces:
Closeable,AutoCloseable,Iterable<Result>,ResultScanner
- Direct Known Subclasses:
ClientSimpleScanner,ReversedClientScanner
Implements the scanner interface for the HBase client. If there are multiple regions in a table,
this scanner will iterate through them all.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final intprotected ScannerCallableWithReplicasprotected RpcRetryingCaller<Result[]>protected booleanprotected org.apache.hadoop.conf.Configurationprivate final ClusterConnectionprotected HRegionInfoprotected longprotected Resultprivate static final org.slf4j.Loggerprotected final longprotected final ExecutorServiceprotected final intprotected final intprivate intprotected RpcControllerFactoryprotected final Scanprivate final Scanprotected booleanprotected final intprivate final ScanResultCacheprotected final io.opentelemetry.api.trace.Spanprotected final TableNameprivate final booleanFields inherited from class org.apache.hadoop.hbase.client.AbstractClientScanner
scanMetrics -
Constructor Summary
ConstructorsConstructorDescriptionClientScanner(org.apache.hadoop.conf.Configuration conf, Scan scan, Scan scanForMetrics, TableName tableName, ClusterConnection connection, RpcRetryingCallerFactory rpcFactory, RpcControllerFactory controllerFactory, ExecutorService pool, int scanReadRpcTimeout, int scannerTimeout, int primaryOperationTimeout, ConnectionConfiguration connectionConfiguration, Map<String, byte[]> requestAttributes) Create a new ClientScanner for the specified table Note that the passedScan's start row maybe changed changed. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddEstimatedSize(long estimatedHeapSizeOfResult) private Result[]call(ScannerCallableWithReplicas callable, RpcRetryingCaller<Result[]> caller, int scannerTimeout, boolean updateCurrentRegion) voidclose()Closes the scanner and releases any resources it has allocatedprivate voidprivate voidcloseScannerIfExhausted(boolean exhausted) protected abstract ScannerCallableWill be called in moveToNextRegion to create ScannerCallable.intintprotected intprotected org.apache.hadoop.conf.ConfigurationgetConf()protected ClusterConnectionprotected longprotected ExecutorServicegetPool()protected intprotected intprotected ScangetScan()protected intprotected final intprotected TableNamegetTable()protected longprivate voidhandleScanError(DoNotRetryIOException e, org.apache.commons.lang3.mutable.MutableBoolean retryAfterOutOfOrderException, int retriesLeft) protected voidprotected void(package private) booleanprotected voidContact the servers to load moreResults in the cache.protected booleanClose the previous scanner and create a new ScannerCallable for the next scanner.next()Grab the next row's worth of values.protected Resultprivate booleanregionExhausted(Result[] values) booleanAllow the client to renew the scanner's lease on the server.private booleanprotected abstract booleanWill be called in moveToNextRegion when currentRegion is null.protected voidPublish the scan metrics.Methods inherited from class org.apache.hadoop.hbase.client.AbstractClientScanner
getScanMetrics, initScanMetricsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface org.apache.hadoop.hbase.client.ResultScanner
iterator, next
-
Field Details
-
LOG
-
scan
-
scanForMetrics
-
closed
-
currentRegion
-
callable
-
cache
-
scanResultCache
-
caching
-
lastNext
-
lastResult
-
maxScannerResultSize
-
connection
-
tableName
-
readRpcTimeout
-
scannerTimeout
-
useScannerTimeoutForNextCalls
-
scanMetricsPublished
-
caller
-
rpcControllerFactory
-
conf
-
span
-
-
retries
-
pool
-
requestAttributes
-
-
Constructor Details
-
ClientScanner
public ClientScanner(org.apache.hadoop.conf.Configuration conf, Scan scan, Scan scanForMetrics, TableName tableName, ClusterConnection connection, RpcRetryingCallerFactory rpcFactory, RpcControllerFactory controllerFactory, ExecutorService pool, int scanReadRpcTimeout, int scannerTimeout, int primaryOperationTimeout, ConnectionConfiguration connectionConfiguration, Map<String, byte[]> requestAttributes) throws IOExceptionCreate a new ClientScanner for the specified table Note that the passedScan's start row maybe changed changed.- Parameters:
conf- TheConfigurationto use.scan-Scanto use in this scannertableName- The table that we wish to scanconnection- Connection identifying the cluster- Throws:
IOException
-
-
Method Details
-
getScanReplicaId
-
getConnection
-
getTable
-
getRetries
-
getScannerTimeout
-
getConf
-
getScan
-
getPool
-
getPrimaryOperationTimeout
-
getCaching
-
getTimestamp
-
getMaxResultSize
-
closeScanner
- Throws:
IOException
-
setNewStartKey
Will be called in moveToNextRegion when currentRegion is null. Abstract because for normal scan, we will start next scan from the endKey of the currentRegion, and for reversed scan, we will start next scan from the startKey of the currentRegion.- Returns:
falseif we have reached the stop row. Otherwisetrue.
-
createScannerCallable
Will be called in moveToNextRegion to create ScannerCallable. Abstract because for reversed scan we need to create a ReversedScannerCallable. -
moveToNextRegion
Close the previous scanner and create a new ScannerCallable for the next scanner.Marked as protected only because TestClientScanner need to override this method.
- Returns:
- false if we should terminate the scan. Otherwise
-
isAnyRPCcancelled
boolean isAnyRPCcancelled() -
call
private Result[] call(ScannerCallableWithReplicas callable, RpcRetryingCaller<Result[]> caller, int scannerTimeout, boolean updateCurrentRegion) throws IOException - Throws:
IOException
-
writeScanMetrics
Publish the scan metrics. For now, we use scan.setAttribute to pass the metrics back to the application or TableInputFormat.Later, we could push it to other systems. We don't use metrics framework because it doesn't support multi-instances of the same metrics on the same machine; for scan/map reduce scenarios, we will have multiple scans running at the same time. By default, scan metrics are disabled; if the application wants to collect them, this behavior can be turned on by calling callingScan.setScanMetricsEnabled(boolean) -
initSyncCache
-
nextWithSyncCache
- Throws:
IOException
-
getCacheSize
-
scanExhausted
-
regionExhausted
-
closeScannerIfExhausted
- Throws:
IOException
-
handleScanError
private void handleScanError(DoNotRetryIOException e, org.apache.commons.lang3.mutable.MutableBoolean retryAfterOutOfOrderException, int retriesLeft) throws DoNotRetryIOException - Throws:
DoNotRetryIOException
-
loadCache
Contact the servers to load moreResults in the cache.- Throws:
IOException
-
addEstimatedSize
-
getCacheCount
-
close
Description copied from interface:ResultScannerCloses the scanner and releases any resources it has allocated -
renewLease
Description copied from interface:ResultScannerAllow the client to renew the scanner's lease on the server.- Returns:
- true if the lease was successfully renewed, false otherwise.
-
initCache
-
next
Description copied from interface:ResultScannerGrab the next row's worth of values. The scanner will return a Result.- Returns:
- Result object if there is another row, null if the scanner is exhausted.
- Throws:
IOException- e
-