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
Modifier and TypeFieldDescriptionprivate final Connection
protected HRegionLocation
Some subclasses want to set their own location.private int
private final byte[]
protected final org.apache.hbase.thirdparty.com.google.protobuf.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.protected S
private final TableName
-
Constructor Summary
ConstructorDescriptionRegionServerCallable
(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 fromException
toIOException
.protected ClusterConnection
ReturnsClusterConnection
instance 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 HRegionLocation
protected int
byte[]
getRow()
protected org.apache.hbase.thirdparty.com.google.protobuf.RpcController
protected CellScanner
Get the RpcController CellScanner.protected S
getStub()
void
prepare
(boolean reload) Prepare by setting up any connections to servers, etc., ahead of call invocation.protected abstract T
rpcCall()
Run the RPC call.protected void
setLocation
(HRegionLocation location) protected void
setRpcControllerCellScanner
(CellScanner cellScanner) protected void
protected abstract void
setStubByServiceName
(ServerName serviceName) Set the RCP client stublong
sleep
(long pause, int tries) Sleep and retry.void
Called 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 whichrow
belongs.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 fromException
toIOException
. Also does set up of the rpcController.- Specified by:
call
in 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
ReturnsClusterConnection
instance used by this Callable. -
getLocation
-
setLocation
-
getTableName
-
getRow
-
getPriority
-
throwable
Description copied from interface:RetryingCallable
Called 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:
throwable
in 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:RetryingCallable
Returns 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:
getExceptionMessageAdditionalDetail
in interfaceRetryingCallable<T>
-
sleep
Description copied from interface:RetryingCallable
Sleep and retry.- Specified by:
sleep
in 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:RetryingCallable
Prepare by setting up any connections to servers, etc., ahead of call invocation. TODO: We call prepare before EVERY call. Seems wrong. FIX!!!!- Specified by:
prepare
in 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
-