@InterfaceAudience.Private public class RpcClient extends Object
See HBaseServer
Modifier and Type | Class and Description |
---|---|
static class |
RpcClient.BlockingRpcChannelImplementation
Blocking rpc channel that goes via hbase rpc.
|
protected class |
RpcClient.Call
A call waiting for a value.
|
static class |
RpcClient.CallTimeoutException
Client-side call timeout
|
protected class |
RpcClient.Connection
Thread that reads responses and notifies callers.
|
protected static class |
RpcClient.ConnectionId
This class holds the address and the user ticket, etc.
|
static class |
RpcClient.FailedServerException |
Constructor and Description |
---|
RpcClient(org.apache.hadoop.conf.Configuration conf,
String clusterId)
Construct an IPC client for the cluster
clusterId with the default SocketFactory |
RpcClient(org.apache.hadoop.conf.Configuration conf,
String clusterId,
SocketAddress localAddr)
Construct an IPC client for the cluster
clusterId with the default SocketFactory |
Modifier and Type | Method and Description |
---|---|
void |
cancelConnections(String hostname,
int port,
IOException ioe)
Interrupt the connections to the given ip:port server.
|
BlockingRpcChannel |
createBlockingRpcChannel(ServerName sn,
User ticket,
int rpcTimeout)
Creates a "channel" that can be used by a blocking protobuf service.
|
protected RpcClient.Connection |
createConnection(RpcClient.ConnectionId remoteId,
Codec codec,
org.apache.hadoop.io.compress.CompressionCodec compressor)
Creates a connection.
|
protected RpcClient.Connection |
getConnection(User ticket,
RpcClient.Call call,
InetSocketAddress addr,
int rpcTimeout,
Codec codec,
org.apache.hadoop.io.compress.CompressionCodec compressor) |
static String |
getDefaultCodec(org.apache.hadoop.conf.Configuration c) |
protected static int |
getPoolSize(org.apache.hadoop.conf.Configuration config)
Return the pool size specified in the configuration, which is applicable only if
the pool type is
PoolMap.PoolType.RoundRobin . |
protected static PoolMap.PoolType |
getPoolType(org.apache.hadoop.conf.Configuration config)
Return the pool type specified in the configuration, which must be set to
either
PoolMap.PoolType.RoundRobin or PoolMap.PoolType.ThreadLocal ,
otherwise default to the former. |
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 void |
resetRpcTimeout() |
static void |
setPingInterval(org.apache.hadoop.conf.Configuration conf,
int pingInterval)
set the ping interval value in configuration
|
static void |
setRpcTimeout(int t) |
static void |
setSocketTimeout(org.apache.hadoop.conf.Configuration conf,
int socketTimeout)
Set the socket timeout
|
void |
stop()
Stop all threads related to this client.
|
protected IOException |
wrapException(InetSocketAddress addr,
IOException exception)
Take an IOException and the address we were trying to connect to
and return an IOException with the input exception as the cause.
|
public static final org.apache.commons.logging.Log LOG
protected final PoolMap<RpcClient.ConnectionId,RpcClient.Connection> connections
protected int counter
protected final AtomicBoolean running
protected final org.apache.hadoop.conf.Configuration conf
protected final int maxIdleTime
protected final int maxRetries
protected final long failureSleep
protected final boolean tcpNoDelay
protected final boolean tcpKeepAlive
protected int pingInterval
protected org.apache.hadoop.hbase.ipc.RpcClient.FailedServers failedServers
protected final SocketFactory socketFactory
protected String clusterId
protected final SocketAddress localAddr
public static final String PING_INTERVAL_NAME
public static final String SOCKET_TIMEOUT
public static final String FAILED_SERVER_EXPIRY_KEY
public static final int FAILED_SERVER_EXPIRY_DEFAULT
public static final String IPC_CLIENT_FALLBACK_TO_SIMPLE_AUTH_ALLOWED_KEY
public static final boolean IPC_CLIENT_FALLBACK_TO_SIMPLE_AUTH_ALLOWED_DEFAULT
protected static final Map<AuthenticationProtos.TokenIdentifier.Kind,org.apache.hadoop.security.token.TokenSelector<? extends org.apache.hadoop.security.token.TokenIdentifier>> tokenHandlers
public RpcClient(org.apache.hadoop.conf.Configuration conf, String clusterId)
clusterId
with the default SocketFactoryconf
- configurationclusterId
- public RpcClient(org.apache.hadoop.conf.Configuration conf, String clusterId, SocketAddress localAddr)
clusterId
with the default SocketFactoryconf
- configurationclusterId
- localAddr
- client socket bind address.public static void setPingInterval(org.apache.hadoop.conf.Configuration conf, int pingInterval)
conf
- ConfigurationpingInterval
- the ping intervalpublic static void setSocketTimeout(org.apache.hadoop.conf.Configuration conf, int socketTimeout)
conf
- ConfigurationsocketTimeout
- the socket timeoutprotected RpcClient.Connection createConnection(RpcClient.ConnectionId remoteId, Codec codec, org.apache.hadoop.io.compress.CompressionCodec compressor) throws IOException
remoteId
- - the ConnectionId to use for the connection creation.IOException
public static String getDefaultCodec(org.apache.hadoop.conf.Configuration c)
protected static PoolMap.PoolType getPoolType(org.apache.hadoop.conf.Configuration config)
PoolMap.PoolType.RoundRobin
or PoolMap.PoolType.ThreadLocal
,
otherwise default to the former.
For applications with many user threads, use a small round-robin pool. For
applications with few user threads, you may want to try using a
thread-local pool. In any case, the number of RpcClient
instances
should not exceed the operating system's hard limit on the number of
connections.config
- configurationPoolMap.PoolType.RoundRobin
or
PoolMap.PoolType.ThreadLocal
protected static int getPoolSize(org.apache.hadoop.conf.Configuration config)
PoolMap.PoolType.RoundRobin
.config
- public void stop()
protected IOException wrapException(InetSocketAddress addr, IOException exception)
addr
- target addressexception
- the relevant exceptionpublic void cancelConnections(String hostname, int port, IOException ioe)
protected RpcClient.Connection getConnection(User ticket, RpcClient.Call call, InetSocketAddress addr, int rpcTimeout, Codec codec, org.apache.hadoop.io.compress.CompressionCodec compressor) throws IOException, InterruptedException
IOException
InterruptedException
public static void setRpcTimeout(int t)
public static int getRpcTimeout()
public static int getRpcTimeout(int defaultTimeout)
setRpcTimeout(int)
and the given
default timeout.public static void resetRpcTimeout()
public BlockingRpcChannel createBlockingRpcChannel(ServerName sn, User ticket, int rpcTimeout)
sn
- ticket
- rpcTimeout
- Copyright © 2015 The Apache Software Foundation. All Rights Reserved.