@InterfaceAudience.Public
public interface RawScanResultConsumer
Result
for an asynchronous scan.
Notice that, the onNext(Result[], ScanController)
method will be called in the thread
which we send request to HBase service. So if you want the asynchronous scanner fetch data from
HBase in background while you process the returned data, you need to move the processing work to
another thread to make the onNext
call return immediately. And please do NOT do any time
consuming tasks in all methods below unless you know what you are doing.
Modifier and Type | Interface and Description |
---|---|
static interface |
RawScanResultConsumer.ScanController
Used to suspend or stop a scan, or get a scan cursor if available.
|
static interface |
RawScanResultConsumer.ScanResumer
Used to resume a scan.
|
Modifier and Type | Method and Description |
---|---|
void |
onComplete()
Indicate that the scan operation is completed normally.
|
void |
onError(Throwable error)
Indicate that we hit an unrecoverable error and the scan operation is terminated.
|
default void |
onHeartbeat(RawScanResultConsumer.ScanController controller)
Indicate that there is a heartbeat message but we have not cumulated enough cells to call
onNext(Result[], ScanController) . |
void |
onNext(Result[] results,
RawScanResultConsumer.ScanController controller)
Indicate that we have receive some data.
|
default void |
onScanMetricsCreated(ScanMetrics scanMetrics)
If
scan.isScanMetricsEnabled() returns true, then this method will be called prior to
all other methods in this interface to give you the ScanMetrics instance for this scan
operation. |
void onNext(Result[] results, RawScanResultConsumer.ScanController controller)
results
- the data fetched from HBase service.controller
- used to suspend or terminate the scan. Notice that the controller
instance is only valid within scope of onNext method. You can only call its method in
onNext, do NOT store it and call it later outside onNext.default void onHeartbeat(RawScanResultConsumer.ScanController controller)
onNext(Result[], ScanController)
.
Note that this method will always be called when RS returns something to us but we do not have
enough cells to call onNext(Result[], ScanController)
. Sometimes it may not be a
'heartbeat' message for RS, for example, we have a large row with many cells and size limit is
exceeded before sending all the cells for this row. For RS it does send some data to us and the
time limit has not been reached, but we can not return the data to client so here we call this
method to tell client we have already received something.
This method give you a chance to terminate a slow scan operation.
controller
- used to suspend or terminate the scan. Notice that the controller
instance is only valid within the scope of onHeartbeat method. You can only call its
method in onHeartbeat, do NOT store it and call it later outside onHeartbeat.void onError(Throwable error)
We will not call onComplete()
after calling onError(Throwable)
.
void onComplete()
default void onScanMetricsCreated(ScanMetrics scanMetrics)
scan.isScanMetricsEnabled()
returns true, then this method will be called prior to
all other methods in this interface to give you the ScanMetrics
instance for this scan
operation. The ScanMetrics
instance will be updated on-the-fly during the scan, you can
store it somewhere to get the metrics at any time if you want.Copyright © 2007–2017 The Apache Software Foundation. All rights reserved.