Package org.apache.drill.exec.rpc
Class BasicClient<T extends com.google.protobuf.Internal.EnumLite,CC extends ClientConnection,HS extends com.google.protobuf.MessageLite,HR extends com.google.protobuf.MessageLite>
java.lang.Object
org.apache.drill.exec.rpc.RpcBus<T,CC>
org.apache.drill.exec.rpc.BasicClient<T,CC,HS,HR>
- Type Parameters:
T
- handshake rpc typeCC
- Client connection typeHS
- Handshake send typeHR
- Handshake receive type
- All Implemented Interfaces:
Closeable
,AutoCloseable
- Direct Known Subclasses:
ControlClient
,DataClient
,UserClient
public abstract class BasicClient<T extends com.google.protobuf.Internal.EnumLite,CC extends ClientConnection,HS extends com.google.protobuf.MessageLite,HR extends com.google.protobuf.MessageLite>
extends RpcBus<T,CC>
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.drill.exec.rpc.RpcBus
RpcBus.ChannelClosedHandler, RpcBus.InboundHandler
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
protected void
connectAsClient
(RpcConnectionHandler<CC> connectionListener, HS handshakeValue, String host, int port) protected void
finalizeConnection
(HR handshake, CC connection) abstract ProtobufLengthDecoder
getDecoder
(BufferAllocator allocator) boolean
hasPing
(long timeoutSec) Sends request and waits for answer to verify connection.protected CC
initRemoteConnection
(io.netty.channel.socket.SocketChannel channel) boolean
isActive()
protected boolean
protected boolean
protected abstract void
prepareSaslHandshake
(RpcConnectionHandler<CC> connectionHandler, List<String> serverAuthMechanisms) Creates various instances needed to start the SASL handshake.<SEND extends com.google.protobuf.MessageLite,
RECEIVE extends com.google.protobuf.MessageLite>
voidsend
(RpcOutcomeListener<RECEIVE> listener, SEND protobufBody, boolean allowInEventLoop, io.netty.buffer.ByteBuf... dataBodies) <SEND extends com.google.protobuf.MessageLite,
RECEIVE extends com.google.protobuf.MessageLite>
voidsend
(RpcOutcomeListener<RECEIVE> listener, T rpcType, SEND protobufBody, Class<RECEIVE> clazz, io.netty.buffer.ByteBuf... dataBodies) <SEND extends com.google.protobuf.MessageLite,
RECEIVE extends com.google.protobuf.MessageLite>
DrillRpcFuture<RECEIVE>protected void
setAuthComplete
(boolean authComplete) Set's the state for authentication complete.void
setAutoRead
(boolean enableAutoRead) void
setSslChannel
(io.netty.channel.Channel c) protected void
setupSSL
(io.netty.channel.ChannelPipeline pipe, ConnectionMultiListener.SSLHandshakeListener sslHandshakeListener) protected void
startSaslHandshake
(RpcConnectionHandler<CC> connectionHandler, Map<String, ?> saslProperties, org.apache.hadoop.security.UserGroupInformation ugi, AuthenticatorFactory authFactory, T rpcType) Main method which starts the SASL handshake for all client channels (user/data/control) once it's determined after regular RPC handshake that authentication is required by server side.validateHandshake
(HR validateHandshake) Methods inherited from class org.apache.drill.exec.rpc.RpcBus
get, getCloseHandler, getResponseDefaultInstance, handle, send, send, send, setAddresses
-
Field Details
-
connection
-
-
Constructor Details
-
BasicClient
-
-
Method Details
-
setupSSL
protected void setupSSL(io.netty.channel.ChannelPipeline pipe, ConnectionMultiListener.SSLHandshakeListener sslHandshakeListener) -
isSslEnabled
protected boolean isSslEnabled() -
setAuthComplete
protected void setAuthComplete(boolean authComplete) Set's the state for authentication complete.- Parameters:
authComplete
- - state to set. True means authentication between client and server is completed, false means authentication is in progress.
-
isAuthComplete
protected boolean isAuthComplete() -
setSslChannel
public void setSslChannel(io.netty.channel.Channel c) -
initRemoteConnection
- Specified by:
initRemoteConnection
in classRpcBus<T extends com.google.protobuf.Internal.EnumLite,
CC extends ClientConnection>
-
hasPing
public boolean hasPing(long timeoutSec) Sends request and waits for answer to verify connection.- Parameters:
timeoutSec
- time in seconds to wait message receiving. If 0 then won't wait.- Returns:
- true if answer received until timeout, false otherwise
-
getDecoder
-
isActive
public boolean isActive() -
validateHandshake
- Throws:
RpcException
-
prepareSaslHandshake
protected abstract void prepareSaslHandshake(RpcConnectionHandler<CC> connectionHandler, List<String> serverAuthMechanisms) throws RpcException Creates various instances needed to start the SASL handshake. This is called fromvalidateHandshake(MessageLite)
if authentication is required from server side.- Parameters:
connectionHandler
- - Connection handler used by client's to know about success/failure conditions.serverAuthMechanisms
- - List of auth mechanisms configured on server side- Throws:
RpcException
-
startSaslHandshake
protected void startSaslHandshake(RpcConnectionHandler<CC> connectionHandler, Map<String, ?> saslProperties, org.apache.hadoop.security.UserGroupInformation ugi, AuthenticatorFactory authFactory, T rpcType) Main method which starts the SASL handshake for all client channels (user/data/control) once it's determined after regular RPC handshake that authentication is required by server side. Once authentication is completed then only the underlying channel is made available to clients to send other RPC messages. Success and failure events are notified to the connection handler on which client waits.- Parameters:
connectionHandler
- - Connection handler used by client's to know about success/failure conditions.saslProperties
- - SASL related properties needed to create SASL client.ugi
- - UserGroupInformation with logged in client side userauthFactory
- - Authentication factory to use for this SASL handshake.rpcType
- - SASL_MESSAGE rpc type.
-
finalizeConnection
-
send
public <SEND extends com.google.protobuf.MessageLite,RECEIVE extends com.google.protobuf.MessageLite> void send(RpcOutcomeListener<RECEIVE> listener, T rpcType, SEND protobufBody, Class<RECEIVE> clazz, io.netty.buffer.ByteBuf... dataBodies) -
send
public <SEND extends com.google.protobuf.MessageLite,RECEIVE extends com.google.protobuf.MessageLite> DrillRpcFuture<RECEIVE> send(T rpcType, SEND protobufBody, Class<RECEIVE> clazz, io.netty.buffer.ByteBuf... dataBodies) -
send
public <SEND extends com.google.protobuf.MessageLite,RECEIVE extends com.google.protobuf.MessageLite> void send(RpcOutcomeListener<RECEIVE> listener, SEND protobufBody, boolean allowInEventLoop, io.netty.buffer.ByteBuf... dataBodies) -
connectAsClient
protected void connectAsClient(RpcConnectionHandler<CC> connectionListener, HS handshakeValue, String host, int port) -
setAutoRead
public void setAutoRead(boolean enableAutoRead) -
close
public void close()
-