Class FlushSignaller

  • All Implemented Interfaces:
    java.lang.Runnable, Operation

    class FlushSignaller
    extends java.lang.Object
    implements Operation
    The FlushSignaller is an operation that performs writes operation asynchronously. This will basically determine if the socket is write ready and drain each queued buffer to the socket until there are no more pending buffers.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private Socket socket
      This is the socket that this will be flushing.
      private Trace trace
      This is used to trace the activity for the operation.
      private SocketFlusher writer
      This is the writer that is used to write the data.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void cancel()
      This is used to cancel the operation if it has timed out.
      java.nio.channels.SocketChannel getChannel()
      This returns the socket channel for the connected pipeline.
      Trace getTrace()
      This is used to acquire the trace object that is associated with the operation.
      void run()
      This is used to perform the drain of the pending buffer queue.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • writer

        private final SocketFlusher writer
        This is the writer that is used to write the data.
      • socket

        private final Socket socket
        This is the socket that this will be flushing.
      • trace

        private final Trace trace
        This is used to trace the activity for the operation.
    • Constructor Detail

      • FlushSignaller

        public FlushSignaller​(SocketFlusher writer,
                              Socket socket)
        Constructor for the FlushSignaller object. This will create an operation that is used to flush the buffer queue to the underlying socket. This ensures that the data is written to the socket in the queued order.
        Parameters:
        writer - this is the writer to flush the data to
        socket - this is the socket to be flushed
    • Method Detail

      • getTrace

        public Trace getTrace()
        This is used to acquire the trace object that is associated with the operation. A trace object is used to collection details on what operations are being performed. For instance it may contain information relating to I/O events or errors.
        Specified by:
        getTrace in interface Operation
        Returns:
        this returns the trace associated with this operation
      • getChannel

        public java.nio.channels.SocketChannel getChannel()
        This returns the socket channel for the connected pipeline. It is this channel that is used to determine if there are bytes that can be written. When closed this is no longer selectable.
        Specified by:
        getChannel in interface Operation
        Returns:
        this returns the connected channel for the pipeline
      • run

        public void run()
        This is used to perform the drain of the pending buffer queue. This will drain each pending queue if the socket is write ready. If the socket is not write ready the operation is enqueued for selection and this returns. This ensures that all the data will eventually be delivered.
        Specified by:
        run in interface java.lang.Runnable
      • cancel

        public void cancel()
        This is used to cancel the operation if it has timed out. If the delegate is waiting too long to flush the contents of the buffers to the underlying transport then the socket is closed and the flusher times out to avoid deadlock.
        Specified by:
        cancel in interface Operation