@InterfaceAudience.Private public class RpcClientImpl extends AbstractRpcClient
See HBaseServer
Modifier and Type | Class and Description |
---|---|
protected class |
RpcClientImpl.Connection
Thread that reads responses and notifies callers.
|
AbstractRpcClient.BlockingRpcChannelImplementation
Modifier and Type | Field and Description |
---|---|
protected AtomicInteger |
callIdCnt |
protected PoolMap<ConnectionId,RpcClientImpl.Connection> |
connections |
protected FailedServers |
failedServers |
protected AtomicBoolean |
running |
protected SocketFactory |
socketFactory |
protected static Map<AuthenticationProtos.TokenIdentifier.Kind,<any>> |
tokenHandlers |
clusterId, codec, compressor, conf, connectTO, failureSleep, fallbackAllowed, ipcUtil, localAddr, LOG, maxRetries, minIdleTimeBeforeClose, readTO, tcpKeepAlive, tcpNoDelay, userProvider, writeTO
DEFAULT_CODEC_CLASS, DEFAULT_SOCKET_TIMEOUT_CONNECT, DEFAULT_SOCKET_TIMEOUT_READ, DEFAULT_SOCKET_TIMEOUT_WRITE, FAILED_SERVER_EXPIRY_DEFAULT, FAILED_SERVER_EXPIRY_KEY, IDLE_TIME, IPC_CLIENT_FALLBACK_TO_SIMPLE_AUTH_ALLOWED_DEFAULT, IPC_CLIENT_FALLBACK_TO_SIMPLE_AUTH_ALLOWED_KEY, PING_CALL_ID, SOCKET_TIMEOUT_CONNECT, SOCKET_TIMEOUT_READ, SOCKET_TIMEOUT_WRITE, SPECIFIC_WRITE_THREAD
Constructor and Description |
---|
RpcClientImpl(Configuration conf,
String clusterId)
Construct an IPC client for the cluster
clusterId with the default SocketFactory |
RpcClientImpl(Configuration conf,
String clusterId,
SocketAddress localAddr)
Construct an IPC client for the cluster
clusterId with the default SocketFactory
This method is called with reflection by the RpcClientFactory to create an instance |
Modifier and Type | Method and Description |
---|---|
protected Pair<Message,CellScanner> |
call(PayloadCarryingRpcController pcrc,
MethodDescriptor md,
Message param,
Message returnType,
User ticket,
InetSocketAddress addr)
Make a call, passing
param , to the IPC server running at
address which is servicing the protocol protocol,
with the ticket credentials, returning the value. |
void |
cancelConnections(ServerName sn)
Interrupt the connections to the given ip:port server.
|
void |
close()
Stop all threads related to this client.
|
protected RpcClientImpl.Connection |
createConnection(ConnectionId remoteId,
Codec codec,
CompressionCodec compressor)
Creates a connection.
|
protected RpcClientImpl.Connection |
getConnection(User ticket,
Call call,
InetSocketAddress addr)
Get a connection from the pool, or create a new one and add it to the
pool.
|
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.
|
createBlockingRpcChannel, getDefaultCodec, getPoolSize, getPoolType
protected final AtomicInteger callIdCnt
protected final PoolMap<ConnectionId,RpcClientImpl.Connection> connections
protected final AtomicBoolean running
protected final FailedServers failedServers
protected final SocketFactory socketFactory
protected static final Map<AuthenticationProtos.TokenIdentifier.Kind,<any>> tokenHandlers
public RpcClientImpl(Configuration conf, String clusterId)
clusterId
with the default SocketFactoryconf
- configurationclusterId
- the cluster idpublic RpcClientImpl(Configuration conf, String clusterId, SocketAddress localAddr)
clusterId
with the default SocketFactory
This method is called with reflection by the RpcClientFactory to create an instanceconf
- configurationclusterId
- the cluster idlocalAddr
- client socket bind address.protected RpcClientImpl.Connection createConnection(ConnectionId remoteId, Codec codec, CompressionCodec compressor) throws IOException
remoteId
- - the ConnectionId to use for the connection creation.IOException
public void close()
protected Pair<Message,CellScanner> call(PayloadCarryingRpcController pcrc, MethodDescriptor md, Message param, Message returnType, User ticket, InetSocketAddress addr) throws IOException, InterruptedException
param
, to the IPC server running at
address
which is servicing the protocol
protocol,
with the ticket
credentials, returning the value.
Throws exceptions if there are network problems or if the remote code
threw an exception.call
in class AbstractRpcClient
ticket
- Be careful which ticket you pass. A new user will mean a new Connection.
UserProvider.getCurrent()
makes a new instance of User each time so will be a
new Connection each time.InterruptedException
IOException
protected IOException wrapException(InetSocketAddress addr, IOException exception)
addr
- target addressexception
- the relevant exceptionpublic void cancelConnections(ServerName sn)
sn
- server location to cancel connections ofprotected RpcClientImpl.Connection getConnection(User ticket, Call call, InetSocketAddress addr) throws IOException
IOException