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 type
CC - Client connection type
HS - Handshake send type
HR - 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>
  • Field Details

  • Constructor Details

    • BasicClient

      public BasicClient(RpcConfig rpcMapping, io.netty.buffer.ByteBufAllocator alloc, io.netty.channel.EventLoopGroup eventLoopGroup, T handshakeType, Class<HR> responseClass, com.google.protobuf.Parser<HR> handshakeParser)
  • 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

      protected CC initRemoteConnection(io.netty.channel.socket.SocketChannel channel)
      Specified by:
      initRemoteConnection in class RpcBus<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

      public abstract ProtobufLengthDecoder getDecoder(BufferAllocator allocator)
    • isActive

      public boolean isActive()
    • validateHandshake

      protected abstract List<String> validateHandshake(HR validateHandshake) throws RpcException
      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 from validateHandshake(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 user
      authFactory - - Authentication factory to use for this SASL handshake.
      rpcType - - SASL_MESSAGE rpc type.
    • finalizeConnection

      protected void finalizeConnection(HR handshake, CC connection)
    • 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()