Class BytesWriteHandler

java.lang.Object
org.elasticsearch.nio.BytesWriteHandler
All Implemented Interfaces:
NioChannelHandler

public abstract class BytesWriteHandler extends Object implements NioChannelHandler
  • Constructor Details

    • BytesWriteHandler

      public BytesWriteHandler()
  • Method Details

    • createWriteOperation

      public WriteOperation createWriteOperation(SocketChannelContext context, Object message, BiConsumer<Void,Exception> listener)
      Description copied from interface: NioChannelHandler
      This method is called when a message is queued with a channel. It can be called from any thread. This method should validate that the message is a valid type and return a write operation object to be queued with the channel
      Specified by:
      createWriteOperation in interface NioChannelHandler
      Parameters:
      context - the channel context
      message - the message
      listener - the listener to be called when the message is sent
      Returns:
      the write operation to be queued
    • channelActive

      public void channelActive()
      Description copied from interface: NioChannelHandler
      This method is called when the channel is active for use.
      Specified by:
      channelActive in interface NioChannelHandler
    • writeToBytes

      public List<FlushOperation> writeToBytes(WriteOperation writeOperation)
      Description copied from interface: NioChannelHandler
      This method is called on the event loop thread. It should serialize a write operation object to bytes that can be flushed to the raw nio channel.
      Specified by:
      writeToBytes in interface NioChannelHandler
      Parameters:
      writeOperation - to be converted to bytes
      Returns:
      the operations to flush the bytes to the channel
    • pollFlushOperations

      public List<FlushOperation> pollFlushOperations()
      Description copied from interface: NioChannelHandler
      Returns any flush operations that are ready to flush. This exists as a way to check if any flush operations were produced during a read call.
      Specified by:
      pollFlushOperations in interface NioChannelHandler
      Returns:
      flush operations
    • closeNow

      public boolean closeNow()
      Description copied from interface: NioChannelHandler
      This method indicates if the underlying channel should be closed.
      Specified by:
      closeNow in interface NioChannelHandler
      Returns:
      if the channel should be closed
    • close

      public void close()
      Specified by:
      close in interface NioChannelHandler