Class NioEndpoint

    • Field Detail

      • OP_REGISTER

        public static final int OP_REGISTER
        Custom operation for registering interest in a socket.
        See Also:
        Constant Field Values
    • Constructor Detail

      • NioEndpoint

        public NioEndpoint()
        Default constructor.
    • Method Detail

      • setUseInheritedChannel

        public void setUseInheritedChannel​(boolean useInheritedChannel)
        Sets whether to use an inherited channel.
        Parameters:
        useInheritedChannel - true to use System.inheritedChannel
      • getUseInheritedChannel

        public boolean getUseInheritedChannel()
        Returns whether an inherited channel is used.
        Returns:
        true if System.inheritedChannel is used
      • getUnixDomainSocketPath

        public java.lang.String getUnixDomainSocketPath()
        Returns the Unix domain socket path.
        Returns:
        the Unix domain socket path
      • setUnixDomainSocketPath

        public void setUnixDomainSocketPath​(java.lang.String unixDomainSocketPath)
        Sets the Unix domain socket path.
        Parameters:
        unixDomainSocketPath - the path to the Unix domain socket
      • getUnixDomainSocketPathPermissions

        public java.lang.String getUnixDomainSocketPathPermissions()
        Returns the Unix domain socket path permissions.
        Returns:
        the permissions string
      • setUnixDomainSocketPathPermissions

        public void setUnixDomainSocketPathPermissions​(java.lang.String unixDomainSocketPathPermissions)
        Sets the Unix domain socket path permissions.
        Parameters:
        unixDomainSocketPathPermissions - the permissions string
      • setPollerThreadPriority

        public void setPollerThreadPriority​(int pollerThreadPriority)
        Sets the poller thread priority.
        Parameters:
        pollerThreadPriority - the thread priority
      • getPollerThreadPriority

        public int getPollerThreadPriority()
        Returns the poller thread priority.
        Returns:
        the thread priority
      • setSelectorTimeout

        public void setSelectorTimeout​(long timeout)
        Sets the selector timeout.
        Parameters:
        timeout - The timeout in milliseconds
      • getSelectorTimeout

        public long getSelectorTimeout()
        Returns the selector timeout.
        Returns:
        the timeout in milliseconds
      • getKeepAliveCount

        public int getKeepAliveCount()
        Number of keep-alive sockets.
        Returns:
        The number of sockets currently in the keep-alive state waiting for the next request to be received on the socket
      • getId

        public java.lang.String getId()
        Description copied from class: AbstractEndpoint
        The default behavior is to identify connectors uniquely with address and port. However, certain connectors are not using that and need some other identifier, which then can be used as a replacement.
        Overrides:
        getId in class AbstractEndpoint<NioChannel,​java.nio.channels.SocketChannel>
        Returns:
        the id
      • bind

        public void bind()
                  throws java.lang.Exception
        Initialize the endpoint.
        Specified by:
        bind in class AbstractEndpoint<NioChannel,​java.nio.channels.SocketChannel>
        Throws:
        java.lang.Exception - If an error occurs during binding
      • initServerSocket

        protected void initServerSocket()
                                 throws java.lang.Exception
        Initializes the server socket channel.
        Throws:
        java.lang.Exception - If initialization fails
      • startInternal

        public void startInternal()
                           throws java.lang.Exception
        Start the NIO endpoint, creating acceptor, poller threads.
        Specified by:
        startInternal in class AbstractEndpoint<NioChannel,​java.nio.channels.SocketChannel>
        Throws:
        java.lang.Exception - If an error occurs during startup
      • stopInternal

        public void stopInternal()
        Stop the endpoint. This will cause all processing threads to stop.
        Specified by:
        stopInternal in class AbstractEndpoint<NioChannel,​java.nio.channels.SocketChannel>
      • unbind

        public void unbind()
                    throws java.lang.Exception
        Deallocate NIO memory pools, and close server socket.
        Overrides:
        unbind in class AbstractJsseEndpoint<NioChannel,​java.nio.channels.SocketChannel>
        Throws:
        java.lang.Exception
      • doCloseServerSocket

        protected void doCloseServerSocket()
                                    throws java.io.IOException
        Description copied from class: AbstractEndpoint
        Actually close the server socket but don't perform any other clean-up.
        Specified by:
        doCloseServerSocket in class AbstractEndpoint<NioChannel,​java.nio.channels.SocketChannel>
        Throws:
        java.io.IOException - If an error occurs closing the socket
      • getNioChannels

        protected SynchronizedStack<NioChannel> getNioChannels()
        Returns the NIO channel cache.
        Returns:
        the channel cache stack
      • getPoller

        protected NioEndpoint.Poller getPoller()
        Returns the poller instance.
        Returns:
        the poller
      • getStopLatch

        protected java.util.concurrent.CountDownLatch getStopLatch()
        Returns the stop latch.
        Returns:
        the stop latch
      • setStopLatch

        protected void setStopLatch​(java.util.concurrent.CountDownLatch stopLatch)
        Sets the stop latch.
        Parameters:
        stopLatch - the stop latch
      • setSocketOptions

        protected boolean setSocketOptions​(java.nio.channels.SocketChannel socket)
        Process the specified connection.
        Specified by:
        setSocketOptions in class AbstractEndpoint<NioChannel,​java.nio.channels.SocketChannel>
        Parameters:
        socket - The socket channel
        Returns:
        true if the socket was correctly configured and processing may continue, false if the socket needs to be close immediately
      • destroySocket

        protected void destroySocket​(java.nio.channels.SocketChannel socket)
        Description copied from class: AbstractEndpoint
        Close the socket. This is used when the connector is not in a state which allows processing the socket, or if there was an error which prevented the allocation of the socket wrapper.
        Specified by:
        destroySocket in class AbstractEndpoint<NioChannel,​java.nio.channels.SocketChannel>
        Parameters:
        socket - The newly accepted socket
      • serverSocketAccept

        protected java.nio.channels.SocketChannel serverSocketAccept()
                                                              throws java.lang.Exception
        Description copied from class: AbstractEndpoint
        Accept a connection from the server socket.
        Specified by:
        serverSocketAccept in class AbstractEndpoint<NioChannel,​java.nio.channels.SocketChannel>
        Returns:
        The accepted socket
        Throws:
        java.lang.Exception - If an error occurs during accept