Class NettyConnection

  • All Implemented Interfaces:
    java.lang.AutoCloseable, Connection

    public final class NettyConnection
    extends TransportConnection
    Netty based connection implementation.
    Author:
    Middleware Services
    • Constructor Detail

      • NettyConnection

        public NettyConnection​(ConnectionConfig config,
                               java.lang.Class<? extends io.netty.channel.Channel> type,
                               io.netty.channel.EventLoopGroup ioGroup,
                               io.netty.channel.EventLoopGroup messageGroup,
                               boolean shutdownGroups)
        Creates a new connection. Netty supports various transport implementations including NIO, EPOLL, KQueue, etc. The class type and event loop group are tightly coupled in this regard.
        Parameters:
        config - connection configuration
        type - type of channel
        ioGroup - event loop group that handles I/O and supports the channel type, cannot be null
        messageGroup - event loop group that handles inbound messages, can be null
        shutdownGroups - whether to shutdown the event loop groups when the connection is closed
    • Method Detail

      • test

        protected boolean test​(LdapURL url)
        Description copied from class: TransportConnection
        Determine whether the supplied URL is acceptable for use.
        Specified by:
        test in class TransportConnection
        Parameters:
        url - LDAP URL to test
        Returns:
        whether URL can be become active
      • getLdapURL

        public LdapURL getLdapURL()
        Description copied from interface: Connection
        Returns the URL that was selected for this connection. The existence of this value does not indicate a current established connection.
        Returns:
        LDAP URL
      • operation

        public BindResponse operation​(SaslClientRequest request)
                               throws LdapException
        Performs a SASL bind operation that uses a custom client.
        Parameters:
        request - to send
        Returns:
        result of the GSS-API bind operation
        Throws:
        LdapException - if the operation fails or another bind is in progress
      • operation

        public NettyConnection.BindOperationHandle operation​(BindRequest request)
        Description copied from interface: Connection
        Creates a handle for a bind operation. Since clients must not send requests while a bind is in progress, some methods may not be supported on the the operation handle.
        Parameters:
        request - bind request
        Returns:
        operation handle
      • write

        protected void write​(DefaultOperationHandle handle)
        Description copied from class: TransportConnection
        Write the request in the supplied handle to the LDAP server. This method does not throw, it should report exceptions to the handle.
        Specified by:
        write in class TransportConnection
        Parameters:
        handle - for the operation write
      • close

        public void close​(RequestControl... controls)
        Closes this connection. Abandons all pending responses and sends an unbind to the LDAP server if the connection is open when this method is invoked.
        Parameters:
        controls - to send with the unbind request when closing the connection
      • notifyOperationHandlesOfClose

        protected void notifyOperationHandlesOfClose()
        Sends an exception notification to all pending responses that the connection has been closed. Since this invokes any configured exception handlers, notifications will use the messageWorkerGroup if it is configured.
      • reconnect

        protected void reconnect()
        Attempts to reestablish the channel for this connection.
        Throws:
        java.lang.IllegalStateException - if the connection is open
      • isOpen

        public boolean isOpen()
        Returns whether the underlying Netty channel is open. See Channel.isOpen().
        Returns:
        whether the Netty channel is open
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object