Top Description Inners Fields Constructors Methods
org.xnio

public abstract Class XnioWorker

extends AbstractExecutorService
implements Configurable, ExecutorService, XnioIoFactory, Contextual<XnioWorker>
Class Inheritance
All Implemented Interfaces
org.wildfly.common.context.Contextual, org.xnio.XnioIoFactory, java.util.concurrent.ExecutorService, java.lang.AutoCloseable, java.util.concurrent.Executor, org.xnio.channels.Configurable
Annotations
@SuppressWarnings:unused
Imports
java.io.IOException, java.net.InetAddress, .InetSocketAddress, .SocketAddress, java.security.PrivilegedAction, java.util.Collections, .List, .Set, java.util.concurrent.AbstractExecutorService, .BlockingQueue, .ExecutorService, .LinkedBlockingDeque, .ThreadFactory, .ThreadPoolExecutor, .TimeUnit, java.util.concurrent.atomic.AtomicInteger, .AtomicIntegerFieldUpdater, java.util.zip.Deflater, .Inflater, org.jboss.threads.EnhancedQueueExecutor, org.wildfly.common.Assert, org.wildfly.common.context.ContextManager, .Contextual, org.wildfly.common.net.CidrAddress, .CidrAddressTable, org.xnio._private.Messages, org.xnio.channels.AcceptingChannel, .AssembledConnectedMessageChannel, .AssembledConnectedStreamChannel, .BoundChannel, .Configurable, .ConnectedMessageChannel, .ConnectedStreamChannel, .MulticastMessageChannel, .StreamChannel, .StreamSinkChannel, .StreamSourceChannel, org.xnio.conduits.ConduitStreamSinkChannel, .ConduitStreamSourceChannel, .DeflatingStreamSinkConduit, .InflatingStreamSourceConduit, .StreamSinkChannelWrappingConduit, .StreamSourceChannelWrappingConduit, org.xnio.management.XnioServerMXBean, .XnioWorkerMXBean, org.jboss.logging.Logger

A worker for I/O channel notification.
Author
David M. Lloyd
Since
3.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
XnioWorker.Builder

A builder which allows workers to be programmatically configured.

pack-priv static class
pack-priv static class
pack-priv static class
pack-priv static class
pack-priv static class
pack-priv static class
pack-priv static interface
pack-priv static class
pack-priv class

Field Summary

Modifier and TypeField and Description
private final CidrAddressTable<InetSocketAddress>
private static final ContextManager<XnioWorker>
private static final RuntimePermission
private static final Set<Option<?>>
private static final Logger
private static final IoFuture.HandlingNotifier<MessageConnection, FutureResult<ConnectedMessageChannel>>
private final String
private static final Set<Option<?>>
private static final AtomicInteger
private static final IoFuture.HandlingNotifier<StreamConnection, FutureResult<ConnectedStreamChannel>>
private final XnioWorker.TaskPool
private volatile int
private static final AtomicIntegerFieldUpdater<XnioWorker>
private final Runnable
private final Xnio

Constructor Summary

AccessConstructor and Description
protected
XnioWorker(final XnioWorker.Builder
the worker builder
builder
)

Construct a new instance.

Method Summary

Modifier and TypeMethod and Description
public IoFuture<ConnectedMessageChannel>

Returns:

the future connection
acceptDatagram
(SocketAddress
the destination (bind) address
destination
,
ChannelListener<? super ConnectedMessageChannel>
the listener which will be notified when the channel is open, or null for none
openListener
,
ChannelListener<? super BoundChannel>
the listener which will be notified when the acceptor is bound, or null for none
bindListener
,
OptionMap
the option map
optionMap
)
Deprecated

Accept a message connection at a destination address.

public IoFuture<MessageConnection>
acceptMessageConnection(final SocketAddress
the destination (bind) address
destination
,
final ChannelListener<? super MessageConnection>
the listener which will be notified when the channel is open, or null for none
openListener
,
final ChannelListener<? super BoundChannel>
the listener which will be notified when the acceptor is bound, or null for none
bindListener
,
final OptionMap
the option map
optionMap
)

Implements org.xnio.XnioIoFactory.acceptMessageConnection.

Accept a message connection at a destination address.

public IoFuture<ConnectedStreamChannel>

Returns:

the future connection
acceptStream
(SocketAddress
the destination (bind) address
destination
,
ChannelListener<? super ConnectedStreamChannel>
the listener which will be notified when the channel is open, or null for none
openListener
,
ChannelListener<? super BoundChannel>
the listener which will be notified when the acceptor is bound, or null for none
bindListener
,
OptionMap
the option map
optionMap
)
Deprecated

Accept a stream connection at a destination address.

