public abstract class XnioWorker extends AbstractExecutorService implements Configurable, ExecutorService
Modifier | Constructor and Description |
---|---|
protected |
XnioWorker(Xnio xnio,
ThreadGroup threadGroup,
OptionMap optionMap,
Runnable terminationTask)
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)
Accept a message connection at a destination address.
|
protected IoFuture<ConnectedMessageChannel> |
acceptLocalDatagram(LocalSocketAddress destination,
ChannelListener<? super ConnectedMessageChannel> openListener,
ChannelListener<? super BoundChannel> bindListener,
OptionMap optionMap)
Implementation helper method to accept a local (UNIX domain) datagram connection.
|
protected IoFuture<ConnectedStreamChannel> |
acceptLocalStream(LocalSocketAddress destination,
ChannelListener<? super ConnectedStreamChannel> openListener,
ChannelListener<? super BoundChannel> bindListener,
OptionMap optionMap)
Implementation helper method to accept a local (UNIX domain) stream connection.
|
IoFuture<ConnectedStreamChannel> |
acceptStream(SocketAddress destination,
ChannelListener<? super ConnectedStreamChannel> openListener,
ChannelListener<? super BoundChannel> bindListener,
OptionMap optionMap)
Accept a stream connection at a destination address.
|
protected IoFuture<ConnectedStreamChannel> |
acceptTcpStream(InetSocketAddress destination,
ChannelListener<? super ConnectedStreamChannel> openListener,
ChannelListener<? super BoundChannel> bindListener,
OptionMap optionMap)
Implementation helper method to accept a TCP connection.
|
abstract boolean |
awaitTermination(long timeout,
TimeUnit unit) |
IoFuture<ConnectedMessageChannel> |
connectDatagram(SocketAddress destination,
ChannelListener<? super ConnectedMessageChannel> openListener,
ChannelListener<? super BoundChannel> bindListener,
OptionMap optionMap)
Connect to a remote stream server.
|
IoFuture<ConnectedMessageChannel> |
connectDatagram(SocketAddress bindAddress,
SocketAddress destination,
ChannelListener<? super ConnectedMessageChannel> openListener,
ChannelListener<? super BoundChannel> bindListener,
OptionMap optionMap)
Connect to a remote datagram server.
|
protected IoFuture<ConnectedMessageChannel> |
connectLocalDatagram(LocalSocketAddress bindAddress,
LocalSocketAddress destination,
ChannelListener<? super ConnectedMessageChannel> openListener,
ChannelListener<? super BoundChannel> bindListener,
OptionMap optionMap)
Implementation helper method to connect to a local (UNIX domain) datagram server.
|
protected IoFuture<ConnectedStreamChannel> |
connectLocalStream(LocalSocketAddress bindAddress,
LocalSocketAddress destinationAddress,
ChannelListener<? super ConnectedStreamChannel> openListener,
ChannelListener<? super BoundChannel> bindListener,
OptionMap optionMap)
Implementation helper method to connect to a local (UNIX domain) server.
|
IoFuture<ConnectedStreamChannel> |
connectStream(SocketAddress destination,
ChannelListener<? super ConnectedStreamChannel> openListener,
ChannelListener<? super BoundChannel> bindListener,
OptionMap optionMap)
Connect to a remote stream server.
|
IoFuture<ConnectedStreamChannel> |
connectStream(SocketAddress destination,
ChannelListener<? super ConnectedStreamChannel> openListener,
OptionMap optionMap)
Connect to a remote stream server.
|
IoFuture<ConnectedStreamChannel> |
connectStream(SocketAddress bindAddress,
SocketAddress destination,
ChannelListener<? super ConnectedStreamChannel> openListener,
ChannelListener<? super BoundChannel> bindListener,
OptionMap optionMap)
Connect to a remote stream server.
|
protected IoFuture<ConnectedStreamChannel> |
connectTcpStream(InetSocketAddress bindAddress,
InetSocketAddress destinationAddress,
ChannelListener<? super ConnectedStreamChannel> openListener,
ChannelListener<? super BoundChannel> bindListener,
OptionMap optionMap)
Implementation helper method to connect to a TCP server.
|
protected IoFuture<ConnectedMessageChannel> |
connectUdpDatagram(InetSocketAddress bindAddress,
InetSocketAddress destination,
ChannelListener<? super ConnectedMessageChannel> openListener,
ChannelListener<? super BoundChannel> bindListener,
OptionMap optionMap)
Implementation helper method to connect to a UDP server.
|
protected AcceptingChannel<? extends ConnectedStreamChannel> |
createLocalStreamServer(LocalSocketAddress bindAddress,
ChannelListener<? super AcceptingChannel<ConnectedStreamChannel>> 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)
Open a unidirectional stream pipe.
|
void |
createPipe(ChannelListener<? super StreamChannel> leftOpenListener,
ChannelListener<? super StreamChannel> rightOpenListener,
OptionMap optionMap)
Open a bidirectional stream pipe.
|
AcceptingChannel<? extends ConnectedStreamChannel> |
createStreamServer(SocketAddress bindAddress,
ChannelListener<? super AcceptingChannel<ConnectedStreamChannel>> acceptListener,
OptionMap optionMap)
Create a stream server, for TCP or UNIX domain servers.
|
protected AcceptingChannel<? extends ConnectedStreamChannel> |
createTcpServer(InetSocketAddress bindAddress,
ChannelListener<? super AcceptingChannel<ConnectedStreamChannel>> 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.
|
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.
|
Xnio |
getXnio()
Get the XNIO provider which produced this worker.
|
abstract boolean |
isShutdown() |
abstract boolean |
isTerminated() |
<T> T |
setOption(Option<T> option,
T value)
Set an option for this channel.
|
abstract void |
shutdown() |
abstract List<Runnable> |
shutdownNow() |
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
protected XnioWorker(Xnio xnio, ThreadGroup threadGroup, OptionMap optionMap, Runnable terminationTask)
Xnio.createWorker(OptionMap)
method.xnio
- the XNIO provider which produced this worker instancethreadGroup
- the thread group for worker threadsoptionMap
- the option map to use to configure this workerterminationTask
- 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 createdprotected AcceptingChannel<? extends ConnectedStreamChannel> createTcpServer(InetSocketAddress 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 createdprotected AcceptingChannel<? extends ConnectedStreamChannel> createLocalStreamServer(LocalSocketAddress 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 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 mappublic 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 mappublic 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 mapprotected IoFuture<ConnectedStreamChannel> connectTcpStream(InetSocketAddress bindAddress, InetSocketAddress destinationAddress, ChannelListener<? super ConnectedStreamChannel> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap)
bindAddress
- the bind addressdestinationAddress
- 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 @return the future result of this operationprotected IoFuture<ConnectedStreamChannel> connectLocalStream(LocalSocketAddress bindAddress, LocalSocketAddress destinationAddress, ChannelListener<? super ConnectedStreamChannel> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap)
bindAddress
- the bind addressdestinationAddress
- 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<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 mapprotected IoFuture<ConnectedStreamChannel> acceptLocalStream(LocalSocketAddress 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 mapprotected IoFuture<ConnectedStreamChannel> acceptTcpStream(InetSocketAddress 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<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 mappublic 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 mapprotected IoFuture<ConnectedMessageChannel> connectUdpDatagram(InetSocketAddress bindAddress, InetSocketAddress destination, ChannelListener<? super ConnectedMessageChannel> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap)
bindAddress
- the bind addressdestination
- 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 mapprotected IoFuture<ConnectedMessageChannel> connectLocalDatagram(LocalSocketAddress bindAddress, LocalSocketAddress destination, ChannelListener<? super ConnectedMessageChannel> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap)
bindAddress
- the bind addressdestination
- 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<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 mapprotected IoFuture<ConnectedMessageChannel> acceptLocalDatagram(LocalSocketAddress 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 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 createdpublic void createPipe(ChannelListener<? super StreamChannel> leftOpenListener, ChannelListener<? super StreamChannel> rightOpenListener, OptionMap optionMap) throws IOException
leftOpenListener
- the left-hand open listenerrightOpenListener
- the right-hand open listeneroptionMap
- the pipe channel configurationIOException
- if the pipe could not be createdpublic void createOneWayPipe(ChannelListener<? super StreamSourceChannel> sourceListener, ChannelListener<? super StreamSinkChannel> sinkListener, OptionMap optionMap) throws IOException
sourceListener
- the source open listenersinkListener
- the sink open listeneroptionMap
- the pipe channel configurationIOException
- 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()
isShutdown
in interface ExecutorService
public abstract boolean isTerminated()
isTerminated
in interface ExecutorService
public abstract boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException
awaitTermination
in interface ExecutorService
InterruptedException
protected Runnable getTerminationTask()
protected void taskPoolTerminated()
protected void shutDownTaskPool()
taskPoolTerminated()
method is called.protected List<Runnable> shutDownTaskPoolNow()
public void execute(Runnable command)
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()
Copyright © 2012 JBoss by Red Hat. All Rights Reserved.