org.apache.hadoop.hbase.ipc
Class HBaseRPC

java.lang.Object
  extended by org.apache.hadoop.hbase.ipc.HBaseRPC

public class HBaseRPC
extends Object

A simple RPC mechanism. This is a local hbase copy of the hadoop RPC so we can do things like address HADOOP-414 for hbase-only and try other hbase-specific optimizations like using our own version of ObjectWritable. Class has been renamed to avoid confusing it w/ hadoop versions.

A protocol is a Java interface. All parameters and return types must be one of:

All methods in the protocol should throw only IOException. No field data of the protocol instance is transmitted.


Nested Class Summary
static class HBaseRPC.UnknownProtocolException
          An error requesting an RPC protocol that the server is not serving.
static class HBaseRPC.VersionMismatch
          A version mismatch for the RPC protocol.
 
Field Summary
protected static org.apache.commons.logging.Log LOG
           
static String RPC_ENGINE_PROP
          Configuration key for the RpcEngine implementation to load to handle connection protocols.
 
Method Summary
static Object[] call(Method method, Object[][] params, InetSocketAddress[] addrs, Class<? extends VersionedProtocol> protocol, User ticket, org.apache.hadoop.conf.Configuration conf)
          Deprecated. Instead of calling statically, use getProtocolEngine(org.apache.hadoop.conf.Configuration) to obtain an RpcEngine instance and then use RpcEngine.call(java.lang.reflect.Method, Object[][], java.net.InetSocketAddress[], Class, org.apache.hadoop.hbase.security.User, org.apache.hadoop.conf.Configuration)
static RpcEngine getProtocolEngine(org.apache.hadoop.conf.Configuration conf)
          Returns a new instance of the configured RpcEngine implementation.
static int getRpcTimeout()
           
static int getRpcTimeout(int defaultTimeout)
          Returns the lower of the thread-local RPC time from setRpcTimeout(int) and the given default timeout.
static RpcServer getServer(Class protocol, Object instance, Class<?>[] ifaces, String bindAddress, int port, int numHandlers, int metaHandlerCount, boolean verbose, org.apache.hadoop.conf.Configuration conf, int highPriorityLevel)
          Construct a server for a protocol implementation instance.
static RpcServer getServer(Object instance, Class<?>[] ifaces, String bindAddress, int port, int numHandlers, int metaHandlerCount, boolean verbose, org.apache.hadoop.conf.Configuration conf, int highPriorityLevel)
          Construct a server for a protocol implementation instance listening on a port and address.
static void resetRpcTimeout()
           
static void setRpcTimeout(int rpcTimeout)
           
static
<T extends VersionedProtocol>
T
waitForProxy(RpcEngine rpcClient, Class<T> protocol, long clientVersion, InetSocketAddress addr, org.apache.hadoop.conf.Configuration conf, int maxAttempts, int rpcTimeout, long timeout)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

protected static final org.apache.commons.logging.Log LOG

RPC_ENGINE_PROP

public static final String RPC_ENGINE_PROP
Configuration key for the RpcEngine implementation to load to handle connection protocols. Handlers for individual protocols can be configured using "hbase.rpc.engine." + protocol.class.name.

See Also:
Constant Field Values
Method Detail

getProtocolEngine

public static RpcEngine getProtocolEngine(org.apache.hadoop.conf.Configuration conf)
Returns a new instance of the configured RpcEngine implementation.


waitForProxy

public static <T extends VersionedProtocol> T waitForProxy(RpcEngine rpcClient,
                                                           Class<T> protocol,
                                                           long clientVersion,
                                                           InetSocketAddress addr,
                                                           org.apache.hadoop.conf.Configuration conf,
                                                           int maxAttempts,
                                                           int rpcTimeout,
                                                           long timeout)
                                                throws IOException
Parameters:
protocol - protocol interface
clientVersion - which client version we expect
addr - address of remote service
conf - configuration
maxAttempts - max attempts
rpcTimeout - timeout for each RPC
timeout - timeout in milliseconds
Returns:
proxy
Throws:
IOException - e

call

@Deprecated
public static Object[] call(Method method,
                                       Object[][] params,
                                       InetSocketAddress[] addrs,
                                       Class<? extends VersionedProtocol> protocol,
                                       User ticket,
                                       org.apache.hadoop.conf.Configuration conf)
                     throws IOException,
                            InterruptedException
Deprecated. Instead of calling statically, use getProtocolEngine(org.apache.hadoop.conf.Configuration) to obtain an RpcEngine instance and then use RpcEngine.call(java.lang.reflect.Method, Object[][], java.net.InetSocketAddress[], Class, org.apache.hadoop.hbase.security.User, org.apache.hadoop.conf.Configuration)

Expert: Make multiple, parallel calls to a set of servers.

Parameters:
method - method to invoke
params - array of parameters
addrs - array of addresses
conf - configuration
Returns:
values
Throws:
IOException - e
InterruptedException

getServer

public static RpcServer getServer(Object instance,
                                  Class<?>[] ifaces,
                                  String bindAddress,
                                  int port,
                                  int numHandlers,
                                  int metaHandlerCount,
                                  boolean verbose,
                                  org.apache.hadoop.conf.Configuration conf,
                                  int highPriorityLevel)
                           throws IOException
Construct a server for a protocol implementation instance listening on a port and address.

Parameters:
instance - instance
bindAddress - bind address
port - port to bind to
numHandlers - number of handlers to start
verbose - verbose flag
conf - configuration
Returns:
Server
Throws:
IOException - e

getServer

public static RpcServer getServer(Class protocol,
                                  Object instance,
                                  Class<?>[] ifaces,
                                  String bindAddress,
                                  int port,
                                  int numHandlers,
                                  int metaHandlerCount,
                                  boolean verbose,
                                  org.apache.hadoop.conf.Configuration conf,
                                  int highPriorityLevel)
                           throws IOException
Construct a server for a protocol implementation instance.

Throws:
IOException

setRpcTimeout

public static void setRpcTimeout(int rpcTimeout)

getRpcTimeout

public static int getRpcTimeout()

resetRpcTimeout

public static void resetRpcTimeout()

getRpcTimeout

public static int getRpcTimeout(int defaultTimeout)
Returns the lower of the thread-local RPC time from setRpcTimeout(int) and the given default timeout.



Copyright © 2014 The Apache Software Foundation. All Rights Reserved.