public IoFuture<StreamConnection>
acceptStreamConnection(SocketAddress
the destination (bind) address
destination
,
ChannelListener<? super StreamConnection>
the listener which will be notified when the channel is open, or null for none
openListener
,
ChannelListener<? super BoundChannel>
the listener which will be notified when the acceptor is bound, or null for none
bindListener
,
OptionMap
the option map
optionMap
)

Implements org.xnio.XnioIoFactory.acceptStreamConnection.

Accept a stream connection at a destination address.

public abstract boolean

Returns:

true if termination completed before the timeout expired
awaitTermination
(final long
the amount of time to wait
timeout
,
final TimeUnit
the unit of time
unit
)

Redeclares java.util.concurrent.ExecutorService.awaitTermination.

Wait for termination.

public abstract void
awaitTermination()

Wait for termination.

protected abstract XnioIoThread

Returns:

the thread
chooseThread
()

Choose a thread randomly from this worker.

public IoFuture<ConnectedMessageChannel>

Returns:

the future result of this operation
connectDatagram
(SocketAddress
the destination address
destination
,
ChannelListener<? super ConnectedMessageChannel>
the listener which will be notified when the channel is open, or null for none
openListener
,
ChannelListener<? super BoundChannel>
the listener which will be notified when the channel is bound, or null for none
bindListener
,
OptionMap
the option map
optionMap
)
Deprecated

Connect to a remote datagram server.

public IoFuture<ConnectedMessageChannel>

Returns:

the future result of this operation
connectDatagram
(SocketAddress
the local address to bind to
bindAddress
,
SocketAddress
the destination address
destination
,
ChannelListener<? super ConnectedMessageChannel>
the listener which will be notified when the channel is open, or null for none
openListener
,
ChannelListener<? super BoundChannel>
the listener which will be notified when the channel is bound, or null for none
bindListener
,
OptionMap
the option map
optionMap
)
Deprecated

Connect to a remote datagram server.

public IoFuture<ConnectedStreamChannel>

Returns:

the future result of this operation
connectStream
(SocketAddress
the destination address
destination
,
ChannelListener<? super ConnectedStreamChannel>
the listener which will be notified when the channel is open, or null for none
openListener
,
OptionMap
the option map
optionMap
)
Deprecated

Connect to a remote stream server.

public IoFuture<ConnectedStreamChannel>

Returns:

the future result of this operation
connectStream
(SocketAddress
the destination address
destination
,
ChannelListener<? super ConnectedStreamChannel>
the listener which will be notified when the channel is open, or null for none
openListener
,
ChannelListener<? super BoundChannel>
the listener which will be notified when the channel is bound, or null for none
bindListener
,
OptionMap
the option map
optionMap
)
Deprecated

Connect to a remote stream server.

public IoFuture<ConnectedStreamChannel>

Returns:

the future result of this operation
connectStream
(SocketAddress
the local address to bind to
bindAddress
,
SocketAddress
the destination address
destination
,
ChannelListener<? super ConnectedStreamChannel>
the listener which will be notified when the channel is open, or null for none
openListener
,
ChannelListener<? super BoundChannel>
the listener which will be notified when the channel is bound, or null for none
bindListener
,
OptionMap
the option map
optionMap
)
Deprecated

Connect to a remote stream server.

public ChannelPipe<StreamChannel, StreamChannel>
createFullDuplexPipe()

Implements org.xnio.XnioIoFactory.createFullDuplexPipe.

Create a two-way stream pipe.

public ChannelPipe<StreamConnection, StreamConnection>
public ChannelPipe<StreamConnection, StreamConnection>
createFullDuplexPipeConnection(final XnioIoFactory
the peer to use for controlling the remote (right) side
peer
)

Implements org.xnio.XnioIoFactory.createFullDuplexPipeConnection.

Create a two-way stream pipe.

public ChannelPipe<StreamSourceChannel, StreamSinkChannel>
createHalfDuplexPipe()

Implements org.xnio.XnioIoFactory.createHalfDuplexPipe.

Create a one-way stream pipe.

public ChannelPipe<StreamSourceChannel, StreamSinkChannel>
createHalfDuplexPipe(final XnioIoFactory
the peer to use for the sink (right) side
peer
)

Implements org.xnio.XnioIoFactory.createHalfDuplexPipe.

Create a one-way stream pipe.

protected AcceptingChannel<StreamConnection>

Returns:

the acceptor
createLocalStreamConnectionServer
(LocalSocketAddress
the address to bind to
bindAddress
,
ChannelListener<? super AcceptingChannel<StreamConnection>>
the initial accept listener
acceptListener
,
OptionMap
the initial configuration for the server
optionMap
)

