Class NioReceiver

java.lang.Object
org.apache.catalina.tribes.transport.ReceiverBase
org.apache.catalina.tribes.transport.nio.NioReceiver
All Implemented Interfaces:
Runnable, ChannelReceiver, Heartbeat, ListenCallback, NioReceiverMBean, RxTaskPool.TaskCreator

public class NioReceiver extends ReceiverBase implements Runnable, NioReceiverMBean
  • Field Details

    • sm

      protected static final StringManager sm
      The string manager for this package.
    • events

      protected final Deque<Runnable> events
    • lastCheck

      protected long lastCheck
  • Constructor Details

    • NioReceiver

      public NioReceiver()
  • Method Details

    • stop

      public void stop()
      Description copied from interface: ChannelReceiver
      Stop listening for messages
      Specified by:
      stop in interface ChannelReceiver
      Overrides:
      stop in class ReceiverBase
    • start

      public void start() throws IOException
      Description copied from interface: ChannelReceiver
      Start listening for incoming messages on the host/port
      Specified by:
      start in interface ChannelReceiver
      Overrides:
      start in class ReceiverBase
      Throws:
      IOException - Listen failed
    • createRxTask

      public AbstractRxTask createRxTask()
      Specified by:
      createRxTask in interface RxTaskPool.TaskCreator
    • bind

      protected void bind() throws IOException
      Throws:
      IOException
    • addEvent

      public void addEvent(Runnable event)
    • events

      public void events()
    • cancelledKey

      public static void cancelledKey(SelectionKey key)
    • socketTimeouts

      protected void socketTimeouts()
    • listen

      protected void listen() throws Exception
      Get data from channel and store in byte array send it to cluster
      Throws:
      IOException - IO error
      Exception
    • stopListening

      protected void stopListening()
      Close Selector.
      See Also:
    • registerChannel

      protected void registerChannel(Selector selector, SelectableChannel channel, int ops, Object attach) throws Exception
      Register the given channel with the given selector for the given operations of interest
      Parameters:
      selector - The selector to use
      channel - The channel
      ops - The operations to register
      attach - Attachment object
      Throws:
      Exception - IO error with channel
    • run

      public void run()
      Start thread and listen
      Specified by:
      run in interface Runnable
    • readDataFromSocket

      protected void readDataFromSocket(SelectionKey key) throws Exception
      Sample data handler method for a channel with data ready to read.
      Parameters:
      key - A SelectionKey object associated with a channel determined by the selector to be ready for reading. If the channel returns an EOF condition, it is closed here, which automatically invalidates the associated key. The selector will then de-register the channel on the next select call.
      Throws:
      Exception - IO error with channel