@InterfaceAudience.LimitedPrivate(value="Configuration") public class AsyncRpcClient extends AbstractRpcClient
Modifier and Type | Class and Description |
---|---|
static class |
AsyncRpcClient.RpcChannelImplementation
Blocking rpc channel that goes via hbase rpc.
|
AbstractRpcClient.BlockingRpcChannelImplementation
Modifier and Type | Field and Description |
---|---|
(package private) io.netty.bootstrap.Bootstrap |
bootstrap |
protected AtomicInteger |
callIdCnt |
static String |
CLIENT_MAX_THREADS |
private boolean |
closed |
private PoolMap<Integer,AsyncRpcChannel> |
connections |
private static io.netty.channel.ChannelInitializer<io.netty.channel.socket.SocketChannel> |
DEFAULT_CHANNEL_INITIALIZER |
(package private) FailedServers |
failedServers |
(package private) static Pair<io.netty.channel.EventLoopGroup,Class<? extends io.netty.channel.Channel>> |
GLOBAL_EVENT_LOOP_GROUP |
private static org.apache.commons.logging.Log |
LOG |
static String |
USE_GLOBAL_EVENT_LOOP_GROUP |
static String |
USE_NATIVE_TRANSPORT |
private boolean |
useGlobalEventLoopGroup |
private static io.netty.util.HashedWheelTimer |
WHEEL_TIMER |
clusterId, codec, compressor, conf, connectTO, failureSleep, fallbackAllowed, ipcUtil, localAddr, maxRetries, metrics, 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
Modifier | Constructor and Description |
---|---|
(package private) |
AsyncRpcClient(org.apache.hadoop.conf.Configuration configuration)
Used in test only.
|
(package private) |
AsyncRpcClient(org.apache.hadoop.conf.Configuration configuration,
io.netty.channel.ChannelInitializer<io.netty.channel.socket.SocketChannel> channelInitializer)
Used in test only.
|
|
AsyncRpcClient(org.apache.hadoop.conf.Configuration configuration,
String clusterId,
SocketAddress localAddress,
MetricsConnection metrics)
Constructor
|
protected |
AsyncRpcClient(org.apache.hadoop.conf.Configuration configuration,
String clusterId,
SocketAddress localAddress,
MetricsConnection metrics,
io.netty.channel.ChannelInitializer<io.netty.channel.socket.SocketChannel> channelInitializer)
Constructor for tests
|
Modifier and Type | Method and Description |
---|---|
ByteBuffer |
buildCellBlock(CellScanner cells)
Build cell block
|
protected Pair<com.google.protobuf.Message,CellScanner> |
call(PayloadCarryingRpcController pcrc,
com.google.protobuf.Descriptors.MethodDescriptor md,
com.google.protobuf.Message param,
com.google.protobuf.Message returnType,
User ticket,
InetSocketAddress addr,
MetricsConnection.CallStats callStats)
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. |
private void |
callMethod(com.google.protobuf.Descriptors.MethodDescriptor md,
PayloadCarryingRpcController pcrc,
com.google.protobuf.Message param,
com.google.protobuf.Message returnType,
User ticket,
InetSocketAddress addr,
com.google.protobuf.RpcCallback<com.google.protobuf.Message> done)
Call method async
|
void |
cancelConnections(ServerName sn)
Interrupt the connections to the given ip:port server.
|
void |
close()
Close netty
|
CellScanner |
createCellScanner(byte[] cellBlock)
Create a cell scanner
|
private static Pair<io.netty.channel.EventLoopGroup,Class<? extends io.netty.channel.Channel>> |
createEventLoopGroup(org.apache.hadoop.conf.Configuration conf) |
com.google.protobuf.RpcChannel |
createRpcChannel(ServerName sn,
User user,
int rpcTimeout)
Creates a "channel" that can be used by a protobuf service.
|
private AsyncRpcChannel |
createRpcChannel(String serviceName,
InetSocketAddress location,
User ticket)
Creates an RPC client
|
private static Pair<io.netty.channel.EventLoopGroup,Class<? extends io.netty.channel.Channel>> |
getGlobalEventLoopGroup(org.apache.hadoop.conf.Configuration conf) |
(package private) io.netty.util.Timeout |
newTimeout(io.netty.util.TimerTask task,
long delay,
TimeUnit unit) |
void |
removeConnection(AsyncRpcChannel connection)
Remove connection from pool
|
callBlockingMethod, createBlockingRpcChannel, getCodec, getDefaultCodec, getPoolSize, getPoolType, hasCellBlockSupport, wrapException
private static final org.apache.commons.logging.Log LOG
public static final String CLIENT_MAX_THREADS
public static final String USE_NATIVE_TRANSPORT
public static final String USE_GLOBAL_EVENT_LOOP_GROUP
private static final io.netty.util.HashedWheelTimer WHEEL_TIMER
private static final io.netty.channel.ChannelInitializer<io.netty.channel.socket.SocketChannel> DEFAULT_CHANNEL_INITIALIZER
protected final AtomicInteger callIdCnt
private final PoolMap<Integer,AsyncRpcChannel> connections
final FailedServers failedServers
final io.netty.bootstrap.Bootstrap bootstrap
private final boolean useGlobalEventLoopGroup
static Pair<io.netty.channel.EventLoopGroup,Class<? extends io.netty.channel.Channel>> GLOBAL_EVENT_LOOP_GROUP
private boolean closed
protected AsyncRpcClient(org.apache.hadoop.conf.Configuration configuration, String clusterId, SocketAddress localAddress, MetricsConnection metrics, io.netty.channel.ChannelInitializer<io.netty.channel.socket.SocketChannel> channelInitializer)
configuration
- to HBaseclusterId
- for the clusterlocalAddress
- local address to connect tometrics
- the connection metricschannelInitializer
- for custom channel handlersAsyncRpcClient(org.apache.hadoop.conf.Configuration configuration)
AsyncRpcClient(org.apache.hadoop.conf.Configuration configuration, io.netty.channel.ChannelInitializer<io.netty.channel.socket.SocketChannel> channelInitializer)
public AsyncRpcClient(org.apache.hadoop.conf.Configuration configuration, String clusterId, SocketAddress localAddress, MetricsConnection metrics)
configuration
- to HBaseclusterId
- for the clusterlocalAddress
- local address to connect tometrics
- the connection metricsprivate static Pair<io.netty.channel.EventLoopGroup,Class<? extends io.netty.channel.Channel>> getGlobalEventLoopGroup(org.apache.hadoop.conf.Configuration conf)
private static Pair<io.netty.channel.EventLoopGroup,Class<? extends io.netty.channel.Channel>> createEventLoopGroup(org.apache.hadoop.conf.Configuration conf)
protected Pair<com.google.protobuf.Message,CellScanner> call(PayloadCarryingRpcController pcrc, com.google.protobuf.Descriptors.MethodDescriptor md, com.google.protobuf.Message param, com.google.protobuf.Message returnType, User ticket, InetSocketAddress addr, MetricsConnection.CallStats callStats) 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
- if call is interruptedIOException
- if a connection failure is encounteredprivate void callMethod(com.google.protobuf.Descriptors.MethodDescriptor md, PayloadCarryingRpcController pcrc, com.google.protobuf.Message param, com.google.protobuf.Message returnType, User ticket, InetSocketAddress addr, com.google.protobuf.RpcCallback<com.google.protobuf.Message> done)
public void close()
public CellScanner createCellScanner(byte[] cellBlock) throws IOException
cellBlock
- to create scanner forIOException
- on error on creation cell scannerpublic ByteBuffer buildCellBlock(CellScanner cells) throws IOException
cells
- to create block withIOException
- if block creation failsprivate AsyncRpcChannel createRpcChannel(String serviceName, InetSocketAddress location, User ticket) throws StoppedRpcClientException, FailedServerException
serviceName
- name of serviccelocation
- to connect toticket
- for current userStoppedRpcClientException
- when Rpc client is stoppedFailedServerException
- if server failedpublic void cancelConnections(ServerName sn)
sn
- server to cancel connections forpublic void removeConnection(AsyncRpcChannel connection)
public com.google.protobuf.RpcChannel createRpcChannel(ServerName sn, User user, int rpcTimeout)
sn
- server name describing location of serveruser
- which is to use the connectionrpcTimeout
- default rpc operation timeoutio.netty.util.Timeout newTimeout(io.netty.util.TimerTask task, long delay, TimeUnit unit)
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.