Implementation helper method to create a UNIX domain stream server.

public void
createOneWayPipe(ChannelListener<? super StreamSourceChannel>
the source open listener
sourceListener
,
ChannelListener<? super StreamSinkChannel>
the sink open listener
sinkListener
,
final OptionMap
the pipe channel configuration
optionMap
)
Deprecated Users should prefer the simpler createHalfDuplexPipe() instead.

Open a unidirectional stream pipe.

public void
createPipe(ChannelListener<? super StreamChannel>
the left-hand open listener
leftOpenListener
,
ChannelListener<? super StreamChannel>
the right-hand open listener
rightOpenListener
,
final OptionMap
the pipe channel configuration
optionMap
)
Deprecated Users should prefer the simpler createFullDuplexPipe() instead.

Open a bidirectional stream pipe.

public AcceptingChannel<StreamConnection>

Returns:

the acceptor
createStreamConnectionServer
(SocketAddress
the address to bind to
bindAddress
,
ChannelListener<? super AcceptingChannel<StreamConnection>>
the initial accept listener
acceptListener
,
OptionMap
the initial configuration for the server
optionMap
)

Create a stream server, for TCP or UNIX domain servers.

public AcceptingChannel<? extends ConnectedStreamChannel>

Returns:

the acceptor
createStreamServer
(SocketAddress
the address to bind to
bindAddress
,
ChannelListener<? super AcceptingChannel<ConnectedStreamChannel>>
the initial accept listener
acceptListener
,
OptionMap
the initial configuration for the server
optionMap
)
Deprecated

Create a stream server, for TCP or UNIX domain servers.

protected AcceptingChannel<StreamConnection>

Returns:

the acceptor
createTcpConnectionServer
(InetSocketAddress
the address to bind to
bindAddress
,
ChannelListener<? super AcceptingChannel<StreamConnection>>
the initial accept listener
acceptListener
,
OptionMap
the initial configuration for the server
optionMap
)

Implementation helper method to create a TCP stream server.

public MulticastMessageChannel

Returns:

the UDP server channel
createUdpServer
(InetSocketAddress
the bind address
bindAddress
,
ChannelListener<? super MulticastMessageChannel>
the initial open-connection listener
bindListener
,
OptionMap
the initial configuration for the server
optionMap
)

Create a UDP server.

public MulticastMessageChannel

Returns:

the UDP server channel
createUdpServer
(InetSocketAddress
the bind address
bindAddress
,
OptionMap
the initial configuration for the server
optionMap
)

Create a UDP server.

public void
execute(final Runnable
the command to run
command
)

Implements java.util.concurrent.Executor.execute.

Execute a command in the task pool.

public InetSocketAddress

Returns:

the expected bind address for the given destination, or null if no explicit bind will be done
getBindAddress
(InetAddress destination)

Get the expected bind address for the given destination, if any.

protected CidrAddressTable<InetSocketAddress>

Returns:

the bind address table
getBindAddressTable
()

Get the bind address table.

protected final int

Returns:

the estimated number of busy threads in the worker pool
getBusyWorkerThreadCount
()

Get an estimate of the number of busy threads in the worker pool.

public static ContextManager<XnioWorker>

Returns:

the context manager (not null)
getContextManager
()

Get the context manager for XNIO workers.

protected final int

Returns:

the core worker pool size
getCoreWorkerPoolSize
()

Get the core worker pool size.

public StreamSinkChannel

Returns:

a compressed channel
getDeflatingChannel
(final StreamSinkChannel
the channel to compress to
delegate
,
final OptionMap
the configuration options for the channel
options
)

Create a stream channel that compresses to the destination according to the configuration in the given option map.

protected StreamSinkChannel

Returns:

a compressed channel
getDeflatingChannel
(final StreamSinkChannel
the channel to compress to
delegate
,
final Deflater
the deflater to use
deflater
)

Create a stream channel that compresses to the destination according to the configuration in the given inflater.

public StreamSourceChannel

Returns:

a decompressed channel
getInflatingChannel
(final StreamSourceChannel
the compressed channel
delegate
,
OptionMap
the configuration options for the channel
options
)

Create a stream channel that decompresses the source data according to the configuration in the given option map.

protected StreamSourceChannel

Returns:

a decompressed channel
getInflatingChannel
(final StreamSourceChannel
the compressed channel
delegate
,
final Inflater
the inflater to use
inflater
)

Create a stream channel that decompresses the source data according to the configuration in the given inflater.

public ContextManager<XnioWorker>

Returns:

the context manager (not null)
getInstanceContextManager
()

Implements org.wildfly.common.context.Contextual.getInstanceContextManager.

Get the instance context manager for XNIO workers by delegating to getContextManager().

