Class AbstractIOReactor

  • All Implemented Interfaces:
    IOReactor
    Direct Known Subclasses:
    BaseIOReactor

    public abstract class AbstractIOReactor
    extends java.lang.Object
    implements IOReactor
    Generic implementation of IOReactor that can used as a subclass for more specialized I/O reactors. It is based on a single Selector instance.
    Since:
    4.0
    • Constructor Summary

      Constructors 
      Constructor Description
      AbstractIOReactor​(long selectTimeout)
      Creates new AbstractIOReactor instance.
      AbstractIOReactor​(long selectTimeout, boolean interestOpsQueueing)
      Creates new AbstractIOReactor instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addChannel​(ChannelEntry channelEntry)
      Adds new channel entry.
      void awaitShutdown​(long timeout)
      Blocks for the given period of time in milliseconds awaiting the completion of the reactor shutdown.
      boolean getInterestOpsQueueing()
      Returns true if interest Ops queueing is enabled, false otherwise.
      IOReactorStatus getStatus()
      Returns the current status of the reactor.
      void gracefulShutdown()
      Attempts graceful shutdown of this I/O reactor.
      void hardShutdown()
      Attempts force-shutdown of this I/O reactor.
      void shutdown()
      Initiates shutdown of the reactor and blocks for a default period of time waiting for the reactor to terminate all active connections, to shut down itself and to release system resources it currently holds.
      void shutdown​(long gracePeriod)
      Initiates shutdown of the reactor and blocks approximately for the given period of time in milliseconds waiting for the reactor to terminate all active connections, to shut down itself and to release system resources it currently holds.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AbstractIOReactor

        public AbstractIOReactor​(long selectTimeout)
                          throws IOReactorException
        Creates new AbstractIOReactor instance.
        Parameters:
        selectTimeout - the select timeout.
        Throws:
        IOReactorException - in case if a non-recoverable I/O error.
      • AbstractIOReactor

        public AbstractIOReactor​(long selectTimeout,
                                 boolean interestOpsQueueing)
                          throws IOReactorException
        Creates new AbstractIOReactor instance.
        Parameters:
        selectTimeout - the select timeout.
        interestOpsQueueing - Ops queueing flag.
        Throws:
        IOReactorException - in case if a non-recoverable I/O error.
        Since:
        4.1
    • Method Detail

      • getStatus

        public IOReactorStatus getStatus()
        Description copied from interface: IOReactor
        Returns the current status of the reactor.
        Specified by:
        getStatus in interface IOReactor
        Returns:
        reactor status.
      • getInterestOpsQueueing

        public boolean getInterestOpsQueueing()
        Returns true if interest Ops queueing is enabled, false otherwise.
        Since:
        4.1
      • addChannel

        public void addChannel​(ChannelEntry channelEntry)
        Adds new channel entry. The channel will be asynchronously registered with the selector.
        Parameters:
        channelEntry - the channel entry.
      • gracefulShutdown

        public void gracefulShutdown()
        Attempts graceful shutdown of this I/O reactor.
      • awaitShutdown

        public void awaitShutdown​(long timeout)
                           throws java.lang.InterruptedException
        Blocks for the given period of time in milliseconds awaiting the completion of the reactor shutdown.
        Parameters:
        timeout - the maximum wait time.
        Throws:
        java.lang.InterruptedException - if interrupted.
      • shutdown

        public void shutdown​(long gracePeriod)
                      throws IOReactorException
        Description copied from interface: IOReactor
        Initiates shutdown of the reactor and blocks approximately for the given period of time in milliseconds waiting for the reactor to terminate all active connections, to shut down itself and to release system resources it currently holds.
        Specified by:
        shutdown in interface IOReactor
        Parameters:
        gracePeriod - wait time in milliseconds.
        Throws:
        IOReactorException
      • shutdown

        public void shutdown()
                      throws IOReactorException
        Description copied from interface: IOReactor
        Initiates shutdown of the reactor and blocks for a default period of time waiting for the reactor to terminate all active connections, to shut down itself and to release system resources it currently holds. It is up to individual implementations to decide for how long this method can remain blocked.
        Specified by:
        shutdown in interface IOReactor
        Throws:
        IOReactorException