T
- The class that the ServerCallable handles.S
- The protocol to use (Admin or Client or even an Endpoint over in MetaTableAccessor).@InterfaceAudience.Private public abstract class RegionServerCallable<T,S> extends Object implements RetryingCallable<T>
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.
Modifier and Type | Field and Description |
---|---|
private Connection |
connection |
protected HRegionLocation |
location
Some subclasses want to set their own location.
|
private int |
priority |
private byte[] |
row |
protected org.apache.hbase.thirdparty.com.google.protobuf.RpcController |
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 |
stub |
private TableName |
tableName |
Constructor and Description |
---|
RegionServerCallable(Connection connection,
TableName tableName,
byte[] row,
org.apache.hbase.thirdparty.com.google.protobuf.RpcController rpcController) |
RegionServerCallable(Connection connection,
TableName tableName,
byte[] row,
org.apache.hbase.thirdparty.com.google.protobuf.RpcController rpcController,
int priority) |
Modifier and Type | Method and Description |
---|---|
T |
call(int callTimeout)
Override that changes call Exception from
Exception to IOException . |
protected ClusterConnection |
getConnection() |
String |
getExceptionMessageAdditionalDetail() |
HRegionInfo |
getHRegionInfo() |
protected HRegionLocation |
getLocation() |
protected int |
getPriority() |
byte[] |
getRow() |
protected org.apache.hbase.thirdparty.com.google.protobuf.RpcController |
getRpcController() |
protected CellScanner |
getRpcControllerCellScanner()
Get the RpcController CellScanner.
|
protected S |
getStub() |
TableName |
getTableName() |
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 |
setStub(S stub) |
protected abstract void |
setStubByServiceName(ServerName serviceName)
Set the RCP client stub
|
long |
sleep(long pause,
int tries) |
void |
throwable(Throwable t,
boolean retrying)
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.).
|
private final Connection connection
private final byte[] row
protected HRegionLocation location
protected final org.apache.hbase.thirdparty.com.google.protobuf.RpcController rpcController
private int priority
public RegionServerCallable(Connection connection, TableName tableName, byte[] row, org.apache.hbase.thirdparty.com.google.protobuf.RpcController rpcController)
connection
- Connection to use.rpcController
- Controller to use; can be shaded or non-shaded.tableName
- Table name to which row
belongs.row
- The row we want in tableName
.public RegionServerCallable(Connection connection, TableName tableName, byte[] row, org.apache.hbase.thirdparty.com.google.protobuf.RpcController rpcController, int priority)
protected org.apache.hbase.thirdparty.com.google.protobuf.RpcController getRpcController()
public T call(int callTimeout) throws IOException
Exception
to IOException
.
Also does set up of the rpcController.call
in interface RetryingCallable<T>
callTimeout
- - the time available for this call. 0 for infinite.IOException
protected abstract T rpcCall() throws Exception
Exception
protected CellScanner getRpcControllerCellScanner()
protected void setRpcControllerCellScanner(CellScanner cellScanner)
protected ClusterConnection getConnection()
ClusterConnection
instance used by this Callable.protected HRegionLocation getLocation()
protected void setLocation(HRegionLocation location)
public TableName getTableName()
public byte[] getRow()
protected int getPriority()
public void throwable(Throwable t, boolean retrying)
RetryingCallable
throwable
in interface RetryingCallable<T>
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)public String getExceptionMessageAdditionalDetail()
getExceptionMessageAdditionalDetail
in interface RetryingCallable<T>
public long sleep(long pause, int tries)
sleep
in interface RetryingCallable<T>
pause
- time to pausetries
- amount of tries until till sleeppublic HRegionInfo getHRegionInfo()
public void prepare(boolean reload) throws IOException
RetryingCallable
prepare
in interface RetryingCallable<T>
reload
- Set this to true if need to requery locationsIOException
- eprotected abstract void setStubByServiceName(ServerName serviceName) throws IOException
serviceName
- to get the rpc stub forIOException
- When client could not be createdCopyright © 2007–2019 The Apache Software Foundation. All rights reserved.