public final XnioIoThread

Returns:

the I/O thread
getIoThread
()

Get an I/O thread from this worker.

public abstract XnioIoThread

Returns:

the thread
getIoThread
(int
the hash code
hashCode
)

Get an I/O thread from this worker.

public abstract int

Returns:

the number of I/O threads configured on this worker
getIoThreadCount
()

Get the number of I/O threads configured on this worker.

protected final int

Returns:

the maximum worker pool size
getMaxWorkerPoolSize
()

Get the maximum worker pool size.

public abstract XnioWorkerMXBean
public String

Returns:

the name of the worker
getName
()

Get the name of this worker.

private int
public <T> T
getOption(final Option<T>
the option to get
option
)

Implements org.xnio.channels.Configurable.getOption.

Get the value of a channel option.

protected Runnable

Returns:

the termination task
getTerminationTask
()

Get the user task to run once termination is complete.

protected final int

Returns:

the estimated number of threads in the worker pool
getWorkerPoolSize
()

Get an estimate of the number of threads in the worker pool.

protected final int

Returns:

the estimated number of tasks
getWorkerQueueSize
()

Get an estimate of the number of tasks in the worker queue.

public Xnio

Returns:

the XNIO provider
getXnio
()

Get the XNIO provider which produced this worker.

public abstract boolean

Returns:

true the worker has been shut down
isShutdown
()

Redeclares java.util.concurrent.ExecutorService.isShutdown.

Determine whether the worker has been shut down.

protected boolean

Returns:

true if the task pool is externally managed, false otherwise
isTaskPoolExternal
()

Determine whether the worker task pool is managed externally.

public abstract boolean

Returns:

true if the worker is terminated
isTerminated
()

Redeclares java.util.concurrent.ExecutorService.isTerminated.

Determine whether the worker has terminated.

public IoFuture<MessageConnection>
openMessageConnection(final SocketAddress
the destination address
destination
,
final ChannelListener<? super MessageConnection>
the listener which will be notified when the channel is open, or null for none
openListener
,
final OptionMap
the option map
optionMap
)

Implements org.xnio.XnioIoFactory.openMessageConnection.

Connect to a remote message server.

public IoFuture<StreamConnection>
openStreamConnection(SocketAddress
the destination address
destination
,
ChannelListener<? super StreamConnection>
the listener which will be notified when the channel is open, or null for none
openListener
,
OptionMap
the option map
optionMap
)

Implements org.xnio.XnioIoFactory.openStreamConnection.

Connect to a remote stream server.

public IoFuture<StreamConnection>
openStreamConnection(SocketAddress
the destination address
destination
,
ChannelListener<? super StreamConnection>
the listener which will be notified when the channel is open, or null for none
openListener
,
ChannelListener<? super BoundChannel>
the listener which will be notified when the channel is bound, or null for none
bindListener
,
OptionMap
the option map
optionMap
)

Implements org.xnio.XnioIoFactory.openStreamConnection.

Connect to a remote stream server.

public IoFuture<StreamConnection>
openStreamConnection(SocketAddress
the local address to bind to
bindAddress
,
SocketAddress
the destination address
destination
,
ChannelListener<? super StreamConnection>
the listener which will be notified when the channel is open, or null for none
openListener
,
ChannelListener<? super BoundChannel>
the listener which will be notified when the channel is bound, or null for none
bindListener
,
OptionMap
the option map
optionMap
)

Implements org.xnio.XnioIoFactory.openStreamConnection.

Connect to a remote stream server.

protected abstract ManagementRegistration
public <T> T
setOption(final Option<T>
the option to set
option
,
final T
the value of the option to set
value
)

Implements org.xnio.channels.Configurable.setOption.

Set an option for this channel.

public abstract void
shutdown()

Redeclares java.util.concurrent.ExecutorService.shutdown.

Shut down this worker.

public abstract List<Runnable>

Returns:

the list of outstanding tasks
shutdownNow
()

Redeclares java.util.concurrent.ExecutorService.shutdownNow.

Immediately terminate the worker.

protected void
shutDownTaskPool()

Initiate shutdown of the task thread pool.

protected List<Runnable>

Returns:

the pending task list
shutDownTaskPoolNow
()

Shut down the task thread pool immediately and return its pending tasks.

public boolean
supportsOption(final Option<?>
the option
option
)

Implements org.xnio.channels.Configurable.supportsOption.

Determine whether an option is supported on this channel.

protected void
taskPoolTerminated()

Callback to indicate that the task thread pool has terminated.

Inherited from java.util.concurrent.AbstractExecutorService:
invokeAllinvokeAllinvokeAnyinvokeAnynewTaskFornewTaskForsubmitsubmitsubmit