Interface OperationDistributor

  • All Known Implementing Classes:
    ActionDistributor, PartitionDistributor

    interface OperationDistributor
    The Distributor object is used to execute operations that have an interested I/O event ready. This acts much like a scheduler would in that it delays the execution of the operations until such time as the associated SelectableChannel has an interested I/O event ready.

    This distributor has two modes, one mode is used to cancel the channel once an I/O event has occurred. This means that the channel is removed from the Selector so that the selector does not break when asked to select again. Canceling the channel is useful when the operation execution may not fully read the payload or when the operation takes a significant amount of time.

    See Also:
    ActionDistributor
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void close()
      This is used to close the distributor such that it cancels all of the registered channels and closes down the selector.
      void process​(Operation task, int require)
      This is used to process the Operation object.
    • Method Detail

      • process

        void process​(Operation task,
                     int require)
              throws java.io.IOException
        This is used to process the Operation object. This will wake up the selector if it is currently blocked selecting and register the operations associated channel. Once the selector is awake it will acquire the operation from the queue and register the associated SelectableChannel for selection. The operation will then be executed when the channel is ready for the interested I/O events.
        Parameters:
        task - this is the task that is scheduled for distribution
        require - this is the bit-mask value for interested events
        Throws:
        java.io.IOException
      • close

        void close()
            throws java.io.IOException
        This is used to close the distributor such that it cancels all of the registered channels and closes down the selector. This is used when the distributor is no longer required, after the close further attempts to process operations will fail.
        Throws:
        java.io.IOException