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 Details

    • connection

      private final Connection connection
    • tableName

      private final TableName tableName
    • row

      private final byte[] row
    • location

      Some subclasses want to set their own location. Make it protected.
    • stub

      protected S stub
    • rpcController

      protected final 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. Can be null!
    • priority

      private int priority
    • requestAttributes

      protected final Map<String,byte[]> 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 which row belongs.
      row - The row we want in tableName.
    • 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

      protected org.apache.hbase.thirdparty.com.google.protobuf.RpcController getRpcController()
    • setStub

      protected void setStub(S stub)
    • getStub

      protected S getStub()
    • call

      public T call(int callTimeout) throws IOException
      Override that changes call Exception from Exception to IOException. Also does set up of the rpcController.
      Specified by:
      call in interface RetryingCallable<T>
      Parameters:
      callTimeout - - the time available for this call. 0 for infinite.
      Returns:
      computed result
      Throws:
      IOException
    • rpcCall

      protected abstract T rpcCall() throws Exception
      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

      protected void setRpcControllerCellScanner(CellScanner cellScanner)
    • getConnection

      Returns ClusterConnection instance used by this Callable.
    • getLocation

    • setLocation

      protected void setLocation(HRegionLocation location)
    • getTableName

    • getRow

      public byte[] getRow()
    • getPriority

      protected int getPriority()
    • throwable

      public void throwable(Throwable t, boolean retrying)
      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 interface RetryingCallable<T>
      Parameters:
      t - throwable which was thrown
      retrying - 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 interface RetryingCallable<T>
    • sleep

      public long sleep(long pause, int tries)
      Description copied from interface: RetryingCallable
      Sleep and retry.
      Specified by:
      sleep in interface RetryingCallable<T>
      Parameters:
      pause - time to pause
      tries - amount of tries until till sleep
      Returns:
      Suggestion on how much to sleep between retries
    • getHRegionInfo

      Returns the HRegionInfo for the current region
    • prepare

      public void prepare(boolean reload) throws IOException
      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 interface RetryingCallable<T>
      Parameters:
      reload - Set this to true if need to requery locations
      Throws:
      IOException - e
    • setStubByServiceName

      protected abstract void setStubByServiceName(ServerName serviceName) throws IOException
      Set the RCP client stub
      Parameters:
      serviceName - to get the rpc stub for
      Throws:
      IOException - When client could not be created