Package org.elasticsearch.nio
Class EventHandler
java.lang.Object
org.elasticsearch.nio.EventHandler
-
Field Summary
-
Constructor Summary
ConstructorDescriptionEventHandler
(Consumer<Exception> exceptionHandler, Supplier<NioSelector> selectorSupplier) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
acceptChannel
(ServerChannelContext context) This method is called when a server channel signals it is ready to accept a connection.protected void
acceptException
(ServerChannelContext context, Exception exception) This method is called when an attempt to accept a connection throws an exception.protected void
activeException
(ChannelContext<?> context, Exception exception) This method is called when setting a channel to active throws an exception.protected void
closeException
(ChannelContext<?> context, Exception exception) This method is called when an attempt to close a channel throws an exception.protected void
connectException
(SocketChannelContext context, Exception exception) This method is called when an attempt to connect a channel throws an exception.protected void
genericChannelException
(ChannelContext<?> context, Exception exception) This method is called when handling an event from a channel fails due to an unexpected exception.protected void
handleActive
(ChannelContext<?> context) This method is called after a NioChannel is active with the selector.protected void
handleClose
(ChannelContext<?> context) This method handles the closing of an NioChannelprotected void
handleConnect
(SocketChannelContext context) This method is called when a NioSocketChannel has just been accepted or if it has receive an OP_CONNECT event.protected void
handleRead
(SocketChannelContext context) This method is called when a channel signals it is ready for be read.protected void
handleRegistration
(ChannelContext<?> context) This method is called when a NioChannel is being registered with the selector.protected void
handleTask
(Runnable task) This method is called when a task or listener attached to a channel is available to run.protected void
handleWrite
(SocketChannelContext context) This method is called when a channel signals it is ready to receive writes.protected void
postHandling
(SocketChannelContext context) This method is called after events (READ, WRITE, CONNECT) have been handled for a channel.protected void
readException
(SocketChannelContext context, Exception exception) This method is called when an attempt to read from a channel throws an exception.protected void
registrationException
(ChannelContext<?> context, Exception exception) This method is called when an attempt to register a channel throws an exception.protected void
selectorException
(IOException exception) This method handles an IOException that was thrown during a call toSelector.select(long)
orSelector.close()
.protected void
taskException
(Exception exception) This method is called when a task or listener attached to a channel operation throws an exception.protected void
uncaughtException
(Exception exception) This method handles an exception that was uncaught during a select loop.protected void
writeException
(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 aSelectionKey
threwCancelledKeyException
.- Parameters:
context
- that caused the exceptionexception
- that was thrown
-