Package org.xnio
Class XnioWorker
java.lang.Object
java.util.concurrent.AbstractExecutorService
org.xnio.XnioWorker
- All Implemented Interfaces:
Executor
,ExecutorService
,org.wildfly.common.context.Contextual<XnioWorker>
,Configurable
,XnioIoFactory
public abstract class XnioWorker
extends AbstractExecutorService
implements Configurable, ExecutorService, XnioIoFactory, org.wildfly.common.context.Contextual<XnioWorker>
A worker for I/O channel notification.
- Since:
- 3.0
- Author:
- David M. Lloyd
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
A builder which allows workers to be programmatically configured. -
Field Summary
Fields inherited from interface org.xnio.channels.Configurable
EMPTY
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
XnioWorker
(XnioWorker.Builder builder) Construct a new instance. -
Method Summary
Modifier and TypeMethodDescriptionacceptDatagram
(SocketAddress destination, ChannelListener<? super ConnectedMessageChannel> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap) Deprecated.acceptMessageConnection
(SocketAddress destination, ChannelListener<? super MessageConnection> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap) Accept a message connection at a destination address.acceptStream
(SocketAddress destination, ChannelListener<? super ConnectedStreamChannel> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap) Deprecated.acceptStreamConnection
(SocketAddress destination, ChannelListener<? super StreamConnection> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap) Accept a stream connection at a destination address.abstract void
Wait for termination.abstract boolean
awaitTermination
(long timeout, TimeUnit unit) Wait for termination.protected abstract XnioIoThread
Choose a thread randomly from this worker.connectDatagram
(SocketAddress bindAddress, SocketAddress destination, ChannelListener<? super ConnectedMessageChannel> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap) Deprecated.connectDatagram
(SocketAddress destination, ChannelListener<? super ConnectedMessageChannel> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap) Deprecated.connectStream
(SocketAddress bindAddress, SocketAddress destination, ChannelListener<? super ConnectedStreamChannel> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap) Deprecated.connectStream
(SocketAddress destination, ChannelListener<? super ConnectedStreamChannel> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap) Deprecated.connectStream
(SocketAddress destination, ChannelListener<? super ConnectedStreamChannel> openListener, OptionMap optionMap) Deprecated.Create a two-way stream pipe.Create a two-way stream pipe.Create a two-way stream pipe.Create a one-way stream pipe.Create a one-way stream pipe.protected AcceptingChannel<StreamConnection>
createLocalStreamConnectionServer
(LocalSocketAddress bindAddress, ChannelListener<? super AcceptingChannel<StreamConnection>> acceptListener, OptionMap optionMap) Implementation helper method to create a UNIX domain stream server.void
createOneWayPipe
(ChannelListener<? super StreamSourceChannel> sourceListener, ChannelListener<? super StreamSinkChannel> sinkListener, OptionMap optionMap) Deprecated.void
createPipe
(ChannelListener<? super StreamChannel> leftOpenListener, ChannelListener<? super StreamChannel> rightOpenListener, OptionMap optionMap) Deprecated.Users should prefer the simplercreateFullDuplexPipe()
instead.createStreamConnectionServer
(SocketAddress bindAddress, ChannelListener<? super AcceptingChannel<StreamConnection>> acceptListener, OptionMap optionMap) Create a stream server, for TCP or UNIX domain servers.AcceptingChannel<? extends ConnectedStreamChannel>
createStreamServer
(SocketAddress bindAddress, ChannelListener<? super AcceptingChannel<ConnectedStreamChannel>> acceptListener, OptionMap optionMap) Deprecated.protected AcceptingChannel<StreamConnection>
createTcpConnectionServer
(InetSocketAddress bindAddress, ChannelListener<? super AcceptingChannel<StreamConnection>> acceptListener, OptionMap optionMap) Implementation helper method to create a TCP stream server.createUdpServer
(InetSocketAddress bindAddress, ChannelListener<? super MulticastMessageChannel> bindListener, OptionMap optionMap) Create a UDP server.createUdpServer
(InetSocketAddress bindAddress, OptionMap optionMap) Create a UDP server.void
Execute a command in the task pool.getBindAddress
(InetAddress destination) Get the expected bind address for the given destination, if any.protected org.wildfly.common.net.CidrAddressTable<InetSocketAddress>
Get the bind address table.protected final int
Get an estimate of the number of busy threads in the worker pool.static org.wildfly.common.context.ContextManager<XnioWorker>
Get the context manager for XNIO workers.protected final int
Get the core worker pool size.protected StreamSinkChannel
getDeflatingChannel
(StreamSinkChannel delegate, Deflater deflater) Create a stream channel that compresses to the destination according to the configuration in the given inflater.getDeflatingChannel
(StreamSinkChannel delegate, OptionMap options) Create a stream channel that compresses to the destination according to the configuration in the given option map.protected StreamSourceChannel
getInflatingChannel
(StreamSourceChannel delegate, Inflater inflater) Create a stream channel that decompresses the source data according to the configuration in the given inflater.getInflatingChannel
(StreamSourceChannel delegate, OptionMap options) Create a stream channel that decompresses the source data according to the configuration in the given option map.org.wildfly.common.context.ContextManager<XnioWorker>
Get the instance context manager for XNIO workers by delegating togetContextManager()
.final XnioIoThread
Get an I/O thread from this worker.abstract XnioIoThread
getIoThread
(int hashCode) Get an I/O thread from this worker.abstract int
Get the number of I/O threads configured on this worker.protected final int
Get the maximum worker pool size.abstract XnioWorkerMXBean
getName()
Get the name of this worker.<T> T
Get the value of a channel option.protected Runnable
Get the user task to run once termination is complete.protected final int
Get an estimate of the number of threads in the worker pool.protected final int
Get an estimate of the number of tasks in the worker queue.getXnio()
Get the XNIO provider which produced this worker.abstract boolean
Determine whether the worker has been shut down.protected boolean
Determine whether the worker task pool is managed externally.abstract boolean
Determine whether the worker has terminated.openMessageConnection
(SocketAddress destination, ChannelListener<? super MessageConnection> openListener, OptionMap optionMap) Connect to a remote message server.openStreamConnection
(SocketAddress bindAddress, SocketAddress destination, ChannelListener<? super StreamConnection> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap) Connect to a remote stream server.openStreamConnection
(SocketAddress destination, ChannelListener<? super StreamConnection> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap) Connect to a remote stream server.openStreamConnection
(SocketAddress destination, ChannelListener<? super StreamConnection> openListener, OptionMap optionMap) Connect to a remote stream server.protected abstract ManagementRegistration
registerServerMXBean
(XnioServerMXBean metrics) <T> T
Set an option for this channel.abstract void
shutdown()
Shut down this worker.Immediately terminate the worker.protected void
Initiate shutdown of the task thread pool.Shut down the task thread pool immediately and return its pending tasks.boolean
supportsOption
(Option<?> option) Determine whether an option is supported on this channel.protected void
Callback to indicate that the task thread pool has terminated.Methods inherited from class java.util.concurrent.AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.wildfly.common.context.Contextual
run, runAction, runBiConsumer, runBiFunction, runBiPredicate, runCallable, runConsumer, runExBiConsumer, runExBiFunction, runExBiPredicate, runExceptionAction, runExConsumer, runExFunction, runExIntFunction, runExLongFunction, runExPredicate, runFunction, runIntFunction, runLongFunction, runPredicate
-
Constructor Details
-
XnioWorker
Construct a new instance. Intended to be called only from implementations.- Parameters:
builder
- the worker builder
-
-
Method Details
-
getContextManager
Get the context manager for XNIO workers.- Returns:
- the context manager (not
null
)
-
getInstanceContextManager
Get the instance context manager for XNIO workers by delegating togetContextManager()
.- Specified by:
getInstanceContextManager
in interfaceorg.wildfly.common.context.Contextual<XnioWorker>
- Returns:
- the context manager (not
null
)
-
createStreamServer
@Deprecated public AcceptingChannel<? extends ConnectedStreamChannel> createStreamServer(SocketAddress bindAddress, ChannelListener<? super AcceptingChannel<ConnectedStreamChannel>> acceptListener, OptionMap optionMap) throws IOException Deprecated.Create a stream server, for TCP or UNIX domain servers. The type of server is determined by the bind address.- Parameters:
bindAddress
- the address to bind toacceptListener
- the initial accept listeneroptionMap
- the initial configuration for the server- Returns:
- the acceptor
- Throws:
IOException
- if the server could not be created
-
createStreamConnectionServer
public AcceptingChannel<StreamConnection> createStreamConnectionServer(SocketAddress bindAddress, ChannelListener<? super AcceptingChannel<StreamConnection>> acceptListener, OptionMap optionMap) throws IOException Create a stream server, for TCP or UNIX domain servers. The type of server is determined by the bind address.- Parameters:
bindAddress
- the address to bind toacceptListener
- the initial accept listeneroptionMap
- the initial configuration for the server- Returns:
- the acceptor
- Throws:
IOException
- if the server could not be created
-
createTcpConnectionServer
protected AcceptingChannel<StreamConnection> createTcpConnectionServer(InetSocketAddress bindAddress, ChannelListener<? super AcceptingChannel<StreamConnection>> acceptListener, OptionMap optionMap) throws IOException Implementation helper method to create a TCP stream server.- Parameters:
bindAddress
- the address to bind toacceptListener
- the initial accept listeneroptionMap
- the initial configuration for the server- Returns:
- the acceptor
- Throws:
IOException
- if the server could not be created
-
createLocalStreamConnectionServer
protected AcceptingChannel<StreamConnection> createLocalStreamConnectionServer(LocalSocketAddress bindAddress, ChannelListener<? super AcceptingChannel<StreamConnection>> acceptListener, OptionMap optionMap) throws IOException Implementation helper method to create a UNIX domain stream server.- Parameters:
bindAddress
- the address to bind toacceptListener
- the initial accept listeneroptionMap
- the initial configuration for the server- Returns:
- the acceptor
- Throws:
IOException
- if the server could not be created
-
connectStream
@Deprecated public IoFuture<ConnectedStreamChannel> connectStream(SocketAddress destination, ChannelListener<? super ConnectedStreamChannel> openListener, OptionMap optionMap) Deprecated.Connect to a remote stream server. The protocol family is determined by the type of the socket address given.- Parameters:
destination
- the destination addressopenListener
- the listener which will be notified when the channel is open, ornull
for noneoptionMap
- the option map- Returns:
- the future result of this operation
-
connectStream
@Deprecated public IoFuture<ConnectedStreamChannel> connectStream(SocketAddress destination, ChannelListener<? super ConnectedStreamChannel> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap) Deprecated.Connect to a remote stream server. The protocol family is determined by the type of the socket address given.- Parameters:
destination
- the destination addressopenListener
- the listener which will be notified when the channel is open, ornull
for nonebindListener
- the listener which will be notified when the channel is bound, ornull
for noneoptionMap
- the option map- Returns:
- the future result of this operation
-
connectStream
@Deprecated public IoFuture<ConnectedStreamChannel> connectStream(SocketAddress bindAddress, SocketAddress destination, ChannelListener<? super ConnectedStreamChannel> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap) Deprecated.Connect to a remote stream server. The protocol family is determined by the type of the socket addresses given (which must match).- Parameters:
bindAddress
- the local address to bind todestination
- the destination addressopenListener
- the listener which will be notified when the channel is open, ornull
for nonebindListener
- the listener which will be notified when the channel is bound, ornull
for noneoptionMap
- the option map- Returns:
- the future result of this operation
-
openStreamConnection
public IoFuture<StreamConnection> openStreamConnection(SocketAddress destination, ChannelListener<? super StreamConnection> openListener, OptionMap optionMap) Description copied from interface:XnioIoFactory
Connect to a remote stream server. The protocol family is determined by the type of the socket address given. If an open listener is used, the channel should not be accessed via the returnedIoFuture
, and vice-versa.- Specified by:
openStreamConnection
in interfaceXnioIoFactory
- Parameters:
destination
- the destination addressopenListener
- the listener which will be notified when the channel is open, ornull
for noneoptionMap
- the option map- Returns:
- the future result of this operation
-
openStreamConnection
public IoFuture<StreamConnection> openStreamConnection(SocketAddress destination, ChannelListener<? super StreamConnection> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap) Description copied from interface:XnioIoFactory
Connect to a remote stream server. The protocol family is determined by the type of the socket address given. If an open listener is used, the channel should not be accessed via the returnedIoFuture
, and vice-versa.- Specified by:
openStreamConnection
in interfaceXnioIoFactory
- Parameters:
destination
- the destination addressopenListener
- the listener which will be notified when the channel is open, ornull
for nonebindListener
- the listener which will be notified when the channel is bound, ornull
for noneoptionMap
- the option map- Returns:
- the future result of this operation
-
openStreamConnection
public IoFuture<StreamConnection> openStreamConnection(SocketAddress bindAddress, SocketAddress destination, ChannelListener<? super StreamConnection> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap) Description copied from interface:XnioIoFactory
Connect to a remote stream server. The protocol family is determined by the type of the socket addresses given (which must match). If an open listener is used, the channel should not be accessed via the returnedIoFuture
, and vice-versa.- Specified by:
openStreamConnection
in interfaceXnioIoFactory
- Parameters:
bindAddress
- the local address to bind todestination
- the destination addressopenListener
- the listener which will be notified when the channel is open, ornull
for nonebindListener
- the listener which will be notified when the channel is bound, ornull
for noneoptionMap
- the option map- Returns:
- the future result of this operation
-
acceptStream
@Deprecated public IoFuture<ConnectedStreamChannel> acceptStream(SocketAddress destination, ChannelListener<? super ConnectedStreamChannel> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap) Deprecated.Accept a stream connection at a destination address. If a wildcard address is specified, then a destination address is chosen in a manner specific to the OS and/or channel type.- Parameters:
destination
- the destination (bind) addressopenListener
- the listener which will be notified when the channel is open, ornull
for nonebindListener
- the listener which will be notified when the acceptor is bound, ornull
for noneoptionMap
- the option map- Returns:
- the future connection
-
acceptStreamConnection
public IoFuture<StreamConnection> acceptStreamConnection(SocketAddress destination, ChannelListener<? super StreamConnection> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap) Description copied from interface:XnioIoFactory
Accept a stream connection at a destination address. If a wildcard address is specified, then a destination address is chosen in a manner specific to the OS and/or channel type.- Specified by:
acceptStreamConnection
in interfaceXnioIoFactory
- Parameters:
destination
- the destination (bind) addressopenListener
- the listener which will be notified when the channel is open, ornull
for nonebindListener
- the listener which will be notified when the acceptor is bound, ornull
for noneoptionMap
- the option map- Returns:
- the future connection
-
connectDatagram
@Deprecated public IoFuture<ConnectedMessageChannel> connectDatagram(SocketAddress destination, ChannelListener<? super ConnectedMessageChannel> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap) Deprecated.Connect to a remote datagram server. The protocol family is determined by the type of the socket address given.- Parameters:
destination
- the destination addressopenListener
- the listener which will be notified when the channel is open, ornull
for nonebindListener
- the listener which will be notified when the channel is bound, ornull
for noneoptionMap
- the option map- Returns:
- the future result of this operation
-
connectDatagram
@Deprecated public IoFuture<ConnectedMessageChannel> connectDatagram(SocketAddress bindAddress, SocketAddress destination, ChannelListener<? super ConnectedMessageChannel> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap) Deprecated.Connect to a remote datagram server. The protocol family is determined by the type of the socket addresses given (which must match).- Parameters:
bindAddress
- the local address to bind todestination
- the destination addressopenListener
- the listener which will be notified when the channel is open, ornull
for nonebindListener
- the listener which will be notified when the channel is bound, ornull
for noneoptionMap
- the option map- Returns:
- the future result of this operation
-
openMessageConnection
public IoFuture<MessageConnection> openMessageConnection(SocketAddress destination, ChannelListener<? super MessageConnection> openListener, OptionMap optionMap) Description copied from interface:XnioIoFactory
Connect to a remote message server. The protocol family is determined by the type of the socket address given. If an open listener is used, the channel should not be accessed via the returnedIoFuture
, and vice-versa.- Specified by:
openMessageConnection
in interfaceXnioIoFactory
- Parameters:
destination
- the destination addressopenListener
- the listener which will be notified when the channel is open, ornull
for noneoptionMap
- the option map- Returns:
- the future result of this operation
-
acceptDatagram
@Deprecated public IoFuture<ConnectedMessageChannel> acceptDatagram(SocketAddress destination, ChannelListener<? super ConnectedMessageChannel> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap) Deprecated.Accept a message connection at a destination address. If a wildcard address is specified, then a destination address is chosen in a manner specific to the OS and/or channel type.- Parameters:
destination
- the destination (bind) addressopenListener
- the listener which will be notified when the channel is open, ornull
for nonebindListener
- the listener which will be notified when the acceptor is bound, ornull
for noneoptionMap
- the option map- Returns:
- the future connection
-
acceptMessageConnection
public IoFuture<MessageConnection> acceptMessageConnection(SocketAddress destination, ChannelListener<? super MessageConnection> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap) Description copied from interface:XnioIoFactory
Accept a message connection at a destination address. If a wildcard address is specified, then a destination address is chosen in a manner specific to the OS and/or channel type. If an open listener is used, the channel should not be accessed via the returnedIoFuture
, and vice-versa.- Specified by:
acceptMessageConnection
in interfaceXnioIoFactory
- Parameters:
destination
- the destination (bind) addressopenListener
- the listener which will be notified when the channel is open, ornull
for nonebindListener
- the listener which will be notified when the acceptor is bound, ornull
for noneoptionMap
- the option map- Returns:
- the future connection
-
createUdpServer
public MulticastMessageChannel createUdpServer(InetSocketAddress bindAddress, ChannelListener<? super MulticastMessageChannel> bindListener, OptionMap optionMap) throws IOException Create a UDP server. The UDP server can be configured to be multicast-capable; this should only be done if multicast is needed, since some providers have a performance penalty associated with multicast. The provider's default executor will be used to execute listener methods.- Parameters:
bindAddress
- the bind addressbindListener
- the initial open-connection listeneroptionMap
- the initial configuration for the server- Returns:
- the UDP server channel
- Throws:
IOException
- if the server could not be created- Since:
- 3.0
-
createUdpServer
public MulticastMessageChannel createUdpServer(InetSocketAddress bindAddress, OptionMap optionMap) throws IOException Create a UDP server. The UDP server can be configured to be multicast-capable; this should only be done if multicast is needed, since some providers have a performance penalty associated with multicast. The provider's default executor will be used to execute listener methods.- Parameters:
bindAddress
- the bind addressoptionMap
- the initial configuration for the server- Returns:
- the UDP server channel
- Throws:
IOException
- if the server could not be created- Since:
- 3.0
-
createPipe
@Deprecated public void createPipe(ChannelListener<? super StreamChannel> leftOpenListener, ChannelListener<? super StreamChannel> rightOpenListener, OptionMap optionMap) throws IOException Deprecated.Users should prefer the simplercreateFullDuplexPipe()
instead.Open a bidirectional stream pipe.- Parameters:
leftOpenListener
- the left-hand open listenerrightOpenListener
- the right-hand open listeneroptionMap
- the pipe channel configuration- Throws:
IOException
- if the pipe could not be created
-
createOneWayPipe
@Deprecated public void createOneWayPipe(ChannelListener<? super StreamSourceChannel> sourceListener, ChannelListener<? super StreamSinkChannel> sinkListener, OptionMap optionMap) throws IOException Deprecated.Users should prefer the simplercreateHalfDuplexPipe()
instead.Open a unidirectional stream pipe.- Parameters:
sourceListener
- the source open listenersinkListener
- the sink open listeneroptionMap
- the pipe channel configuration- Throws:
IOException
- if the pipe could not be created
-
getInflatingChannel
public StreamSourceChannel getInflatingChannel(StreamSourceChannel delegate, OptionMap options) throws IOException Create a stream channel that decompresses the source data according to the configuration in the given option map.- Parameters:
delegate
- the compressed channeloptions
- the configuration options for the channel- Returns:
- a decompressed channel
- Throws:
IOException
- if the channel could not be constructed
-
getInflatingChannel
protected StreamSourceChannel getInflatingChannel(StreamSourceChannel delegate, Inflater inflater) throws IOException Create a stream channel that decompresses the source data according to the configuration in the given inflater.- Parameters:
delegate
- the compressed channelinflater
- the inflater to use- Returns:
- a decompressed channel
- Throws:
IOException
- if the channel could not be constructed
-
getDeflatingChannel
public StreamSinkChannel getDeflatingChannel(StreamSinkChannel delegate, OptionMap options) throws IOException Create a stream channel that compresses to the destination according to the configuration in the given option map.- Parameters:
delegate
- the channel to compress tooptions
- the configuration options for the channel- Returns:
- a compressed channel
- Throws:
IOException
- if the channel could not be constructed
-
getDeflatingChannel
protected StreamSinkChannel getDeflatingChannel(StreamSinkChannel delegate, Deflater deflater) throws IOException Create a stream channel that compresses to the destination according to the configuration in the given inflater.- Parameters:
delegate
- the channel to compress todeflater
- the deflater to use- Returns:
- a compressed channel
- Throws:
IOException
- if the channel could not be constructed
-
createFullDuplexPipe
Description copied from interface:XnioIoFactory
Create a two-way stream pipe.- Specified by:
createFullDuplexPipe
in interfaceXnioIoFactory
- Returns:
- the created pipe
- Throws:
IOException
- if the pipe could not be created
-
createFullDuplexPipeConnection
public ChannelPipe<StreamConnection,StreamConnection> createFullDuplexPipeConnection() throws IOExceptionDescription copied from interface:XnioIoFactory
Create a two-way stream pipe.- Specified by:
createFullDuplexPipeConnection
in interfaceXnioIoFactory
- Returns:
- the created pipe
- Throws:
IOException
- if the pipe could not be created
-
createHalfDuplexPipe
Description copied from interface:XnioIoFactory
Create a one-way stream pipe.- Specified by:
createHalfDuplexPipe
in interfaceXnioIoFactory
- Returns:
- the created pipe
- Throws:
IOException
- if the pipe could not be created
-
createFullDuplexPipeConnection
public ChannelPipe<StreamConnection,StreamConnection> createFullDuplexPipeConnection(XnioIoFactory peer) throws IOException Description copied from interface:XnioIoFactory
Create a two-way stream pipe. The left side will be associated with this factory, and the right side will be associated with the given peer.- Specified by:
createFullDuplexPipeConnection
in interfaceXnioIoFactory
- Parameters:
peer
- the peer to use for controlling the remote (right) side- Returns:
- the created pipe
- Throws:
IOException
- if the pipe could not be created
-
createHalfDuplexPipe
public ChannelPipe<StreamSourceChannel,StreamSinkChannel> createHalfDuplexPipe(XnioIoFactory peer) throws IOException Description copied from interface:XnioIoFactory
Create a one-way stream pipe. The left (source) side will be associated with this factory, and the right (sink) side will be associated with the given peer.- Specified by:
createHalfDuplexPipe
in interfaceXnioIoFactory
- Parameters:
peer
- the peer to use for the sink (right) side- Returns:
- the created pipe
- Throws:
IOException
- if the pipe could not be created
-
shutdown
public abstract void shutdown()Shut down this worker. This method returns immediately. Upon return worker shutdown will have commenced but not necessarily completed. When worker shutdown is complete, the termination task (if one was defined) will be executed.- Specified by:
shutdown
in interfaceExecutorService
-
shutdownNow
Immediately terminate the worker. Any outstanding tasks are collected and returned in a list. Upon return worker shutdown will have commenced but not necessarily completed; however the worker will only complete its current tasks instead of completing all tasks.- Specified by:
shutdownNow
in interfaceExecutorService
- Returns:
- the list of outstanding tasks
-
isShutdown
public abstract boolean isShutdown()Determine whether the worker has been shut down. Will returntrue
once either shutdown method has been called.- Specified by:
isShutdown
in interfaceExecutorService
- Returns:
true
the worker has been shut down
-
isTerminated
public abstract boolean isTerminated()Determine whether the worker has terminated. Will returntrue
once all worker threads are exited (with the possible exception of the thread running the termination task, if any).- Specified by:
isTerminated
in interfaceExecutorService
- Returns:
true
if the worker is terminated
-
awaitTermination
Wait for termination.- Specified by:
awaitTermination
in interfaceExecutorService
- Parameters:
timeout
- the amount of time to waitunit
- the unit of time- Returns:
true
if termination completed before the timeout expired- Throws:
InterruptedException
- if the operation was interrupted
-
awaitTermination
Wait for termination.- Throws:
InterruptedException
- if the operation was interrupted
-
getIoThread
Get an I/O thread from this worker. The thread may be chosen based on arbitrary rules.- Returns:
- the I/O thread
-
getIoThread
Get an I/O thread from this worker. The thread is chosen based on the given hash code.- Parameters:
hashCode
- the hash code- Returns:
- the thread
-
getTerminationTask
Get the user task to run once termination is complete.- Returns:
- the termination task
-
taskPoolTerminated
protected void taskPoolTerminated()Callback to indicate that the task thread pool has terminated. Not called if the task pool is external. -
shutDownTaskPool
protected void shutDownTaskPool()Initiate shutdown of the task thread pool. When all the tasks and threads have completed, thetaskPoolTerminated()
method is called. -
shutDownTaskPoolNow
Shut down the task thread pool immediately and return its pending tasks.- Returns:
- the pending task list
-
isTaskPoolExternal
protected boolean isTaskPoolExternal()Determine whether the worker task pool is managed externally. Externally managed task pools will never respond to shut down requests.- Returns:
true
if the task pool is externally managed,false
otherwise
-
execute
Execute a command in the task pool. -
getIoThreadCount
public abstract int getIoThreadCount()Get the number of I/O threads configured on this worker.- Returns:
- the number of I/O threads configured on this worker
-
supportsOption
Description copied from interface:Configurable
Determine whether an option is supported on this channel.- Specified by:
supportsOption
in interfaceConfigurable
- Parameters:
option
- the option- Returns:
true
if it is supported
-
getOption
Description copied from interface:Configurable
Get the value of a channel option.- Specified by:
getOption
in interfaceConfigurable
- Type Parameters:
T
- the type of the option value- Parameters:
option
- the option to get- Returns:
- the value of the option, or
null
if it is not set - Throws:
IOException
- if an I/O error occurred when reading the option
-
setOption
Description copied from interface:Configurable
Set an option for this channel. Unsupported options are ignored.- Specified by:
setOption
in interfaceConfigurable
- Type Parameters:
T
- the type of the option value- Parameters:
option
- the option to setvalue
- the value of the option to set- Returns:
- the previous option value, if any
- Throws:
IllegalArgumentException
- if the value is not acceptable for this optionIOException
- if an I/O error occurred when modifying the option
-
getXnio
Get the XNIO provider which produced this worker.- Returns:
- the XNIO provider
-
getName
Get the name of this worker.- Returns:
- the name of the worker
-
chooseThread
Choose a thread randomly from this worker.- Returns:
- the thread
-
getCoreWorkerPoolSize
protected final int getCoreWorkerPoolSize()Get the core worker pool size.- Returns:
- the core worker pool size
-
getBusyWorkerThreadCount
protected final int getBusyWorkerThreadCount()Get an estimate of the number of busy threads in the worker pool.- Returns:
- the estimated number of busy threads in the worker pool
-
getWorkerPoolSize
protected final int getWorkerPoolSize()Get an estimate of the number of threads in the worker pool.- Returns:
- the estimated number of threads in the worker pool
-
getMaxWorkerPoolSize
protected final int getMaxWorkerPoolSize()Get the maximum worker pool size.- Returns:
- the maximum worker pool size
-
getWorkerQueueSize
protected final int getWorkerQueueSize()Get an estimate of the number of tasks in the worker queue.- Returns:
- the estimated number of tasks
-
getBindAddressTable
Get the bind address table.- Returns:
- the bind address table
-
getBindAddress
Get the expected bind address for the given destination, if any.- Returns:
- the expected bind address for the given destination, or
null
if no explicit bind will be done
-
getMXBean
-
registerServerMXBean
-
createHalfDuplexPipe()
instead.