public final class SimpleDynamicNIOStrategy extends Object implements IOStrategy
SelectionKeys, which were selected last time by
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 SelectionKeys).
So the strategy is getting applied following way:
SameThreadIOStrategy --(worker-thread threshold)--> WorkerThreadIOStrategy.| Modifier and Type | Method and Description |
|---|---|
ThreadPoolConfig |
createDefaultWorkerPoolConfig(Transport transport) |
boolean |
executeIoEvent(Connection connection,
IOEvent ioEvent)
The
SelectorRunner will invoke this method to allow the strategy implementation to
decide how the IOEvent will be handled. |
boolean |
executeIoEvent(Connection connection,
IOEvent ioEvent,
boolean isIoEventEnabled)
The
SelectorRunner will invoke this method to allow the strategy implementation to
decide how the IOEvent will be handled. |
static SimpleDynamicNIOStrategy |
getInstance() |
Executor |
getThreadPoolFor(Connection connection,
IOEvent ioEvent)
Returns an
Executor to be used to run given ioEvent processing for the given connection. |
public static SimpleDynamicNIOStrategy getInstance()
public boolean executeIoEvent(Connection connection, IOEvent ioEvent) throws IOException
IOStrategySelectorRunner will invoke this method to allow the strategy implementation to
decide how the IOEvent will be handled.executeIoEvent in interface IOStrategyconnection - the Connection upon which the provided IOEvent occurred.ioEvent - the IOEvent that triggered execution of this strategyIOException - if an error occurs processing the IOEvent.public Executor getThreadPoolFor(Connection connection, IOEvent ioEvent)
IOStrategyExecutor 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.getThreadPoolFor in interface IOStrategyconnection - ConnectionioEvent - the event to get the Executor forExecutor to be used to run given ioEvent processing for the given connectionpublic boolean executeIoEvent(Connection connection, IOEvent ioEvent, boolean isIoEventEnabled) throws IOException
IOStrategySelectorRunner will invoke this method to allow the strategy implementation to
decide how the IOEvent will be handled.executeIoEvent in interface IOStrategyconnection - the Connection upon which the provided IOEvent occurred.ioEvent - the IOEvent that triggered execution of this strategyisIoEventEnabled - true if IOEvent is still enabled on the Connection, or false if
IOEvent was preliminary disabled or IOEvent is being simulated.IOException - if an error occurs processing the IOEvent.public ThreadPoolConfig createDefaultWorkerPoolConfig(Transport transport)
createDefaultWorkerPoolConfig in interface WorkerThreadPoolConfigProducerCopyright © 2017–2020 Oracle Corporation. All rights reserved.