Interface IOReactor

  • All Superinterfaces:
    java.lang.AutoCloseable, java.io.Closeable, ModalCloseable
    All Known Subinterfaces:
    IOReactorService
    All Known Implementing Classes:
    AsyncRequester, AsyncServer, DefaultConnectingIOReactor, DefaultListeningIOReactor, HttpAsyncRequester, HttpAsyncServer

    public interface IOReactor
    extends ModalCloseable
    HttpCore NIO is based on the Reactor pattern as described by Doug Lea. The purpose of I/O reactors is to react to I/O events and to dispatch event notifications to individual I/O sessions. The main idea of I/O reactor pattern is to break away from the one thread per connection model imposed by the classic blocking I/O model.

    The IOReactor interface represents an abstract object implementing the Reactor pattern.

    I/O reactors usually employ a small number of dispatch threads (often as few as one) to dispatch I/O event notifications to a much greater number (often as many as several thousands) of I/O sessions or connections. It is generally recommended to have one dispatch thread per CPU core.

    Since:
    4.0
    • Method Detail

      • close

        void close​(CloseMode closeMode)
        Shuts down the I/O reactor either gracefully or immediately. During graceful shutdown individual I/O sessions should be informed about imminent termination and be given a grace period to complete the ongoing I/O sessions. During immediate shutdown all ongoing I/O sessions get aborted immediately.
        Specified by:
        close in interface ModalCloseable
        Parameters:
        closeMode - How to close the receiver.
      • getStatus

        IOReactorStatus getStatus()
        Returns the current status of the reactor.
        Returns:
        reactor status.
      • initiateShutdown

        void initiateShutdown()
        Initiates shutdown of the reactor without blocking. The reactor is expected to terminate all active connections, to shut down itself and to release system resources it currently holds
        Since:
        5.0
      • awaitShutdown

        void awaitShutdown​(TimeValue waitTime)
                    throws java.lang.InterruptedException
        Blocks for the given period of time in milliseconds awaiting the completion of the reactor shutdown.
        Parameters:
        waitTime - wait time.
        Throws:
        java.lang.InterruptedException - Thrown when a thread is waiting, sleeping, or otherwise occupied, and the thread is interrupted, either before or during the activity.
        Since:
        5.0