Package org.elasticsearch.nio
Class BytesWriteHandler
java.lang.Object
org.elasticsearch.nio.BytesWriteHandler
- All Implemented Interfaces:
NioChannelHandler
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidThis method is called when the channel is active for use.voidclose()booleancloseNow()This method indicates if the underlying channel should be closed.createWriteOperation(SocketChannelContext context, Object message, BiConsumer<Void, Exception> listener) This method is called when a message is queued with a channel.Returns any flush operations that are ready to flush.writeToBytes(WriteOperation writeOperation) This method is called on the event loop thread.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.elasticsearch.nio.NioChannelHandler
consumeReads
-
Constructor Details
-
BytesWriteHandler
public BytesWriteHandler()
-
-
Method Details
-
createWriteOperation
public WriteOperation createWriteOperation(SocketChannelContext context, Object message, BiConsumer<Void, 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
-
channelActive
public void channelActive()Description copied from interface:NioChannelHandlerThis method is called when the channel is active for use.- Specified by:
channelActivein interfaceNioChannelHandler
-
writeToBytes
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
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
-
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()- Specified by:
closein interfaceNioChannelHandler
-