|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.emarsys.ecommon.time.schedule.DelayedLinearQueueSchedulingStrategy<T>
public class DelayedLinearQueueSchedulingStrategy<T>
The DelayedLinearQueueSchedulingStrategy
represents a
two phase scheduling algorithm that reschedules queue elements
in their first phase in constant intervals and scales them
linearly with number of processings in their second.
See calculateNextProcessing(QueueScheduler, SchedulableQueueElement)
for the detailed scheduling alorithm specification and
DelayedLinearQueueSchedulingStrategy(int, int)
for the
specification of its parameters.
Under the hood the DelayedLinearQueueSchedulingStrategy
is
powered by QueueSchedulingStrategyChain
that consists of
a ConstantQueueSchedulingStrategy
and a
LinearQueueSchedulingStrategy
as well as the corresponding
predicates that decide which concrete strategy to use.
Field Summary | |
---|---|
protected QueueSchedulingStrategyChain<T> |
alice
the QueueSchedulingStrategyChain that acutally performs |
protected int |
baseIntLen
|
protected static java.lang.String |
CONST_PHASE_ITERATIONS_KEY
|
protected int |
delayIntLen
|
Constructor Summary | |
---|---|
DelayedLinearQueueSchedulingStrategy(int baseIntLen,
int delayIntLen)
Creates a new DelayedLinearQueueSchedulingStrategy instance
with the passed parameters. |
Method Summary | |
---|---|
java.util.Calendar |
calculateNextProcessing(QueueScheduler<T> scheduler,
SchedulableQueueElement<T> schedulable)
If the passed schedulable has been queued (according to SchedulableQueueElement.getQueueingDate() ) before the
delay threshold (== queueing date + delayIntLen ) it will
be constantly rescheduled in baseIntLen milliseconds (see
ConstantQueueSchedulingStrategy ).Else if it has been queued after said threshold it will be linearly rescheduled in SchedulableQueueElement.getScheduledCount()
* delayIntLen milliseconds
(see LinearQueueSchedulingStrategy ). |
protected void |
checkInvariants()
Checks the following invariants which have to be fullfilled at any time: 0 < baseIntLen < delayIntLen
|
protected int |
getConstPhaseIterationCount(QueueSchedulingContext<T> context)
|
protected QueueSchedulingStrategy<T> |
getConstStrategy()
Creates a new wrapped ConstantQueueSchedulingStrategy
instance that will increment the number of the
context param CONST_PHASE_ITERATIONS_KEY on every
call of
calculateNextProcessing(QueueScheduler, SchedulableQueueElement) . |
protected org.apache.commons.collections.Predicate |
getIsBeforeDelayThresholdPredicate()
Returns a Predicate that evaluates to true
if the passed SchedulableQueueElement 's (the
one associated with the passed ChainElement ) queueing date +
delayIntLen is before the current time. |
protected QueueSchedulingStrategy<T> |
getLinearStrategy()
Creates a LinearQueueSchedulingStrategy that will
start to scale the scheduling interval after the constant
scheduling phase. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final java.lang.String CONST_PHASE_ITERATIONS_KEY
protected final int baseIntLen
protected final int delayIntLen
protected QueueSchedulingStrategyChain<T> alice
QueueSchedulingStrategyChain
that acutally performs
Constructor Detail |
---|
public DelayedLinearQueueSchedulingStrategy(int baseIntLen, int delayIntLen) throws java.lang.IllegalArgumentException
Creates a new DelayedLinearQueueSchedulingStrategy
instance
with the passed parameters.
See checkInvariants()
for the restritions of the params.
baseIntLen
- - the base interval lenth for the constant
rescheduling phase.delayIntLen
- - both the delay after which the linear
rescheduling phase will start and the to be scaled
interval lenghte in said phase..
java.lang.IllegalArgumentException
- -
if an invariant is violated through the params
Method Detail |
---|
protected void checkInvariants()
baseIntLen
< delayIntLen
protected QueueSchedulingStrategy<T> getConstStrategy()
ConstantQueueSchedulingStrategy
instance that will increment the number of the
context param CONST_PHASE_ITERATIONS_KEY
on every
call of
calculateNextProcessing(QueueScheduler, SchedulableQueueElement)
.
QueueSchedulingStrategy
instance,
never null
.protected int getConstPhaseIterationCount(QueueSchedulingContext<T> context)
context
-
protected QueueSchedulingStrategy<T> getLinearStrategy()
Creates a LinearQueueSchedulingStrategy
that will
start to scale the scheduling interval after the constant
scheduling phase.
In order to get the right number of reschedulings in the
constant phase the QueueSchedulingContext
param
CONST_PHASE_ITERATIONS_KEY
is queried.
The retrieved number will be used to create a dynamical negative
offset for the scheduled count of a proxy for the schedulable, see
SchedulableQueueElementProxy.setScheduledCountOffset(int)
for details.
QueueSchedulingStrategy
instance,
never null
.protected org.apache.commons.collections.Predicate getIsBeforeDelayThresholdPredicate()
Predicate
that evaluates to true
if the passed SchedulableQueueElement
's (the
one associated with the passed ChainElement
) queueing date +
delayIntLen
is before the current time.
Predicate
instance.public java.util.Calendar calculateNextProcessing(QueueScheduler<T> scheduler, SchedulableQueueElement<T> schedulable)
If the passed schedulable has been queued (according to
SchedulableQueueElement.getQueueingDate()
) before the
delay threshold (== queueing date + delayIntLen
) it will
be constantly rescheduled in baseIntLen
milliseconds (see
ConstantQueueSchedulingStrategy
).
Else if it has been queued after said threshold it will be
linearly rescheduled in
SchedulableQueueElement.getScheduledCount()
* delayIntLen
milliseconds
(see LinearQueueSchedulingStrategy
).
calculateNextProcessing
in interface QueueSchedulingStrategy<T>
scheduler
- - the QueueScheduler
that is associated
with this strategy instanceschedulable
- - the SchedulableQueueElement
that
will be (re)scheduled
null
because every of the chained
strategies returns a valid Calendar
instance the
predicates for executing them are exclusive or joint.QueueSchedulingStrategy.calculateNextProcessing(com.emarsys.ecommon.time.schedule.QueueScheduler, com.emarsys.ecommon.time.schedule.SchedulableQueueElement)
public java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |