Package org.elasticsearch.nio
Class DelegatingHandler
- java.lang.Object
-
- org.elasticsearch.nio.DelegatingHandler
-
- All Implemented Interfaces:
NioChannelHandler
public abstract class DelegatingHandler extends java.lang.Object implements NioChannelHandler
-
-
Constructor Summary
Constructors Constructor Description DelegatingHandler(NioChannelHandler delegate)
-
Method Summary
Modifier and Type Method Description voidchannelRegistered()This method is called when the channel is registered with its selector.voidclose()booleancloseNow()This method indicates if the underlying channel should be closed.intconsumeReads(InboundChannelBuffer channelBuffer)This method handles bytes that have been read from the network.WriteOperationcreateWriteOperation(SocketChannelContext context, java.lang.Object message, java.util.function.BiConsumer<java.lang.Void,java.lang.Exception> listener)This method is called when a message is queued with a channel.java.util.List<FlushOperation>pollFlushOperations()Returns any flush operations that are ready to flush.java.util.List<FlushOperation>writeToBytes(WriteOperation writeOperation)This method is called on the event loop thread.
-
-
-
Constructor Detail
-
DelegatingHandler
public DelegatingHandler(NioChannelHandler delegate)
-
-
Method Detail
-
channelRegistered
public void channelRegistered()
Description copied from interface:NioChannelHandlerThis method is called when the channel is registered with its selector.- Specified by:
channelRegisteredin interfaceNioChannelHandler
-
createWriteOperation
public WriteOperation createWriteOperation(SocketChannelContext context, java.lang.Object message, java.util.function.BiConsumer<java.lang.Void,java.lang.Exception> listener)
Description copied from interface:NioChannelHandlerThis 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:
createWriteOperationin interfaceNioChannelHandler- Parameters:
context- the channel contextmessage- the messagelistener- the listener to be called when the message is sent- Returns:
- the write operation to be queued
-
writeToBytes
public java.util.List<FlushOperation> writeToBytes(WriteOperation writeOperation)
Description copied from interface:NioChannelHandlerThis 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:
writeToBytesin interfaceNioChannelHandler- Parameters:
writeOperation- to be converted to bytes- Returns:
- the operations to flush the bytes to the channel
-
pollFlushOperations
public java.util.List<FlushOperation> pollFlushOperations()
Description copied from interface:NioChannelHandlerReturns 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:
pollFlushOperationsin interfaceNioChannelHandler- Returns:
- flush operations
-
consumeReads
public int consumeReads(InboundChannelBuffer channelBuffer) throws java.io.IOException
Description copied from interface:NioChannelHandlerThis method handles bytes that have been read from the network. It should return the number of bytes consumed so that they can be released.- Specified by:
consumeReadsin interfaceNioChannelHandler- Parameters:
channelBuffer- of bytes read from the network- Returns:
- the number of bytes consumed
- Throws:
java.io.IOException- if an exception occurs
-
closeNow
public boolean closeNow()
Description copied from interface:NioChannelHandlerThis method indicates if the underlying channel should be closed.- Specified by:
closeNowin interfaceNioChannelHandler- Returns:
- if the channel should be closed
-
close
public void close() throws java.io.IOException- Specified by:
closein interfaceNioChannelHandler- Throws:
java.io.IOException
-
-