|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.sgs.nio.channels.AsynchronousChannelGroup
com.sun.sgs.impl.nio.AsyncGroupImpl
com.sun.sgs.impl.nio.ReactiveChannelGroup
class ReactiveChannelGroup
A select-based AsynchronousChannelGroup.
This class is a container for a set of Reactors which do the
actual work of registering and dispatching asynchronous operations on
channels. It provides:
Reactor set,
supporting graceful and
immediate shutdown,
and awaiting
termination.
Reactors: channels are assigned to one of the reactors in
the set. Since reactors are single-threaded, the reactor set allows
multiple CPUs to be utilized by having multiple separate reactors.
Reactors is set as the number of
available processors, but it
can be changed by setting the requested number in the system property
"com.sun.sgs.nio.async.reactive.reactors".
| Nested Class Summary | |
|---|---|
(package private) class |
ReactiveChannelGroup.HashingReactorAssignmentStrategy
A Reactor load balancing strategy that chooses a reactor
based on the hash of the channel. |
(package private) static interface |
ReactiveChannelGroup.ReactorAssignmentStrategy
Interface for Reactor load balancing strategies. |
(package private) class |
ReactiveChannelGroup.Worker
Worker to run a reactor and check termination when a reactor completes. |
| Field Summary | |
|---|---|
static int |
DEFAULT_REACTORS
The default number of reactors to be used by channel groups: Runtime.getRuntime().availableProcessors() |
protected static int |
DONE
State: terminated |
protected int |
lifecycleState
The lifecycle state of this group. |
(package private) static Logger |
log
The logger for this class. |
(package private) ReactiveChannelGroup.ReactorAssignmentStrategy |
reactorAssignmentStrategy
The reactor load-balance strategy. |
(package private) List<Reactor> |
reactors
The active reactors in this group. |
static String |
REACTORS_PROPERTY
The property to specify the number of reactors to be used by channel groups: "com.sun.sgs.nio.async.reactive.reactors" |
protected static int |
RUNNING
State: open and running |
protected static int |
SHUTDOWN
State: graceful shutdown in progress |
protected static int |
SHUTDOWN_NOW
State: forced shutdown in progress |
(package private) Object |
stateLock
Lock held on updates to lifecycleState and reactors list, and the condition variable for awaiting group termination. |
| Fields inherited from class com.sun.sgs.impl.nio.AsyncGroupImpl |
|---|
executor, uncaughtHandler |
| Constructor Summary | |
|---|---|
ReactiveChannelGroup(ReactiveAsyncChannelProvider provider,
ExecutorService executor)
Creates a new group with the default number of reactors. |
|
ReactiveChannelGroup(ReactiveAsyncChannelProvider provider,
ExecutorService executor,
int requestedReactors)
Creates a new group with the requested number of reactors. |
|
| Method Summary | |
|---|---|
boolean |
awaitTermination(long timeout,
TimeUnit unit)
Awaits termination of the group. |
boolean |
isShutdown()
Tells whether or not this asynchronous channel group is shutdown. |
boolean |
isTerminated()
Tells whether or not this asynchronous channel group is terminated. |
(package private) AsyncKey |
register(SelectableChannel ch)
Registers the given channel with this group, returning an AsyncKey that can be used to invoke asynchronous IO
operations. |
ReactiveChannelGroup |
shutdown()
Initiates an orderly shutdown of the group. |
ReactiveChannelGroup |
shutdownNow()
Shuts down the group and closes all open channels in the group. |
| Methods inherited from class com.sun.sgs.impl.nio.AsyncGroupImpl |
|---|
completionRunner, executor, finalize, selectorProvider |
| Methods inherited from class com.sun.sgs.nio.channels.AsynchronousChannelGroup |
|---|
getDefaultUncaughtExceptionHandler, open, provider, setDefaultUncaughtExceptionHandler |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
static final Logger log
final Object stateLock
protected int lifecycleState
protected static final int RUNNING
protected static final int SHUTDOWN
protected static final int SHUTDOWN_NOW
protected static final int DONE
final List<Reactor> reactors
public static final String REACTORS_PROPERTY
public static final int DEFAULT_REACTORS
Runtime.getRuntime().availableProcessors()
final ReactiveChannelGroup.ReactorAssignmentStrategy reactorAssignmentStrategy
| Constructor Detail |
|---|
ReactiveChannelGroup(ReactiveAsyncChannelProvider provider,
ExecutorService executor)
throws IOException
provider - the provider that created this groupexecutor - the executor for this group
IOException - if an I/O error occurs
ReactiveChannelGroup(ReactiveAsyncChannelProvider provider,
ExecutorService executor,
int requestedReactors)
throws IOException
available processors.
provider - the provider that created this groupexecutor - the executor for this grouprequestedReactors - the number of reactors to create in this
group, or 0 to use the default
IllegalArgumentException - if a negative number of reactors is
requested
IOException - if an I/O error occurs| Method Detail |
|---|
AsyncKey register(SelectableChannel ch)
throws IOException
AsyncKey that can be used to invoke asynchronous IO
operations. If this group is shutdown, this method will throw
ShutdownChannelGroupException and close the channel.
register in class AsyncGroupImplch - the underlying channel for IO operations
AsyncKey that supports asynchronous operations
on the underlying channel
IOException - if an I/O error occurs
public boolean awaitTermination(long timeout,
TimeUnit unit)
throws InterruptedException
This method blocks until all channels in the group have been closed and all resources associated with the group have been released.
awaitTermination in class AsynchronousChannelGrouptimeout - the maximum time to waitunit - the time unit of the timeout argument
true if the group has terminated; false if
the timeout elapsed before termination
InterruptedException - if interrupted while waitingpublic boolean isShutdown()
isShutdown in class AsynchronousChannelGrouptrue if this asynchronous channel group is shutdownpublic boolean isTerminated()
isTerminated in class AsynchronousChannelGrouptrue if this asynchronous channel group is terminatedpublic ReactiveChannelGroup shutdown()
This method marks the group as shutdown. Further attempts to
construct a channel that binds to this group will throw
ShutdownChannelGroupException. The group terminates when all
asynchronous channels in the group are closed and all resources have
been released. This method has no effect if the group is already
shutdown.
shutdown in class AsynchronousChannelGroup
public ReactiveChannelGroup shutdownNow()
throws IOException
In addition to the actions performed by the AsynchronousChannelGroup.shutdown() method,
this method invokes the close
method on all open channels in the group. This method does not
attempt to stop actively executing
completion handlers.
The group is likely to terminate quickly after invoking this method but there is no guarantee that the group has terminated on completion of this method.
shutdownNow in class AsynchronousChannelGroupIOException - if an I/O error occurs
|
RedDwarf, Version 0.10.1 2010-03-14 10:56:12 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||