Package org.elasticsearch.nio
Class EventHandler
java.lang.Object
org.elasticsearch.nio.EventHandler
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionEventHandler(Consumer<Exception> exceptionHandler, Supplier<NioSelector> selectorSupplier) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidacceptChannel(ServerChannelContext context) This method is called when a server channel signals it is ready to accept a connection.protected voidacceptException(ServerChannelContext context, Exception exception) This method is called when an attempt to accept a connection throws an exception.protected voidactiveException(ChannelContext<?> context, Exception exception) This method is called when setting a channel to active throws an exception.protected voidcloseException(ChannelContext<?> context, Exception exception) This method is called when an attempt to close a channel throws an exception.protected voidconnectException(SocketChannelContext context, Exception exception) This method is called when an attempt to connect a channel throws an exception.protected voidgenericChannelException(ChannelContext<?> context, Exception exception) This method is called when handling an event from a channel fails due to an unexpected exception.protected voidhandleActive(ChannelContext<?> context) This method is called after a NioChannel is active with the selector.protected voidhandleClose(ChannelContext<?> context) This method handles the closing of an NioChannelprotected voidhandleConnect(SocketChannelContext context) This method is called when a NioSocketChannel has just been accepted or if it has receive an OP_CONNECT event.protected voidhandleRead(SocketChannelContext context) This method is called when a channel signals it is ready for be read.protected voidhandleRegistration(ChannelContext<?> context) This method is called when a NioChannel is being registered with the selector.protected voidhandleTask(Runnable task) This method is called when a task or listener attached to a channel is available to run.protected voidhandleWrite(SocketChannelContext context) This method is called when a channel signals it is ready to receive writes.protected voidpostHandling(SocketChannelContext context) This method is called after events (READ, WRITE, CONNECT) have been handled for a channel.protected voidreadException(SocketChannelContext context, Exception exception) This method is called when an attempt to read from a channel throws an exception.protected voidregistrationException(ChannelContext<?> context, Exception exception) This method is called when an attempt to register a channel throws an exception.protected voidselectorException(IOException exception) This method handles an IOException that was thrown during a call toSelector.select(long)orSelector.close().protected voidtaskException(Exception exception) This method is called when a task or listener attached to a channel operation throws an exception.protected voiduncaughtException(Exception exception) This method handles an exception that was uncaught during a select loop.protected voidwriteException(SocketChannelContext context, Exception exception) This method is called when an attempt to write to a channel throws an exception.
-
Field Details
-
exceptionHandler
-
-
Constructor Details
-
EventHandler
-
-
Method Details
-
acceptChannel
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
This method is called when an attempt to accept a connection throws an exception.- Parameters:
context- that accepting a connectionexception- that occurred
-
handleRegistration
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
This method is called when an attempt to register a channel throws an exception.- Parameters:
context- that was registeredexception- that occurred
-
handleActive
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
This method is called when setting a channel to active throws an exception.- Parameters:
context- that was marked activeexception- that occurred
-
handleConnect
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
This method is called when an attempt to connect a channel throws an exception.- Parameters:
context- that was connectingexception- that occurred
-
handleRead
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
This method is called when an attempt to read from a channel throws an exception.- Parameters:
context- that was being readexception- that occurred
-
handleWrite
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
This method is called when an attempt to write to a channel throws an exception.- Parameters:
context- that was being written toexception- that occurred
-
handleTask
This method is called when a task or listener attached to a channel is available to run.- Parameters:
task- to handle
-
taskException
This method is called when a task or listener attached to a channel operation throws an exception.- Parameters:
exception- that occurred
-
postHandling
This method is called after events (READ, WRITE, CONNECT) have been handled for a channel.- Parameters:
context- that was handled
-
selectorException
This method handles an IOException that was thrown during a call toSelector.select(long)orSelector.close().- Parameters:
exception- the exception
-
uncaughtException
This method handles an exception that was uncaught during a select loop.- Parameters:
exception- that was uncaught
-
handleClose
This method handles the closing of an NioChannel- Parameters:
context- that should be closed- Throws:
IOException
-
closeException
This method is called when an attempt to close a channel throws an exception.- Parameters:
context- that was being closedexception- that occurred
-
genericChannelException
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 aSelectionKeythrewCancelledKeyException.- Parameters:
context- that caused the exceptionexception- that was thrown
-