Package org.apache.hadoop.hbase.client
Class RegionServerCallable<T,S>
java.lang.Object
org.apache.hadoop.hbase.client.RegionServerCallable<T,S>
- Type Parameters:
T- The class that the ServerCallable handles.S- The protocol to use (Admin or Client or even an Endpoint over in MetaTableAccessor).
- All Implemented Interfaces:
RetryingCallable<T>
- Direct Known Subclasses:
ClientServiceCallable
@Private
public abstract class RegionServerCallable<T,S>
extends Object
implements RetryingCallable<T>
Implementations make a RPC call against a RegionService via a protobuf Service. Implement
rpcCall() and the parent class setClientByServiceName; this latter is where the RPC stub gets set
(the appropriate protobuf 'Service'/Client). Be sure to make use of the RpcController that this
instance is carrying via #getRpcController().
TODO: this class is actually tied to one region, because most of the paths make use of the regioninfo part of location when building requests. The only reason it works for multi-region requests (e.g. batch) is that they happen to not use the region parts. This could be done cleaner (e.g. having a generic parameter and 2 derived classes, RegionCallable and actual RegionServerCallable with ServerName.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Connectionprotected HRegionLocationSome subclasses want to set their own location.private intprivate final byte[]protected final org.apache.hbase.thirdparty.com.google.protobuf.RpcControllerThis is 99% of the time a HBaseRpcController but also used doing Coprocessor Endpoints and in this case, it is a ServerRpcControllable which is not a HBaseRpcController.protected Sprivate final TableName -
Constructor Summary
ConstructorsConstructorDescriptionRegionServerCallable(Connection connection, TableName tableName, byte[] row, org.apache.hbase.thirdparty.com.google.protobuf.RpcController rpcController, int priority, Map<String, byte[]> requestAttributes) RegionServerCallable(Connection connection, TableName tableName, byte[] row, org.apache.hbase.thirdparty.com.google.protobuf.RpcController rpcController, Map<String, byte[]> requestAttributes) -
Method Summary
Modifier and TypeMethodDescriptioncall(int callTimeout) Override that changes call Exception fromExceptiontoIOException.protected ClusterConnectionReturnsClusterConnectioninstance used by this Callable.Returns Some details from the implementation that we would like to add to a terminating exception; i.e.Returns the HRegionInfo for the current regionprotected HRegionLocationprotected intbyte[]getRow()protected org.apache.hbase.thirdparty.com.google.protobuf.RpcControllerprotected CellScannerGet the RpcController CellScanner.protected SgetStub()voidprepare(boolean reload) Prepare by setting up any connections to servers, etc., ahead of call invocation.protected abstract TrpcCall()Run the RPC call.protected voidsetLocation(HRegionLocation location) protected voidsetRpcControllerCellScanner(CellScanner cellScanner) protected voidprotected abstract voidsetStubByServiceName(ServerName serviceName) Set the RCP client stublongsleep(long pause, int tries) Sleep and retry.voidCalled 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.).
-
Field Details
-
connection
-
tableName
-
row
-
location
Some subclasses want to set their own location. Make it protected. -
stub
-
rpcController
This is 99% of the time a HBaseRpcController but also used doing Coprocessor Endpoints and in this case, it is a ServerRpcControllable which is not a HBaseRpcController. Can be null! -
priority
-
requestAttributes
-
-
Constructor Details
-
RegionServerCallable
public RegionServerCallable(Connection connection, TableName tableName, byte[] row, org.apache.hbase.thirdparty.com.google.protobuf.RpcController rpcController, Map<String, byte[]> requestAttributes) - Parameters:
connection- Connection to use.rpcController- Controller to use; can be shaded or non-shaded.tableName- Table name to whichrowbelongs.row- The row we want intableName.
-
RegionServerCallable
public RegionServerCallable(Connection connection, TableName tableName, byte[] row, org.apache.hbase.thirdparty.com.google.protobuf.RpcController rpcController, int priority, Map<String, byte[]> requestAttributes)
-
-
Method Details
-
getRpcController
-
setStub
-
getStub
-
call
Override that changes call Exception fromExceptiontoIOException. Also does set up of the rpcController.- Specified by:
callin interfaceRetryingCallable<T>- Parameters:
callTimeout- - the time available for this call. 0 for infinite.- Returns:
- computed result
- Throws:
IOException
-
rpcCall
Run the RPC call. Implement this method. To get at the rpcController that has been created and configured to make this rpc call, use getRpcController(). We are trying to contain rpcController references so we don't pollute codebase with protobuf references; keep the protobuf references contained and only present in a few classes rather than all about the code base.- Throws:
Exception
-
getRpcControllerCellScanner
Get the RpcController CellScanner. If the RpcController is a HBaseRpcController, which it is in all cases except when we are processing Coprocessor Endpoint, then this method returns a reference to the CellScanner that the HBaseRpcController is carrying. Do it up here in this Callable so we don't have to scatter ugly instanceof tests around the codebase. Will return null if called in a Coproccessor Endpoint context. Should never happen. -
setRpcControllerCellScanner
-
getConnection
ReturnsClusterConnectioninstance used by this Callable. -
getLocation
-
setLocation
-
getTableName
-
getRow
-
getPriority
-
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<T>- 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<T>
-
sleep
Description copied from interface:RetryingCallableSleep and retry.- Specified by:
sleepin interfaceRetryingCallable<T>- Parameters:
pause- time to pausetries- amount of tries until till sleep- Returns:
- Suggestion on how much to sleep between retries
-
getHRegionInfo
Returns the HRegionInfo for the current region -
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<T>- Parameters:
reload- Set this to true if need to requery locations- Throws:
IOException- e
-
setStubByServiceName
Set the RCP client stub- Parameters:
serviceName- to get the rpc stub for- Throws:
IOException- When client could not be created
-