Class EventHandler

java.lang.Object
org.elasticsearch.nio.EventHandler

public class EventHandler extends Object
  • Field Details

  • Constructor Details

  • Method Details

    • acceptChannel

      protected void acceptChannel(ServerChannelContext context) throws IOException
      This method is called when a server channel signals it is ready to accept a connection. All of the accept logic should occur in this call.
      Parameters:
      context - that can accept a connection
      Throws:
      IOException
    • acceptException

      protected void acceptException(ServerChannelContext context, Exception exception)
      This method is called when an attempt to accept a connection throws an exception.
      Parameters:
      context - that accepting a connection
      exception - that occurred
    • handleRegistration

      protected void handleRegistration(ChannelContext<?> context) throws IOException
      This method is called when a NioChannel is being registered with the selector. It should only be called once per channel.
      Parameters:
      context - that was registered
      Throws:
      IOException
    • registrationException

      protected void registrationException(ChannelContext<?> context, Exception exception)
      This method is called when an attempt to register a channel throws an exception.
      Parameters:
      context - that was registered
      exception - that occurred
    • handleActive

      protected void handleActive(ChannelContext<?> context) throws IOException
      This method is called after a NioChannel is active with the selector. It should only be called once per channel.
      Parameters:
      context - that was marked active
      Throws:
      IOException
    • activeException

      protected void activeException(ChannelContext<?> context, Exception exception)
      This method is called when setting a channel to active throws an exception.
      Parameters:
      context - that was marked active
      exception - that occurred
    • handleConnect

      protected void handleConnect(SocketChannelContext context) throws IOException
      This method is called when a NioSocketChannel has just been accepted or if it has receive an OP_CONNECT event.
      Parameters:
      context - that was registered
      Throws:
      IOException
    • connectException

      protected void connectException(SocketChannelContext context, Exception exception)
      This method is called when an attempt to connect a channel throws an exception.
      Parameters:
      context - that was connecting
      exception - that occurred
    • handleRead

      protected void handleRead(SocketChannelContext context) throws IOException
      This method is called when a channel signals it is ready for be read. All of the read logic should occur in this call.
      Parameters:
      context - that can be read
      Throws:
      IOException
    • readException

      protected void readException(SocketChannelContext context, Exception exception)
      This method is called when an attempt to read from a channel throws an exception.
      Parameters:
      context - that was being read
      exception - that occurred
    • handleWrite

      protected void handleWrite(SocketChannelContext context) throws IOException
      This method is called when a channel signals it is ready to receive writes. All of the write logic should occur in this call.
      Parameters:
      context - that can be written to
      Throws:
      IOException
    • writeException

      protected void writeException(SocketChannelContext context, Exception exception)
      This method is called when an attempt to write to a channel throws an exception.
      Parameters:
      context - that was being written to
      exception - that occurred
    • handleTask

      protected void handleTask(Runnable task)
      This method is called when a task or listener attached to a channel is available to run.
      Parameters:
      task - to handle
    • taskException

      protected void taskException(Exception exception)
      This method is called when a task or listener attached to a channel operation throws an exception.
      Parameters:
      exception - that occurred
    • postHandling

      protected void postHandling(SocketChannelContext context)
      This method is called after events (READ, WRITE, CONNECT) have been handled for a channel.
      Parameters:
      context - that was handled
    • selectorException

      protected void selectorException(IOException exception)
      This method handles an IOException that was thrown during a call to Selector.select(long) or Selector.close().
      Parameters:
      exception - the exception
    • uncaughtException

      protected void uncaughtException(Exception exception)
      This method handles an exception that was uncaught during a select loop.
      Parameters:
      exception - that was uncaught
    • handleClose

      protected void handleClose(ChannelContext<?> context) throws IOException
      This method handles the closing of an NioChannel
      Parameters:
      context - that should be closed
      Throws:
      IOException
    • closeException

      protected void closeException(ChannelContext<?> context, Exception exception)
      This method is called when an attempt to close a channel throws an exception.
      Parameters:
      context - that was being closed
      exception - that occurred
    • genericChannelException

      protected void genericChannelException(ChannelContext<?> context, Exception exception)
      This method is called when handling an event from a channel fails due to an unexpected exception. An example would be if checking ready ops on a SelectionKey threw CancelledKeyException.
      Parameters:
      context - that caused the exception
      exception - that was thrown