Interface AsyncTable.CoprocessorCallback<R>
- All Known Subinterfaces:
AsyncTable.PartialResultCoprocessorCallback<S,
R>
- All Known Implementing Classes:
NoopPartialResultCoprocessorCallback
- Enclosing interface:
- AsyncTable<C extends ScanResultConsumerBase>
As the locating itself also takes some time, the implementation may want to send rpc calls on
the fly, which means we do not know how many regions we have when we get the return value of
the rpc calls, so we need an onComplete()
which is used to tell you that we have
passed all the return values to you(through the onRegionComplete(RegionInfo, Object)
or onRegionError(RegionInfo, Throwable)
calls), i.e, there will be no
onRegionComplete(RegionInfo, Object)
or onRegionError(RegionInfo, Throwable)
calls in the future.
Here is a pseudo code to describe a typical implementation of a range coprocessor service
method to help you better understand how the AsyncTable.CoprocessorCallback
will be called. The
callback
in the pseudo code is our AsyncTable.CoprocessorCallback
. And notice that the
whenComplete
is CompletableFuture.whenComplete
.
locateThenCall(byte[] row) { locate(row).whenComplete((location, locateError) -> { if (locateError != null) { callback.onError(locateError); return; } incPendingCall(); region = location.getRegion(); if (region.getEndKey() > endKey) { locateEnd = true; } else { locateThenCall(region.getEndKey()); } sendCall().whenComplete((resp, error) -> { if (error != null) { callback.onRegionError(region, error); } else { callback.onRegionComplete(region, resp); } if (locateEnd && decPendingCallAndGet() == 0) { callback.onComplete(); } }); }); }
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Indicate that all responses of the regions have been notified by callingonRegionComplete(RegionInfo, Object)
oronRegionError(RegionInfo, Throwable)
.void
Indicate that we got an error which does not belong to any regions.void
onRegionComplete
(RegionInfo region, R resp) Indicate that the respose of a region is availablevoid
onRegionError
(RegionInfo region, Throwable error) Indicate that the error for a region is available
-
Method Details
-
onRegionComplete
Indicate that the respose of a region is available- Parameters:
region
- the region that the response belongs toresp
- the response of the coprocessor call
-
onRegionError
Indicate that the error for a region is available- Parameters:
region
- the region that the error belongs toerror
- the response error of the coprocessor call
-
onComplete
void onComplete()Indicate that all responses of the regions have been notified by callingonRegionComplete(RegionInfo, Object)
oronRegionError(RegionInfo, Throwable)
. -
onError
Indicate that we got an error which does not belong to any regions. Usually a locating error.
-