public abstract class XnioWorker extends AbstractExecutorService implements Configurable, ExecutorService, XnioIoFactory, org.wildfly.common.context.Contextual<XnioWorker>
Modifier and Type | Class and Description |
---|---|
static class |
XnioWorker.Builder
A builder which allows workers to be programmatically configured.
|
EMPTY
Modifier | Constructor and Description |
---|---|
protected |
XnioWorker(XnioWorker.Builder builder)
Construct a new instance.
|
Modifier and Type | Method and Description |
---|---|
IoFuture<ConnectedMessageChannel> |
acceptDatagram(SocketAddress destination,
ChannelListener<? super ConnectedMessageChannel> openListener,
ChannelListener<? super BoundChannel> bindListener,
OptionMap optionMap)
Deprecated.
|
IoFuture<MessageConnection> |
acceptMessageConnection(SocketAddress destination,
ChannelListener<? super MessageConnection> openListener,
ChannelListener<? super BoundChannel> bindListener,
OptionMap optionMap)
Accept a message connection at a destination address.
|
IoFuture<ConnectedStreamChannel> |
acceptStream(SocketAddress destination,
ChannelListener<? super ConnectedStreamChannel> openListener,
ChannelListener<? super BoundChannel> bindListener,
OptionMap optionMap)
Deprecated.
|
IoFuture<StreamConnection> |
acceptStreamConnection(SocketAddress destination,
ChannelListener<? super StreamConnection> openListener,
ChannelListener<? super BoundChannel> bindListener,
OptionMap optionMap)
Accept a stream connection at a destination address.
|
abstract void |
awaitTermination()
Wait for termination.
|
abstract boolean |
awaitTermination(long timeout,
TimeUnit unit)
Wait for termination.
|
protected abstract XnioIoThread |
chooseThread()
Choose a thread randomly from this worker.
|
IoFuture<ConnectedMessageChannel> |
connectDatagram(SocketAddress destination,
ChannelListener<? super ConnectedMessageChannel> openListener,
ChannelListener<? super BoundChannel> bindListener,
OptionMap optionMap)
Deprecated.
|
IoFuture<ConnectedMessageChannel> |
connectDatagram(SocketAddress bindAddress,
SocketAddress destination,
ChannelListener<? super ConnectedMessageChannel> openListener,
ChannelListener<? super BoundChannel> bindListener,
OptionMap optionMap)
Deprecated.
|
IoFuture<ConnectedStreamChannel> |
connectStream(SocketAddress destination,
ChannelListener<? super ConnectedStreamChannel> openListener,
ChannelListener<? super BoundChannel> bindListener,
OptionMap optionMap)
Deprecated.
|
IoFuture<ConnectedStreamChannel> |
connectStream(SocketAddress destination,
ChannelListener<? super ConnectedStreamChannel> openListener,
OptionMap optionMap)
Deprecated.
|
IoFuture<ConnectedStreamChannel> |
connectStream(SocketAddress bindAddress,
SocketAddress destination,
ChannelListener<? super ConnectedStreamChannel> openListener,
ChannelListener<? super BoundChannel> bindListener,
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.
|
void |
createOneWayPipe(ChannelListener<? super StreamSourceChannel> sourceListener,
ChannelListener<? super StreamSinkChannel> sinkListener,
OptionMap optionMap)
Deprecated.
Users should prefer the simpler
createHalfDuplexPipe() instead. |
void |
createPipe(ChannelListener<? super StreamChannel> leftOpenListener,
ChannelListener<? super StreamChannel> rightOpenListener,
OptionMap optionMap)
Deprecated.
Users should prefer the simpler
createFullDuplexPipe() instead. |
AcceptingChannel<StreamConnection> |
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.
|
MulticastMessageChannel |
createUdpServer(InetSocketAddress bindAddress,
ChannelListener<? super MulticastMessageChannel> bindListener,
OptionMap optionMap)
Create a UDP server.
|
MulticastMessageChannel |
createUdpServer(InetSocketAddress bindAddress,
OptionMap optionMap)
Create a UDP server.
|
void |
execute(Runnable command)
Execute a command in the task pool.
|
protected org.wildfly.common.net.CidrAddressTable<InetSocketAddress> |
getBindAddressTable()
Get the bind address table.
|
protected int |
getBusyWorkerThreadCount()
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 int |
getCoreWorkerPoolSize()
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.
|
StreamSinkChannel |
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.
|
StreamSourceChannel |
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> |
getInstanceContextManager()
Get the instance context manager for XNIO workers by delegating to
getContextManager() . |
XnioIoThread |
getIoThread()
Get an I/O thread from this worker.
|
abstract XnioIoThread |
getIoThread(int hashCode)
Get an I/O thread from this worker.
|
abstract int |
getIoThreadCount()
Get the number of I/O threads configured on this worker.
|
protected int |
getMaxWorkerPoolSize()
Get the maximum worker pool size.
|
abstract XnioWorkerMXBean |
getMXBean() |
String |
getName()
Get the name of this worker.
|
<T> T |
getOption(Option<T> option)
Get the value of a channel option.
|
protected Runnable |
getTerminationTask()
Get the user task to run once termination is complete.
|
protected int |
getWorkerQueueSize()
Get an estimate of the number of tasks in the worker queue.
|
Xnio |
getXnio()
Get the XNIO provider which produced this worker.
|
abstract boolean |
isShutdown()
Determine whether the worker has been shut down.
|
abstract boolean |
isTerminated()
Determine whether the worker has terminated.
|
IoFuture<MessageConnection> |
openMessageConnection(SocketAddress destination,
ChannelListener<? super MessageConnection> openListener,
OptionMap optionMap)
Connect to a remote message server.
|
IoFuture<StreamConnection> |
openStreamConnection(SocketAddress destination,
ChannelListener<? super StreamConnection> openListener,
ChannelListener<? super BoundChannel> bindListener,
OptionMap optionMap)
Connect to a remote stream server.
|
IoFuture<StreamConnection> |
openStreamConnection(SocketAddress destination,
ChannelListener<? super StreamConnection> openListener,
OptionMap optionMap)
Connect to a remote stream server.
|
IoFuture<StreamConnection> |
openStreamConnection(SocketAddress bindAddress,
SocketAddress destination,
ChannelListener<? super StreamConnection> openListener,
ChannelListener<? super BoundChannel> bindListener,
OptionMap optionMap)
Connect to a remote stream server.
|
protected abstract ManagementRegistration |
registerServerMXBean(XnioServerMXBean metrics) |
<T> T |
setOption(Option<T> option,
T value)
Set an option for this channel.
|
abstract void |
shutdown()
Shut down this worker.
|
abstract List<Runnable> |
shutdownNow()
Immediately terminate the worker.
|
protected void |
shutDownTaskPool()
Initiate shutdown of the task thread pool.
|
protected List<Runnable> |
shutDownTaskPoolNow()
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 |
taskPoolTerminated()
Callback to indicate that the task thread pool has terminated.
|
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
invokeAll, invokeAll, invokeAny, invokeAny, submit, submit, submit
run, runAction, runBiConsumer, runBiFunction, runBiPredicate, runCallable, runConsumer, runExBiConsumer, runExBiFunction, runExBiPredicate, runExceptionAction, runExConsumer, runExFunction, runExIntFunction, runExLongFunction, runExPredicate, runFunction, runIntFunction, runLongFunction, runPredicate
protected XnioWorker(XnioWorker.Builder builder)
builder
- the worker builderpublic static org.wildfly.common.context.ContextManager<XnioWorker> getContextManager()
null
)public org.wildfly.common.context.ContextManager<XnioWorker> getInstanceContextManager()
getContextManager()
.getInstanceContextManager
in interface org.wildfly.common.context.Contextual<XnioWorker>
null
)@Deprecated public AcceptingChannel<? extends ConnectedStreamChannel> createStreamServer(SocketAddress bindAddress, ChannelListener<? super AcceptingChannel<ConnectedStreamChannel>> acceptListener, OptionMap optionMap) throws IOException
bindAddress
- the address to bind toacceptListener
- the initial accept listeneroptionMap
- the initial configuration for the serverIOException
- if the server could not be createdpublic AcceptingChannel<StreamConnection> createStreamConnectionServer(SocketAddress bindAddress, ChannelListener<? super AcceptingChannel<StreamConnection>> acceptListener, OptionMap optionMap) throws IOException
bindAddress
- the address to bind toacceptListener
- the initial accept listeneroptionMap
- the initial configuration for the serverIOException
- if the server could not be createdprotected AcceptingChannel<StreamConnection> createTcpConnectionServer(InetSocketAddress bindAddress, ChannelListener<? super AcceptingChannel<StreamConnection>> acceptListener, OptionMap optionMap) throws IOException
bindAddress
- the address to bind toacceptListener
- the initial accept listeneroptionMap
- the initial configuration for the serverIOException
- if the server could not be createdprotected AcceptingChannel<StreamConnection> createLocalStreamConnectionServer(LocalSocketAddress bindAddress, ChannelListener<? super AcceptingChannel<StreamConnection>> acceptListener, OptionMap optionMap) throws IOException
bindAddress
- the address to bind toacceptListener
- the initial accept listeneroptionMap
- the initial configuration for the serverIOException
- if the server could not be created@Deprecated public IoFuture<ConnectedStreamChannel> connectStream(SocketAddress destination, ChannelListener<? super ConnectedStreamChannel> openListener, OptionMap optionMap)
destination
- the destination addressopenListener
- the listener which will be notified when the channel is open, or null
for noneoptionMap
- the option map@Deprecated public IoFuture<ConnectedStreamChannel> connectStream(SocketAddress destination, ChannelListener<? super ConnectedStreamChannel> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap)
destination
- the destination addressopenListener
- the listener which will be notified when the channel is open, or null
for nonebindListener
- the listener which will be notified when the channel is bound, or null
for noneoptionMap
- the option map@Deprecated public IoFuture<ConnectedStreamChannel> connectStream(SocketAddress bindAddress, SocketAddress destination, ChannelListener<? super ConnectedStreamChannel> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap)
bindAddress
- the local address to bind todestination
- the destination addressopenListener
- the listener which will be notified when the channel is open, or null
for nonebindListener
- the listener which will be notified when the channel is bound, or null
for noneoptionMap
- the option mappublic IoFuture<StreamConnection> openStreamConnection(SocketAddress destination, ChannelListener<? super StreamConnection> openListener, OptionMap optionMap)
XnioIoFactory
IoFuture
, and vice-versa.openStreamConnection
in interface XnioIoFactory
destination
- the destination addressopenListener
- the listener which will be notified when the channel is open, or null
for noneoptionMap
- the option mappublic IoFuture<StreamConnection> openStreamConnection(SocketAddress destination, ChannelListener<? super StreamConnection> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap)
XnioIoFactory
IoFuture
, and vice-versa.openStreamConnection
in interface XnioIoFactory
destination
- the destination addressopenListener
- the listener which will be notified when the channel is open, or null
for nonebindListener
- the listener which will be notified when the channel is bound, or null
for noneoptionMap
- the option mappublic IoFuture<StreamConnection> openStreamConnection(SocketAddress bindAddress, SocketAddress destination, ChannelListener<? super StreamConnection> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap)
XnioIoFactory
IoFuture
, and vice-versa.openStreamConnection
in interface XnioIoFactory
bindAddress
- the local address to bind todestination
- the destination addressopenListener
- the listener which will be notified when the channel is open, or null
for nonebindListener
- the listener which will be notified when the channel is bound, or null
for noneoptionMap
- the option map@Deprecated public IoFuture<ConnectedStreamChannel> acceptStream(SocketAddress destination, ChannelListener<? super ConnectedStreamChannel> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap)
destination
- the destination (bind) addressopenListener
- the listener which will be notified when the channel is open, or null
for nonebindListener
- the listener which will be notified when the acceptor is bound, or null
for noneoptionMap
- the option mappublic IoFuture<StreamConnection> acceptStreamConnection(SocketAddress destination, ChannelListener<? super StreamConnection> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap)
XnioIoFactory
acceptStreamConnection
in interface XnioIoFactory
destination
- the destination (bind) addressopenListener
- the listener which will be notified when the channel is open, or null
for nonebindListener
- the listener which will be notified when the acceptor is bound, or null
for noneoptionMap
- the option map@Deprecated public IoFuture<ConnectedMessageChannel> connectDatagram(SocketAddress destination, ChannelListener<? super ConnectedMessageChannel> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap)
destination
- the destination addressopenListener
- the listener which will be notified when the channel is open, or null
for nonebindListener
- the listener which will be notified when the channel is bound, or null
for noneoptionMap
- the option map@Deprecated public IoFuture<ConnectedMessageChannel> connectDatagram(SocketAddress bindAddress, SocketAddress destination, ChannelListener<? super ConnectedMessageChannel> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap)
bindAddress
- the local address to bind todestination
- the destination addressopenListener
- the listener which will be notified when the channel is open, or null
for nonebindListener
- the listener which will be notified when the channel is bound, or null
for noneoptionMap
- the option mappublic IoFuture<MessageConnection> openMessageConnection(SocketAddress destination, ChannelListener<? super MessageConnection> openListener, OptionMap optionMap)
XnioIoFactory
IoFuture
, and vice-versa.openMessageConnection
in interface XnioIoFactory
destination
- the destination addressopenListener
- the listener which will be notified when the channel is open, or null
for noneoptionMap
- the option map@Deprecated public IoFuture<ConnectedMessageChannel> acceptDatagram(SocketAddress destination, ChannelListener<? super ConnectedMessageChannel> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap)
destination
- the destination (bind) addressopenListener
- the listener which will be notified when the channel is open, or null
for nonebindListener
- the listener which will be notified when the acceptor is bound, or null
for noneoptionMap
- the option mappublic IoFuture<MessageConnection> acceptMessageConnection(SocketAddress destination, ChannelListener<? super MessageConnection> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap)
XnioIoFactory
IoFuture
, and vice-versa.acceptMessageConnection
in interface XnioIoFactory
destination
- the destination (bind) addressopenListener
- the listener which will be notified when the channel is open, or null
for nonebindListener
- the listener which will be notified when the acceptor is bound, or null
for noneoptionMap
- the option mappublic MulticastMessageChannel createUdpServer(InetSocketAddress bindAddress, ChannelListener<? super MulticastMessageChannel> bindListener, OptionMap optionMap) throws IOException
bindAddress
- the bind addressbindListener
- the initial open-connection listeneroptionMap
- the initial configuration for the serverIOException
- if the server could not be createdpublic MulticastMessageChannel createUdpServer(InetSocketAddress bindAddress, OptionMap optionMap) throws IOException
bindAddress
- the bind addressoptionMap
- the initial configuration for the serverIOException
- if the server could not be created@Deprecated public void createPipe(ChannelListener<? super StreamChannel> leftOpenListener, ChannelListener<? super StreamChannel> rightOpenListener, OptionMap optionMap) throws IOException
createFullDuplexPipe()
instead.leftOpenListener
- the left-hand open listenerrightOpenListener
- the right-hand open listeneroptionMap
- the pipe channel configurationIOException
- if the pipe could not be created@Deprecated public void createOneWayPipe(ChannelListener<? super StreamSourceChannel> sourceListener, ChannelListener<? super StreamSinkChannel> sinkListener, OptionMap optionMap) throws IOException
createHalfDuplexPipe()
instead.sourceListener
- the source open listenersinkListener
- the sink open listeneroptionMap
- the pipe channel configurationIOException
- if the pipe could not be createdpublic StreamSourceChannel getInflatingChannel(StreamSourceChannel delegate, OptionMap options) throws IOException
delegate
- the compressed channeloptions
- the configuration options for the channelIOException
- if the channel could not be constructedprotected StreamSourceChannel getInflatingChannel(StreamSourceChannel delegate, Inflater inflater) throws IOException
delegate
- the compressed channelinflater
- the inflater to useIOException
- if the channel could not be constructedpublic StreamSinkChannel getDeflatingChannel(StreamSinkChannel delegate, OptionMap options) throws IOException
delegate
- the channel to compress tooptions
- the configuration options for the channelIOException
- if the channel could not be constructedprotected StreamSinkChannel getDeflatingChannel(StreamSinkChannel delegate, Deflater deflater) throws IOException
delegate
- the channel to compress todeflater
- the deflater to useIOException
- if the channel could not be constructedpublic ChannelPipe<StreamChannel,StreamChannel> createFullDuplexPipe() throws IOException
XnioIoFactory
createFullDuplexPipe
in interface XnioIoFactory
IOException
- if the pipe could not be createdpublic ChannelPipe<StreamConnection,StreamConnection> createFullDuplexPipeConnection() throws IOException
XnioIoFactory
createFullDuplexPipeConnection
in interface XnioIoFactory
IOException
- if the pipe could not be createdpublic ChannelPipe<StreamSourceChannel,StreamSinkChannel> createHalfDuplexPipe() throws IOException
XnioIoFactory
createHalfDuplexPipe
in interface XnioIoFactory
IOException
- if the pipe could not be createdpublic ChannelPipe<StreamConnection,StreamConnection> createFullDuplexPipeConnection(XnioIoFactory peer) throws IOException
XnioIoFactory
createFullDuplexPipeConnection
in interface XnioIoFactory
peer
- the peer to use for controlling the remote (right) sideIOException
- if the pipe could not be createdpublic ChannelPipe<StreamSourceChannel,StreamSinkChannel> createHalfDuplexPipe(XnioIoFactory peer) throws IOException
XnioIoFactory
createHalfDuplexPipe
in interface XnioIoFactory
peer
- the peer to use for the sink (right) sideIOException
- if the pipe could not be createdpublic abstract void shutdown()
shutdown
in interface ExecutorService
public abstract List<Runnable> shutdownNow()
shutdownNow
in interface ExecutorService
public abstract boolean isShutdown()
true
once either shutdown method has
been called.isShutdown
in interface ExecutorService
true
the worker has been shut downpublic abstract boolean isTerminated()
true
once all worker threads are exited
(with the possible exception of the thread running the termination task, if any).isTerminated
in interface ExecutorService
true
if the worker is terminatedpublic abstract boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException
awaitTermination
in interface ExecutorService
timeout
- the amount of time to waitunit
- the unit of timetrue
if termination completed before the timeout expiredInterruptedException
- if the operation was interruptedpublic abstract void awaitTermination() throws InterruptedException
InterruptedException
- if the operation was interruptedpublic final XnioIoThread getIoThread()
public abstract XnioIoThread getIoThread(int hashCode)
hashCode
- the hash codeprotected Runnable getTerminationTask()
protected void taskPoolTerminated()
protected void shutDownTaskPool()
taskPoolTerminated()
method is called.protected List<Runnable> shutDownTaskPoolNow()
public void execute(Runnable command)
public abstract int getIoThreadCount()
public boolean supportsOption(Option<?> option)
Configurable
supportsOption
in interface Configurable
option
- the optiontrue
if it is supportedpublic <T> T getOption(Option<T> option) throws IOException
Configurable
getOption
in interface Configurable
T
- the type of the option valueoption
- the option to getnull
if it is not setIOException
- if an I/O error occurred when reading the optionpublic <T> T setOption(Option<T> option, T value) throws IllegalArgumentException, IOException
Configurable
setOption
in interface Configurable
T
- the type of the option valueoption
- the option to setvalue
- the value of the option to setIllegalArgumentException
- if the value is not acceptable for this optionIOException
- if an I/O error occurred when modifying the optionpublic Xnio getXnio()
public String getName()
protected abstract XnioIoThread chooseThread()
protected final int getCoreWorkerPoolSize()
protected final int getBusyWorkerThreadCount()
protected final int getMaxWorkerPoolSize()
protected final int getWorkerQueueSize()
protected org.wildfly.common.net.CidrAddressTable<InetSocketAddress> getBindAddressTable()
public abstract XnioWorkerMXBean getMXBean()
protected abstract ManagementRegistration registerServerMXBean(XnioServerMXBean metrics)
Copyright © 2017 JBoss by Red Hat. All rights reserved.