@InterfaceAudience.Private public class AsyncRpcChannel extends Object
Modifier and Type | Class and Description |
---|---|
private static class |
AsyncRpcChannel.CallWriteListener
Listens to call writes and fails if write failed
|
Modifier and Type | Field and Description |
---|---|
(package private) InetSocketAddress |
address |
(package private) AuthMethod |
authMethod |
private io.netty.channel.Channel |
channel |
private io.netty.util.Timeout |
cleanupTimer |
(package private) AsyncRpcClient |
client |
private boolean |
closed |
private boolean |
connected |
private int |
connectFailureCounter |
private int |
ioFailureCounter |
private static org.apache.commons.logging.Log |
LOG |
private static int |
MAX_SASL_RETRIES |
(package private) String |
name |
private Map<Integer,AsyncCall> |
pendingCalls |
private int |
reloginMaxBackoff |
private String |
serverPrincipal |
(package private) String |
serviceName |
(package private) User |
ticket |
private io.netty.util.TimerTask |
timeoutTask |
private org.apache.hadoop.security.token.Token<? extends org.apache.hadoop.security.token.TokenIdentifier> |
token |
protected static Map<org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos.TokenIdentifier.Kind,org.apache.hadoop.security.token.TokenSelector<? extends org.apache.hadoop.security.token.TokenIdentifier>> |
tokenHandlers |
(package private) boolean |
useSasl |
Constructor and Description |
---|
AsyncRpcChannel(io.netty.bootstrap.Bootstrap bootstrap,
AsyncRpcClient client,
User ticket,
String serviceName,
InetSocketAddress address)
Constructor for netty RPC channel
|
Modifier and Type | Method and Description |
---|---|
private org.apache.hadoop.hbase.protobuf.generated.RPCProtos.UserInformation |
buildUserInfo(org.apache.hadoop.security.UserGroupInformation ugi,
AuthMethod authMethod)
Build the user information
|
io.netty.util.concurrent.Promise<com.google.protobuf.Message> |
callMethod(com.google.protobuf.Descriptors.MethodDescriptor method,
PayloadCarryingRpcController controller,
com.google.protobuf.Message request,
com.google.protobuf.Message responsePrototype,
MetricsConnection.CallStats callStats)
Calls method on channel
|
private void |
cleanupCalls()
Clean up calls.
|
void |
close(Throwable e)
Close connection
|
private io.netty.channel.ChannelFuture |
connect(io.netty.bootstrap.Bootstrap bootstrap)
Connect to channel
|
private void |
createPreamble(io.netty.buffer.ByteBuf byteBuf,
AuthMethod authMethod)
Create connection preamble
|
boolean |
equals(Object obj) |
int |
getConnectionHashCode() |
private SaslClientHandler |
getSaslHandler(org.apache.hadoop.security.UserGroupInformation realTicket,
io.netty.bootstrap.Bootstrap bootstrap)
Get SASL handler
|
private void |
handleSaslConnectionFailure(int currRetries,
Throwable ex,
org.apache.hadoop.security.UserGroupInformation user)
If multiple clients with the same principal try to connect
to the same server at the same time, the server assumes a
replay attack is in progress.
|
int |
hashCode() |
boolean |
isAlive()
Check if the connection is alive
|
(package private) AsyncCall |
removePendingCall(int id) |
private void |
retryOrClose(io.netty.bootstrap.Bootstrap bootstrap,
int connectCounter,
Throwable e)
Retry to connect or close
|
private void |
setupAuthorization()
Set up server authorization
|
private boolean |
shouldAuthenticateOverKrb()
Check if user should authenticate over Kerberos
|
private void |
startHBaseConnection(io.netty.channel.Channel ch)
Start HBase connection
|
String |
toString() |
private io.netty.channel.ChannelFuture |
writeChannelHeader(io.netty.channel.Channel channel)
Write the channel header
|
private void |
writeRequest(AsyncCall call)
Write request to channel
|
private static final org.apache.commons.logging.Log LOG
private static final int MAX_SASL_RETRIES
protected static final Map<org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos.TokenIdentifier.Kind,org.apache.hadoop.security.token.TokenSelector<? extends org.apache.hadoop.security.token.TokenIdentifier>> tokenHandlers
final AsyncRpcClient client
private io.netty.channel.Channel channel
String name
final User ticket
final String serviceName
final InetSocketAddress address
private int ioFailureCounter
private int connectFailureCounter
boolean useSasl
AuthMethod authMethod
private int reloginMaxBackoff
private org.apache.hadoop.security.token.Token<? extends org.apache.hadoop.security.token.TokenIdentifier> token
private String serverPrincipal
private boolean connected
private boolean closed
private io.netty.util.Timeout cleanupTimer
private final io.netty.util.TimerTask timeoutTask
public AsyncRpcChannel(io.netty.bootstrap.Bootstrap bootstrap, AsyncRpcClient client, User ticket, String serviceName, InetSocketAddress address)
bootstrap
- to construct channel onclient
- to connect withticket
- of user which uses connectionserviceName
- name of service to connect toaddress
- to connect toprivate io.netty.channel.ChannelFuture connect(io.netty.bootstrap.Bootstrap bootstrap)
bootstrap
- to connect toprivate void startHBaseConnection(io.netty.channel.Channel ch)
ch
- channel to start connection onprivate SaslClientHandler getSaslHandler(org.apache.hadoop.security.UserGroupInformation realTicket, io.netty.bootstrap.Bootstrap bootstrap) throws IOException
bootstrap
- to reconnect toIOException
- if handler failed to createprivate void retryOrClose(io.netty.bootstrap.Bootstrap bootstrap, int connectCounter, Throwable e)
bootstrap
- to connect withconnectCounter
- amount of triese
- exception of failpublic io.netty.util.concurrent.Promise<com.google.protobuf.Message> callMethod(com.google.protobuf.Descriptors.MethodDescriptor method, PayloadCarryingRpcController controller, com.google.protobuf.Message request, com.google.protobuf.Message responsePrototype, MetricsConnection.CallStats callStats)
method
- to callcontroller
- to run call withrequest
- to sendresponsePrototype
- to construct response withAsyncCall removePendingCall(int id)
private io.netty.channel.ChannelFuture writeChannelHeader(io.netty.channel.Channel channel) throws IOException
channel
- to write toIOException
- on failure to writeprivate void writeRequest(AsyncCall call)
call
- to writeprivate void setupAuthorization() throws IOException
IOException
- if auth setup failedprivate org.apache.hadoop.hbase.protobuf.generated.RPCProtos.UserInformation buildUserInfo(org.apache.hadoop.security.UserGroupInformation ugi, AuthMethod authMethod)
ugi
- User Group InformationauthMethod
- Authorization methodprivate void createPreamble(io.netty.buffer.ByteBuf byteBuf, AuthMethod authMethod)
byteBuf
- to write toauthMethod
- to writepublic void close(Throwable e)
e
- exception on closeprivate void cleanupCalls()
public boolean isAlive()
private boolean shouldAuthenticateOverKrb() throws IOException
IOException
- on failure of checkprivate void handleSaslConnectionFailure(int currRetries, Throwable ex, org.apache.hadoop.security.UserGroupInformation user) throws IOException, InterruptedException
The retry logic is governed by the shouldAuthenticateOverKrb()
method. In case when the user doesn't have valid credentials, we don't
need to retry (from cache or ticket). In such cases, it is prudent to
throw a runtime exception when we receive a SaslException from the
underlying authentication implementation, so there is no retry from
other high level (for eg, HCM or HBaseAdmin).
currRetries
- retry countex
- exception describing failuser
- which is trying to connectIOException
- if IO failInterruptedException
- if thread is interruptedpublic int getConnectionHashCode()
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.