Package org.apache.drill.exec.rpc.user
Class UserServer.BitToUserConnection
java.lang.Object
org.apache.drill.exec.rpc.AbstractRemoteConnection
org.apache.drill.exec.rpc.AbstractServerConnection<UserServer.BitToUserConnection>
org.apache.drill.exec.rpc.user.UserServer.BitToUserConnection
- All Implemented Interfaces:
AutoCloseable
,ConnectionThrottle
,EncryptionContext
,RemoteConnection
,ServerConnection<UserServer.BitToUserConnection>
,UserClientConnection
- Enclosing class:
- UserServer
public class UserServer.BitToUserConnection
extends AbstractServerConnection<UserServer.BitToUserConnection>
implements UserClientConnection
Represents a client connection accepted by Foreman Drillbit's UserServer
from a DrillClient. This connection is used to get hold of
UserSession
which stores all session related information like
session options changed over the lifetime of this connection. There is a
1:1 mapping between a BitToUserConnection and a UserSession. This
connection object is also used to send query data and result back to the
client submitted as part of the session tied to this connection.-
Field Summary
Fields inherited from class org.apache.drill.exec.rpc.AbstractRemoteConnection
saslCodec
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Called from the RpcBus's channel close handler to close all remaining resources associated with this connection.void
close()
Connection consumer wants to close connection.void
void
io.netty.util.concurrent.Future<Void>
Returns theFuture
which will be notified when this channel is closed.protected org.slf4j.Logger
void
void
sendData
(RpcOutcomeListener<GeneralRPCProtos.Ack> listener, QueryDataPackage data) Send query data to client.void
sendResult
(RpcOutcomeListener<GeneralRPCProtos.Ack> listener, UserBitShared.QueryResult result) Send query result outcome to client.Methods inherited from class org.apache.drill.exec.rpc.AbstractServerConnection
changeHandlerTo, disposeSaslServer, getAllocator, getCurrentHandler, getSaslServer, initSaslServer, setEncryption, setMaxWrappedSize
Methods inherited from class org.apache.drill.exec.rpc.AbstractRemoteConnection
addSecurityHandlers, blockOnNotWritable, createNewRpcListener, getAndRemoveRpcOutcome, getChannel, getEncryptionCtxtString, getMaxWrappedSize, getName, getWrapSizeLimit, inEventLoop, isActive, isEncryptionEnabled, recordRemoteFailure, setAutoRead, setWrapSizeLimit
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.drill.exec.rpc.ConnectionThrottle
setAutoRead
Methods inherited from interface org.apache.drill.exec.rpc.EncryptionContext
getEncryptionCtxtString, getMaxWrappedSize, getWrapSizeLimit, isEncryptionEnabled, setWrapSizeLimit
Methods inherited from interface org.apache.drill.exec.rpc.RemoteConnection
addSecurityHandlers, blockOnNotWritable, createNewRpcListener, getAndRemoveRpcOutcome, getChannel, getName, inEventLoop, isActive, recordRemoteFailure
-
Method Details
-
finalizeSaslSession
- Specified by:
finalizeSaslSession
in interfaceServerConnection<UserServer.BitToUserConnection>
- Overrides:
finalizeSaslSession
in classAbstractServerConnection<UserServer.BitToUserConnection>
- Throws:
IOException
-
getSession
- Specified by:
getSession
in interfaceUserClientConnection
- Returns:
- User session object.
-
getLogger
protected org.slf4j.Logger getLogger()- Specified by:
getLogger
in classAbstractServerConnection<UserServer.BitToUserConnection>
-
sendData
Description copied from interface:UserClientConnection
Send query data to client. Outcome is returned throughlistener
.- Specified by:
sendData
in interfaceUserClientConnection
- Parameters:
listener
- The listenerdata
- The data to be sent
-
getClosureFuture
Description copied from interface:UserClientConnection
Returns theFuture
which will be notified when this channel is closed. This method always returns the same future instance.- Specified by:
getClosureFuture
in interfaceUserClientConnection
-
getRemoteAddress
- Specified by:
getRemoteAddress
in interfaceRemoteConnection
- Specified by:
getRemoteAddress
in interfaceUserClientConnection
- Overrides:
getRemoteAddress
in classAbstractRemoteConnection
- Returns:
- Return the client node address.
-
channelClosed
Description copied from class:AbstractRemoteConnection
Called from the RpcBus's channel close handler to close all remaining resources associated with this connection. Ensures that any pending back-pressure items are also unblocked so they can be thrown away.- Specified by:
channelClosed
in interfaceRemoteConnection
- Overrides:
channelClosed
in classAbstractServerConnection<UserServer.BitToUserConnection>
- Parameters:
ex
- The exception that caused the channel to close.
-
close
public void close()Description copied from class:AbstractRemoteConnection
Connection consumer wants to close connection. Initiate connection close and complete. This is a blocking call that ensures that the connection is closed before returning. As part of this call, the channel close handler will be triggered which will call channelClosed() above. The latter will happen in a separate thread while this method is blocking.The check for isActive is not required here since channel can be in OPEN state without being active. We want to close in both the scenarios. A channel is in OPEN state when a socket is created for it before binding to an address.
- For connection oriented transport protocol channel moves to ACTIVE state when a connection is established using this channel. We need to have channel in ACTIVE state NOT OPEN before we can send any message to remote endpoint.
- For connectionless transport protocol a sender can send data as soon as channel moves to OPEN state.
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceRemoteConnection
- Overrides:
close
in classAbstractRemoteConnection
-
incConnectionCounter
public void incConnectionCounter()- Specified by:
incConnectionCounter
in classAbstractRemoteConnection
-
decConnectionCounter
public void decConnectionCounter()- Specified by:
decConnectionCounter
in classAbstractRemoteConnection
-