Class BackoffJobAcquisitionStrategy
java.lang.Object
org.camunda.bpm.engine.impl.jobexecutor.BackoffJobAcquisitionStrategy
- All Implemented Interfaces:
JobAcquisitionStrategy
Determines the number of jobs to acquire and the time to wait between acquisition cycles by an exponential backoff strategy.
Manages two kinds of backoff times:
- idle time: Wait for a certain amount of time when no jobs are available
- backoff time: Wait for a certain amount of time when jobs are available but could not successfully be acquired
This implementation manages idle and backoff time in terms of levels. The initial backoff level is 0, meaning that no backoff is applied. In case the condition for increasing backoff applies, the backoff level is incremented. The actual time to wait is then computed as follows
timeToWait = baseBackoffTime * (backoffFactor ^ (backoffLevel - 1))
Accordingly, the maximum possible backoff level is
maximumLevel = floor( log( backoffFactor, maximumBackoffTime / baseBackoffTime) ) + 1(where log(a, b) is the logarithm of b to the base of a)
- Author:
- Thorben Lindhauer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected intprotected floatprotected intprotected longprotected longprotected intstatic longprotected booleanprotected longprotected floatprotected intprotected intprotected longprotected intprotected longprotected int -
Constructor Summary
ConstructorsConstructorDescriptionBackoffJobAcquisitionStrategy(long baseIdleWaitTime, float idleIncreaseFactor, long maxIdleTime, long baseBackoffWaitTime, float backoffIncreaseFactor, long maxBackoffTime, int backoffDecreaseThreshold, int baseNumJobsToAcquire) BackoffJobAcquisitionStrategy(JobExecutor jobExecutor) -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanprotected longprotected longintgetNumJobsToAcquire(String processEngine) longprotected voidprotected doublelog(double base, double value) voidreconfigure(JobAcquisitionContext context) protected voidprotected voidprotected void
-
Field Details
-
DEFAULT_EXECUTION_SATURATION_WAIT_TIME
public static long DEFAULT_EXECUTION_SATURATION_WAIT_TIME -
baseIdleWaitTime
protected long baseIdleWaitTime -
idleIncreaseFactor
protected float idleIncreaseFactor -
idleLevel
protected int idleLevel -
maxIdleLevel
protected int maxIdleLevel -
maxIdleWaitTime
protected long maxIdleWaitTime -
baseBackoffWaitTime
protected long baseBackoffWaitTime -
backoffIncreaseFactor
protected float backoffIncreaseFactor -
backoffLevel
protected int backoffLevel -
maxBackoffLevel
protected int maxBackoffLevel -
maxBackoffWaitTime
protected long maxBackoffWaitTime -
applyJitter
protected boolean applyJitter -
numAcquisitionsWithoutLockingFailure
protected int numAcquisitionsWithoutLockingFailure -
backoffDecreaseThreshold
protected int backoffDecreaseThreshold -
baseNumJobsToAcquire
protected int baseNumJobsToAcquire -
jobsToAcquire
-
executionSaturated
protected boolean executionSaturated -
executionSaturationWaitTime
protected long executionSaturationWaitTime
-
-
Constructor Details
-
BackoffJobAcquisitionStrategy
public BackoffJobAcquisitionStrategy(long baseIdleWaitTime, float idleIncreaseFactor, long maxIdleTime, long baseBackoffWaitTime, float backoffIncreaseFactor, long maxBackoffTime, int backoffDecreaseThreshold, int baseNumJobsToAcquire) -
BackoffJobAcquisitionStrategy
-
-
Method Details
-
initializeMaxLevels
protected void initializeMaxLevels() -
log
protected double log(double base, double value) -
reconfigure
- Specified by:
reconfigurein interfaceJobAcquisitionStrategy
-
allSubmittedJobsRejected
- Returns:
- true, if all acquired jobs (spanning all engines) were rejected for execution
-
reconfigureIdleLevel
-
reconfigureBackoffLevel
-
reconfigureNumberOfJobsToAcquire
-
getWaitTime
public long getWaitTime()- Specified by:
getWaitTimein interfaceJobAcquisitionStrategy
-
calculateIdleTime
protected long calculateIdleTime() -
calculateBackoffTime
protected long calculateBackoffTime() -
getNumJobsToAcquire
- Specified by:
getNumJobsToAcquirein interfaceJobAcquisitionStrategy
-