- java.lang.Object
-
- java.util.concurrent.AbstractExecutorService
-
- org.xnio.XnioWorker
-
- All Implemented Interfaces:
java.util.concurrent.Executor,java.util.concurrent.ExecutorService,org.wildfly.common.context.Contextual<XnioWorker>,Configurable,XnioIoFactory
public abstract class XnioWorker extends java.util.concurrent.AbstractExecutorService implements Configurable, java.util.concurrent.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 Classes Modifier and Type Class Description static classXnioWorker.BuilderA builder which allows workers to be programmatically configured.
-
Field Summary
-
Fields inherited from interface org.xnio.channels.Configurable
EMPTY
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedXnioWorker(XnioWorker.Builder builder)Construct a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description IoFuture<ConnectedMessageChannel>acceptDatagram(java.net.SocketAddress destination, ChannelListener<? super ConnectedMessageChannel> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap)Deprecated.IoFuture<MessageConnection>acceptMessageConnection(java.net.SocketAddress destination, ChannelListener<? super MessageConnection> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap)Accept a message connection at a destination address.IoFuture<ConnectedStreamChannel>acceptStream(java.net.SocketAddress destination, ChannelListener<? super ConnectedStreamChannel> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap)Deprecated.IoFuture<StreamConnection>acceptStreamConnection(java.net.SocketAddress destination, ChannelListener<? super StreamConnection> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap)Accept a stream connection at a destination address.abstract voidawaitTermination()Wait for termination.abstract booleanawaitTermination(long timeout, java.util.concurrent.TimeUnit unit)Wait for termination.protected abstract XnioIoThreadchooseThread()Choose a thread randomly from this worker.IoFuture<ConnectedMessageChannel>connectDatagram(java.net.SocketAddress bindAddress, java.net.SocketAddress destination, ChannelListener<? super ConnectedMessageChannel> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap)Deprecated.IoFuture<ConnectedMessageChannel>connectDatagram(java.net.SocketAddress destination, ChannelListener<? super ConnectedMessageChannel> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap)Deprecated.IoFuture<ConnectedStreamChannel>connectStream(java.net.SocketAddress bindAddress, java.net.SocketAddress destination, ChannelListener<? super ConnectedStreamChannel> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap)Deprecated.IoFuture<ConnectedStreamChannel>connectStream(java.net.SocketAddress destination, ChannelListener<? super ConnectedStreamChannel> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap)Deprecated.IoFuture<ConnectedStreamChannel>connectStream(java.net.SocketAddress destination, ChannelListener<? super ConnectedStreamChannel> openListener, OptionMap optionMap)Deprecated.ChannelPipe<StreamChannel,StreamChannel>createFullDuplexPipe()Create a two-way stream pipe.ChannelPipe<StreamConnection,StreamConnection>createFullDuplexPipeConnection()Create a two-way stream pipe.ChannelPipe<StreamConnection,StreamConnection>createFullDuplexPipeConnection(XnioIoFactory peer)Create a two-way stream pipe.ChannelPipe<StreamSourceChannel,StreamSinkChannel>createHalfDuplexPipe()Create a one-way stream pipe.ChannelPipe<StreamSourceChannel,StreamSinkChannel>createHalfDuplexPipe(XnioIoFactory peer)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.voidcreateOneWayPipe(ChannelListener<? super StreamSourceChannel> sourceListener, ChannelListener<? super StreamSinkChannel> sinkListener, OptionMap optionMap)Deprecated.Users should prefer the simplercreateHalfDuplexPipe()instead.voidcreatePipe(ChannelListener<? super StreamChannel> leftOpenListener, ChannelListener<? super StreamChannel> rightOpenListener, OptionMap optionMap)Deprecated.Users should prefer the simplercreateFullDuplexPipe()instead.AcceptingChannel<StreamConnection>createStreamConnectionServer(java.net.SocketAddress bindAddress, ChannelListener<? super AcceptingChannel<StreamConnection>> acceptListener, OptionMap optionMap)Create a stream server, for TCP or UNIX domain servers.AcceptingChannel<? extends ConnectedStreamChannel>createStreamServer(java.net.SocketAddress bindAddress, ChannelListener<? super AcceptingChannel<ConnectedStreamChannel>> acceptListener, OptionMap optionMap)Deprecated.protected AcceptingChannel<StreamConnection>createTcpConnectionServer(java.net.InetSocketAddress bindAddress, ChannelListener<? super AcceptingChannel<StreamConnection>> acceptListener, OptionMap optionMap)Implementation helper method to create a TCP stream server.MulticastMessageChannelcreateUdpServer(java.net.InetSocketAddress bindAddress, ChannelListener<? super MulticastMessageChannel> bindListener, OptionMap optionMap)Create a UDP server.MulticastMessageChannelcreateUdpServer(java.net.InetSocketAddress bindAddress, OptionMap optionMap)Create a UDP server.voidexecute(java.lang.Runnable command)Execute a command in the task pool.java.net.InetSocketAddressgetBindAddress(java.net.InetAddress destination)Get the expected bind address for the given destination, if any.protected org.wildfly.common.net.CidrAddressTable<java.net.InetSocketAddress>getBindAddressTable()Get the bind address table.protected intgetBusyWorkerThreadCount()Get an estimate of the number of busy threads in the worker pool.static org.wildfly.common.context.ContextManager<XnioWorker>getContextManager()Get the context manager for XNIO workers.protected intgetCoreWorkerPoolSize()Get the core worker pool size.protected StreamSinkChannelgetDeflatingChannel(StreamSinkChannel delegate, java.util.zip.Deflater deflater)Create a stream channel that compresses to the destination according to the configuration in the given inflater.StreamSinkChannelgetDeflatingChannel(StreamSinkChannel delegate, OptionMap options)Create a stream channel that compresses to the destination according to the configuration in the given option map.protected StreamSourceChannelgetInflatingChannel(StreamSourceChannel delegate, java.util.zip.Inflater inflater)Create a stream channel that decompresses the source data according to the configuration in the given inflater.StreamSourceChannelgetInflatingChannel(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>getInstanceContextManager()Get the instance context manager for XNIO workers by delegating togetContextManager().XnioIoThreadgetIoThread()Get an I/O thread from this worker.abstract XnioIoThreadgetIoThread(int hashCode)Get an I/O thread from this worker.abstract intgetIoThreadCount()Get the number of I/O threads configured on this worker.protected intgetMaxWorkerPoolSize()Get the maximum worker pool size.abstract XnioWorkerMXBeangetMXBean()java.lang.StringgetName()Get the name of this worker.<T> TgetOption(Option<T> option)Get the value of a channel option.protected java.lang.RunnablegetTerminationTask()Get the user task to run once termination is complete.protected intgetWorkerPoolSize()Get an estimate of the number of threads in the worker pool.protected intgetWorkerQueueSize()Get an estimate of the number of tasks in the worker queue.XniogetXnio()Get the XNIO provider which produced this worker.abstract booleanisShutdown()Determine whether the worker has been shut down.protected booleanisTaskPoolExternal()Determine whether the worker task pool is managed externally.abstract booleanisTerminated()Determine whether the worker has terminated.IoFuture<MessageConnection>openMessageConnection(java.net.SocketAddress destination, ChannelListener<? super MessageConnection> openListener, OptionMap optionMap)Connect to a remote message server.IoFuture<StreamConnection>openStreamConnection(java.net.SocketAddress bindAddress, java.net.SocketAddress destination, ChannelListener<? super StreamConnection> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap)Connect to a remote stream server.IoFuture<StreamConnection>openStreamConnection(java.net.SocketAddress destination, ChannelListener<? super StreamConnection> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap)Connect to a remote stream server.IoFuture<StreamConnection>openStreamConnection(java.net.SocketAddress destination, ChannelListener<? super StreamConnection> openListener, OptionMap optionMap)Connect to a remote stream server.protected abstract ManagementRegistrationregisterServerMXBean(XnioServerMXBean metrics)<T> TsetOption(Option<T> option, T value)Set an option for this channel.abstract voidshutdown()Shut down this worker.abstract java.util.List<java.lang.Runnable>shutdownNow()Immediately terminate the worker.protected voidshutDownTaskPool()Initiate shutdown of the task thread pool.protected java.util.List<java.lang.Runnable>shutDownTaskPoolNow()Shut down the task thread pool immediately and return its pending tasks.booleansupportsOption(Option<?> option)Determine whether an option is supported on this channel.protected voidtaskPoolTerminated()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 Detail
-
XnioWorker
protected XnioWorker(XnioWorker.Builder builder)
Construct a new instance. Intended to be called only from implementations.- Parameters:
builder- the worker builder
-
-
Method Detail
-
getContextManager
public static org.wildfly.common.context.ContextManager<XnioWorker> getContextManager()
Get the context manager for XNIO workers.- Returns:
- the context manager (not
null)
-
getInstanceContextManager
public org.wildfly.common.context.ContextManager<XnioWorker> getInstanceContextManager()
Get the instance context manager for XNIO workers by delegating togetContextManager().- Specified by:
getInstanceContextManagerin interfaceorg.wildfly.common.context.Contextual<XnioWorker>- Returns:
- the context manager (not
null)
-
createStreamServer
@Deprecated public AcceptingChannel<? extends ConnectedStreamChannel> createStreamServer(java.net.SocketAddress bindAddress, ChannelListener<? super AcceptingChannel<ConnectedStreamChannel>> acceptListener, OptionMap optionMap) throws java.io.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:
java.io.IOException- if the server could not be created
-
createStreamConnectionServer
public AcceptingChannel<StreamConnection> createStreamConnectionServer(java.net.SocketAddress bindAddress, ChannelListener<? super AcceptingChannel<StreamConnection>> acceptListener, OptionMap optionMap) throws java.io.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:
java.io.IOException- if the server could not be created
-
createTcpConnectionServer
protected AcceptingChannel<StreamConnection> createTcpConnectionServer(java.net.InetSocketAddress bindAddress, ChannelListener<? super AcceptingChannel<StreamConnection>> acceptListener, OptionMap optionMap) throws java.io.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:
java.io.IOException- if the server could not be created
-
createLocalStreamConnectionServer
protected AcceptingChannel<StreamConnection> createLocalStreamConnectionServer(LocalSocketAddress bindAddress, ChannelListener<? super AcceptingChannel<StreamConnection>> acceptListener, OptionMap optionMap) throws java.io.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:
java.io.IOException- if the server could not be created
-
connectStream
@Deprecated public IoFuture<ConnectedStreamChannel> connectStream(java.net.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, ornullfor noneoptionMap- the option map- Returns:
- the future result of this operation
-
connectStream
@Deprecated public IoFuture<ConnectedStreamChannel> connectStream(java.net.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, ornullfor nonebindListener- the listener which will be notified when the channel is bound, ornullfor noneoptionMap- the option map- Returns:
- the future result of this operation
-
connectStream
@Deprecated public IoFuture<ConnectedStreamChannel> connectStream(java.net.SocketAddress bindAddress, java.net.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, ornullfor nonebindListener- the listener which will be notified when the channel is bound, ornullfor noneoptionMap- the option map- Returns:
- the future result of this operation
-
openStreamConnection
public IoFuture<StreamConnection> openStreamConnection(java.net.SocketAddress destination, ChannelListener<? super StreamConnection> openListener, OptionMap optionMap)
Description copied from interface:XnioIoFactoryConnect 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:
openStreamConnectionin interfaceXnioIoFactory- Parameters:
destination- the destination addressopenListener- the listener which will be notified when the channel is open, ornullfor noneoptionMap- the option map- Returns:
- the future result of this operation
-
openStreamConnection
public IoFuture<StreamConnection> openStreamConnection(java.net.SocketAddress destination, ChannelListener<? super StreamConnection> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap)
Description copied from interface:XnioIoFactoryConnect 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:
openStreamConnectionin interfaceXnioIoFactory- Parameters:
destination- the destination addressopenListener- the listener which will be notified when the channel is open, ornullfor nonebindListener- the listener which will be notified when the channel is bound, ornullfor noneoptionMap- the option map- Returns:
- the future result of this operation
-
openStreamConnection
public IoFuture<StreamConnection> openStreamConnection(java.net.SocketAddress bindAddress, java.net.SocketAddress destination, ChannelListener<? super StreamConnection> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap)
Description copied from interface:XnioIoFactoryConnect 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:
openStreamConnectionin interfaceXnioIoFactory- Parameters:
bindAddress- the local address to bind todestination- the destination addressopenListener- the listener which will be notified when the channel is open, ornullfor nonebindListener- the listener which will be notified when the channel is bound, ornullfor noneoptionMap- the option map- Returns:
- the future result of this operation
-
acceptStream
@Deprecated public IoFuture<ConnectedStreamChannel> acceptStream(java.net.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, ornullfor nonebindListener- the listener which will be notified when the acceptor is bound, ornullfor noneoptionMap- the option map- Returns:
- the future connection
-
acceptStreamConnection
public IoFuture<StreamConnection> acceptStreamConnection(java.net.SocketAddress destination, ChannelListener<? super StreamConnection> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap)
Description copied from interface:XnioIoFactoryAccept 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:
acceptStreamConnectionin interfaceXnioIoFactory- Parameters:
destination- the destination (bind) addressopenListener- the listener which will be notified when the channel is open, ornullfor nonebindListener- the listener which will be notified when the acceptor is bound, ornullfor noneoptionMap- the option map- Returns:
- the future connection
-
connectDatagram
@Deprecated public IoFuture<ConnectedMessageChannel> connectDatagram(java.net.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, ornullfor nonebindListener- the listener which will be notified when the channel is bound, ornullfor noneoptionMap- the option map- Returns:
- the future result of this operation
-
connectDatagram
@Deprecated public IoFuture<ConnectedMessageChannel> connectDatagram(java.net.SocketAddress bindAddress, java.net.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, ornullfor nonebindListener- the listener which will be notified when the channel is bound, ornullfor noneoptionMap- the option map- Returns:
- the future result of this operation
-
openMessageConnection
public IoFuture<MessageConnection> openMessageConnection(java.net.SocketAddress destination, ChannelListener<? super MessageConnection> openListener, OptionMap optionMap)
Description copied from interface:XnioIoFactoryConnect 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:
openMessageConnectionin interfaceXnioIoFactory- Parameters:
destination- the destination addressopenListener- the listener which will be notified when the channel is open, ornullfor noneoptionMap- the option map- Returns:
- the future result of this operation
-
acceptDatagram
@Deprecated public IoFuture<ConnectedMessageChannel> acceptDatagram(java.net.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, ornullfor nonebindListener- the listener which will be notified when the acceptor is bound, ornullfor noneoptionMap- the option map- Returns:
- the future connection
-
acceptMessageConnection
public IoFuture<MessageConnection> acceptMessageConnection(java.net.SocketAddress destination, ChannelListener<? super MessageConnection> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap)
Description copied from interface:XnioIoFactoryAccept 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:
acceptMessageConnectionin interfaceXnioIoFactory- Parameters:
destination- the destination (bind) addressopenListener- the listener which will be notified when the channel is open, ornullfor nonebindListener- the listener which will be notified when the acceptor is bound, ornullfor noneoptionMap- the option map- Returns:
- the future connection
-
createUdpServer
public MulticastMessageChannel createUdpServer(java.net.InetSocketAddress bindAddress, ChannelListener<? super MulticastMessageChannel> bindListener, OptionMap optionMap) throws java.io.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:
java.io.IOException- if the server could not be created- Since:
- 3.0
-
createUdpServer
public MulticastMessageChannel createUdpServer(java.net.InetSocketAddress bindAddress, OptionMap optionMap) throws java.io.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:
java.io.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 java.io.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:
java.io.IOException- if the pipe could not be created
-
createOneWayPipe
@Deprecated public void createOneWayPipe(ChannelListener<? super StreamSourceChannel> sourceListener, ChannelListener<? super StreamSinkChannel> sinkListener, OptionMap optionMap) throws java.io.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:
java.io.IOException- if the pipe could not be created
-
getInflatingChannel
public StreamSourceChannel getInflatingChannel(StreamSourceChannel delegate, OptionMap options) throws java.io.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:
java.io.IOException- if the channel could not be constructed
-
getInflatingChannel
protected StreamSourceChannel getInflatingChannel(StreamSourceChannel delegate, java.util.zip.Inflater inflater) throws java.io.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:
java.io.IOException- if the channel could not be constructed
-
getDeflatingChannel
public StreamSinkChannel getDeflatingChannel(StreamSinkChannel delegate, OptionMap options) throws java.io.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:
java.io.IOException- if the channel could not be constructed
-
getDeflatingChannel
protected StreamSinkChannel getDeflatingChannel(StreamSinkChannel delegate, java.util.zip.Deflater deflater) throws java.io.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:
java.io.IOException- if the channel could not be constructed
-
createFullDuplexPipe
public ChannelPipe<StreamChannel,StreamChannel> createFullDuplexPipe() throws java.io.IOException
Description copied from interface:XnioIoFactoryCreate a two-way stream pipe.- Specified by:
createFullDuplexPipein interfaceXnioIoFactory- Returns:
- the created pipe
- Throws:
java.io.IOException- if the pipe could not be created
-
createFullDuplexPipeConnection
public ChannelPipe<StreamConnection,StreamConnection> createFullDuplexPipeConnection() throws java.io.IOException
Description copied from interface:XnioIoFactoryCreate a two-way stream pipe.- Specified by:
createFullDuplexPipeConnectionin interfaceXnioIoFactory- Returns:
- the created pipe
- Throws:
java.io.IOException- if the pipe could not be created
-
createHalfDuplexPipe
public ChannelPipe<StreamSourceChannel,StreamSinkChannel> createHalfDuplexPipe() throws java.io.IOException
Description copied from interface:XnioIoFactoryCreate a one-way stream pipe.- Specified by:
createHalfDuplexPipein interfaceXnioIoFactory- Returns:
- the created pipe
- Throws:
java.io.IOException- if the pipe could not be created
-
createFullDuplexPipeConnection
public ChannelPipe<StreamConnection,StreamConnection> createFullDuplexPipeConnection(XnioIoFactory peer) throws java.io.IOException
Description copied from interface:XnioIoFactoryCreate 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:
createFullDuplexPipeConnectionin interfaceXnioIoFactory- Parameters:
peer- the peer to use for controlling the remote (right) side- Returns:
- the created pipe
- Throws:
java.io.IOException- if the pipe could not be created
-
createHalfDuplexPipe
public ChannelPipe<StreamSourceChannel,StreamSinkChannel> createHalfDuplexPipe(XnioIoFactory peer) throws java.io.IOException
Description copied from interface:XnioIoFactoryCreate 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:
createHalfDuplexPipein interfaceXnioIoFactory- Parameters:
peer- the peer to use for the sink (right) side- Returns:
- the created pipe
- Throws:
java.io.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:
shutdownin interfacejava.util.concurrent.ExecutorService
-
shutdownNow
public abstract java.util.List<java.lang.Runnable> 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:
shutdownNowin interfacejava.util.concurrent.ExecutorService- Returns:
- the list of outstanding tasks
-
isShutdown
public abstract boolean isShutdown()
Determine whether the worker has been shut down. Will returntrueonce either shutdown method has been called.- Specified by:
isShutdownin interfacejava.util.concurrent.ExecutorService- Returns:
truethe worker has been shut down
-
isTerminated
public abstract boolean isTerminated()
Determine whether the worker has terminated. Will returntrueonce all worker threads are exited (with the possible exception of the thread running the termination task, if any).- Specified by:
isTerminatedin interfacejava.util.concurrent.ExecutorService- Returns:
trueif the worker is terminated
-
awaitTermination
public abstract boolean awaitTermination(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedExceptionWait for termination.- Specified by:
awaitTerminationin interfacejava.util.concurrent.ExecutorService- Parameters:
timeout- the amount of time to waitunit- the unit of time- Returns:
trueif termination completed before the timeout expired- Throws:
java.lang.InterruptedException- if the operation was interrupted
-
awaitTermination
public abstract void awaitTermination() throws java.lang.InterruptedExceptionWait for termination.- Throws:
java.lang.InterruptedException- if the operation was interrupted
-
getIoThread
public final XnioIoThread getIoThread()
Get an I/O thread from this worker. The thread may be chosen based on arbitrary rules.- Returns:
- the I/O thread
-
getIoThread
public abstract XnioIoThread getIoThread(int hashCode)
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
protected java.lang.Runnable 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
protected java.util.List<java.lang.Runnable> 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:
trueif the task pool is externally managed,falseotherwise
-
execute
public void execute(java.lang.Runnable command)
Execute a command in the task pool.- Specified by:
executein interfacejava.util.concurrent.Executor- Parameters:
command- the command to run
-
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
public boolean supportsOption(Option<?> option)
Description copied from interface:ConfigurableDetermine whether an option is supported on this channel.- Specified by:
supportsOptionin interfaceConfigurable- Parameters:
option- the option- Returns:
trueif it is supported
-
getOption
public <T> T getOption(Option<T> option) throws java.io.IOException
Description copied from interface:ConfigurableGet the value of a channel option.- Specified by:
getOptionin interfaceConfigurable- Type Parameters:
T- the type of the option value- Parameters:
option- the option to get- Returns:
- the value of the option, or
nullif it is not set - Throws:
java.io.IOException- if an I/O error occurred when reading the option
-
setOption
public <T> T setOption(Option<T> option, T value) throws java.lang.IllegalArgumentException, java.io.IOException
Description copied from interface:ConfigurableSet an option for this channel. Unsupported options are ignored.- Specified by:
setOptionin 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:
java.lang.IllegalArgumentException- if the value is not acceptable for this optionjava.io.IOException- if an I/O error occurred when modifying the option
-
getXnio
public Xnio getXnio()
Get the XNIO provider which produced this worker.- Returns:
- the XNIO provider
-
getName
public java.lang.String getName()
Get the name of this worker.- Returns:
- the name of the worker
-
chooseThread
protected abstract XnioIoThread 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
protected org.wildfly.common.net.CidrAddressTable<java.net.InetSocketAddress> getBindAddressTable()
Get the bind address table.- Returns:
- the bind address table
-
getBindAddress
public java.net.InetSocketAddress getBindAddress(java.net.InetAddress destination)
Get the expected bind address for the given destination, if any.- Returns:
- the expected bind address for the given destination, or
nullif no explicit bind will be done
-
getMXBean
public abstract XnioWorkerMXBean getMXBean()
-
registerServerMXBean
protected abstract ManagementRegistration registerServerMXBean(XnioServerMXBean metrics)
-
-