|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.glassfish.grizzly.strategies.SimpleDynamicStrategy
public class SimpleDynamicStrategy
Simple dynamic strategy, which switches I/O processing strategies, basing
on statistics. This implementation takes in consideration number of
SelectionKeys, which were selected last time by Selector.
SimpleDynamicStrategy is able to use 3 strategies underneath:
SameThreadStrategy, LeaderFollowerStrategy,
WorkerThreadStrategy. And is able to switch between them basing on
corresponding thresholds (threshold represents the number of selected
SelectionKeys).
So the strategy is getting applied following way:
SameThreadStrategy --(leader-follower threshold)--> LeaderFollowerStrategy --(worker-thread threshold)--> WorkerThreadStrategy.
| Nested Class Summary | |
|---|---|
static class |
SimpleDynamicStrategy.DynamicStrategyContext
|
| Constructor Summary | |
|---|---|
SimpleDynamicStrategy(Executor sameThreadProcessorExecutor,
Executor workerThreadProcessorExecutor)
|
|
SimpleDynamicStrategy(NIOTransport transport)
|
|
| Method Summary | |
|---|---|
void |
executeProcessor(SimpleDynamicStrategy.DynamicStrategyContext strategyContext,
ProcessorRunnable processorRunnable)
Execute ProcessorRunnable task. |
int |
getLeaderFollowerThreshold()
Returns the number of SelectionKeys, which should be selected
from a Selector, to make it apply LeaderFollowerStrategy. |
int |
getWorkerThreadThreshold()
Returns the number of SelectionKeys, which should be selected
from a Selector, to make it apply WorkerThreadStrategy. |
boolean |
isTerminateThread(SimpleDynamicStrategy.DynamicStrategyContext strategyContext)
This method may be called by runner Thread after task will be
executed. |
SimpleDynamicStrategy.DynamicStrategyContext |
prepare(Connection connection,
IOEvent ioEvent)
Prepare Strategy for processing IOEvent, occured on the
Connection. |
void |
setLeaderFollowerThreshold(int leaderFollowerThreshold)
Set the number of SelectionKeys, which should be selected
from a Selector, to make it apply LeaderFollowerStrategy. |
void |
setWorkerThreadThreshold(int workerThreadThreshold)
Set the number of SelectionKeys, which should be selected
from a Selector, to make it apply WorkerThreadStrategy. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SimpleDynamicStrategy(NIOTransport transport)
public SimpleDynamicStrategy(Executor sameThreadProcessorExecutor,
Executor workerThreadProcessorExecutor)
| Method Detail |
|---|
public SimpleDynamicStrategy.DynamicStrategyContext prepare(Connection connection,
IOEvent ioEvent)
Strategy for processing IOEvent, occured on the
Connection.
At this phase Strategy may initialize and return context data,
which will be passed further into executeProcessor and isTerminateThread
methods.
prepare in interface Strategy<SimpleDynamicStrategy.DynamicStrategyContext>connection - Connection, on which IOEvent occured.ioEvent - IOEvent.
IOEvent processing.
public void executeProcessor(SimpleDynamicStrategy.DynamicStrategyContext strategyContext,
ProcessorRunnable processorRunnable)
throws IOException
ProcessorRunnable task.
executeProcessor in interface Strategy<SimpleDynamicStrategy.DynamicStrategyContext>strategyContext - context object, initialized on "prepare" phase.processorRunnable - the ProcessorRunnable task to be executed.
IOExceptionpublic boolean isTerminateThread(SimpleDynamicStrategy.DynamicStrategyContext strategyContext)
Thread after task will be
executed. Strategy may instruct the caller to release current
thread, after task execution will be completed.
isTerminateThread in interface Strategy<SimpleDynamicStrategy.DynamicStrategyContext>strategyContext - Strategy context, initialized on "prepare"
phase.
Thread, or false otherwise.LeaderFollowerStrategypublic int getLeaderFollowerThreshold()
SelectionKeys, which should be selected
from a Selector, to make it apply LeaderFollowerStrategy.
SelectionKeys, which should be selected
from a Selector, to make it apply LeaderFollowerStrategy.public void setLeaderFollowerThreshold(int leaderFollowerThreshold)
SelectionKeys, which should be selected
from a Selector, to make it apply LeaderFollowerStrategy.
leaderFollowerThreshold - the number of SelectionKeys,
which should be selected from a Selector, to make it apply
LeaderFollowerStrategy.public int getWorkerThreadThreshold()
SelectionKeys, which should be selected
from a Selector, to make it apply WorkerThreadStrategy.
SelectionKeys, which should be selected
from a Selector, to make it apply WorkerThreadStrategy.public void setWorkerThreadThreshold(int workerThreadThreshold)
SelectionKeys, which should be selected
from a Selector, to make it apply WorkerThreadStrategy.
workerThreadThreshold - the number of SelectionKeys,
which should be selected from a Selector, to make it apply
WorkerThreadStrategy.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||