Top Description Fields Constructors Methods
org.glassfish.grizzly.strategies

public final Class SimpleDynamicNIOStrategy

extends Object
implements IOStrategy
Class Inheritance
All Implemented Interfaces
org.glassfish.grizzly.IOStrategy, org.glassfish.grizzly.strategies.WorkerThreadPoolConfigProducer
Imports
java.io.IOException, java.util.concurrent.Executor, org.glassfish.grizzly.Connection, .IOEvent, .IOStrategy, .Transport, org.glassfish.grizzly.nio.NIOConnection, .NIOTransport, org.glassfish.grizzly.threadpool.ThreadPoolConfig

Simple dynamic strategy, which switches I/O processing strategies, basing on statistics. This implementation takes in consideration number of java.nio.channels.SelectionKeys, which were selected last time by java.nio.channels.Selector. SimpleDynamicIOStrategy is able to use 2 strategies underneath: SameThreadIOStrategy, WorkerThreadIOStrategy. And is able to switch between them basing on corresponding threshold (threshold represents the number of selected java.nio.channels.SelectionKeys). So the strategy is getting applied following way: SameThreadIOStrategy --(worker-thread threshold)--> WorkerThreadIOStrategy.
Author
Alexey Stashok

Field Summary

Modifier and TypeField and Description
private static final SimpleDynamicNIOStrategy
private final SameThreadIOStrategy
private static final int
private final WorkerThreadIOStrategy

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public ThreadPoolConfig
public boolean
executeIoEvent(Connection<L> connection, IOEvent ioEvent)

Implements org.glassfish.grizzly.IOStrategy.executeIoEvent.

The org.glassfish.grizzly.nio.SelectorRunner will invoke this method to allow the strategy implementation to decide how the IOEvent will be handled.

public boolean
executeIoEvent(final Connection<L> connection, final IOEvent ioEvent, final boolean isIoEventEnabled)

Implements org.glassfish.grizzly.IOStrategy.executeIoEvent.

The org.glassfish.grizzly.nio.SelectorRunner will invoke this method to allow the strategy implementation to decide how the IOEvent will be handled.

public static SimpleDynamicNIOStrategy
private static int
public Executor
getThreadPoolFor(final Connection<L> connection, final IOEvent ioEvent)

Implements org.glassfish.grizzly.IOStrategy.getThreadPoolFor.

Returns an Executor to be used to run given ioEvent processing for the given connection.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

INSTANCEback to summary
private static final SimpleDynamicNIOStrategy INSTANCE
sameThreadStrategyback to summary
private final SameThreadIOStrategy sameThreadStrategy
WORKER_THREAD_THRESHOLDback to summary
private static final int WORKER_THREAD_THRESHOLD
workerThreadStrategyback to summary
private final WorkerThreadIOStrategy workerThreadStrategy

Constructor Detail

SimpleDynamicNIOStrategyback to summary
private SimpleDynamicNIOStrategy()

Method Detail

createDefaultWorkerPoolConfigback to summary
public ThreadPoolConfig createDefaultWorkerPoolConfig(final Transport transport)

Implements org.glassfish.grizzly.strategies.WorkerThreadPoolConfigProducer.createDefaultWorkerPoolConfig.

Annotations
@Override
executeIoEventback to summary
public boolean executeIoEvent(Connection<L> connection, IOEvent ioEvent) throws IOException

Implements org.glassfish.grizzly.IOStrategy.executeIoEvent.

Doc from org.glassfish.grizzly.IOStrategy.executeIoEvent.

The org.glassfish.grizzly.nio.SelectorRunner will invoke this method to allow the strategy implementation to decide how the IOEvent will be handled.

Annotations
@Override
Exceptions
IOException:
if an error occurs processing the IOEvent.
executeIoEventback to summary
public boolean executeIoEvent(final Connection<L> connection, final IOEvent ioEvent, final boolean isIoEventEnabled) throws IOException

Implements org.glassfish.grizzly.IOStrategy.executeIoEvent.

Doc from org.glassfish.grizzly.IOStrategy.executeIoEvent.

The org.glassfish.grizzly.nio.SelectorRunner will invoke this method to allow the strategy implementation to decide how the IOEvent will be handled.

Annotations
@Override
Exceptions
IOException:
if an error occurs processing the IOEvent.
getInstanceback to summary
public static SimpleDynamicNIOStrategy getInstance()
getLastSelectedKeysCountback to summary
private static int getLastSelectedKeysCount(final Connection<L> c)
getThreadPoolForback to summary
public Executor getThreadPoolFor(final Connection<L> connection, final IOEvent ioEvent)

Implements org.glassfish.grizzly.IOStrategy.getThreadPoolFor.

Doc from org.glassfish.grizzly.IOStrategy.getThreadPoolFor.

Returns an Executor to be used to run given ioEvent processing for the given connection. A null value will be returned if the ioEvent should be executed in the kernel thread.

Annotations
@Override