public class BackoffJobAcquisitionStrategy extends Object implements 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:
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)
Modifier and Type | Field and Description |
---|---|
protected boolean |
applyJitter |
protected int |
backoffDecreaseThreshold |
protected float |
backoffIncreaseFactor |
protected int |
backoffLevel |
protected long |
baseBackoffWaitTime |
protected long |
baseIdleWaitTime |
protected int |
baseNumJobsToAcquire |
static long |
DEFAULT_EXECUTION_SATURATION_WAIT_TIME |
protected boolean |
executionSaturated |
protected long |
executionSaturationWaitTime |
protected float |
idleIncreaseFactor |
protected int |
idleLevel |
protected Map<String,Integer> |
jobsToAcquire |
protected int |
maxBackoffLevel |
protected long |
maxBackoffWaitTime |
protected int |
maxIdleLevel |
protected long |
maxIdleWaitTime |
protected int |
numAcquisitionsWithoutLockingFailure |
Constructor and Description |
---|
BackoffJobAcquisitionStrategy(JobExecutor jobExecutor) |
BackoffJobAcquisitionStrategy(long baseIdleWaitTime,
float idleIncreaseFactor,
long maxIdleTime,
long baseBackoffWaitTime,
float backoffIncreaseFactor,
long maxBackoffTime,
int backoffDecreaseThreshold,
int baseNumJobsToAcquire) |
Modifier and Type | Method and Description |
---|---|
protected boolean |
allSubmittedJobsRejected(JobAcquisitionContext context) |
protected long |
calculateBackoffTime() |
protected long |
calculateIdleTime() |
int |
getNumJobsToAcquire(String processEngine) |
long |
getWaitTime() |
protected void |
initializeMaxLevels() |
protected double |
log(double base,
double value) |
void |
reconfigure(JobAcquisitionContext context) |
protected void |
reconfigureBackoffLevel(JobAcquisitionContext context) |
protected void |
reconfigureIdleLevel(JobAcquisitionContext context) |
protected void |
reconfigureNumberOfJobsToAcquire(JobAcquisitionContext context) |
public static long DEFAULT_EXECUTION_SATURATION_WAIT_TIME
protected long baseIdleWaitTime
protected float idleIncreaseFactor
protected int idleLevel
protected int maxIdleLevel
protected long maxIdleWaitTime
protected long baseBackoffWaitTime
protected float backoffIncreaseFactor
protected int backoffLevel
protected int maxBackoffLevel
protected long maxBackoffWaitTime
protected boolean applyJitter
protected int numAcquisitionsWithoutLockingFailure
protected int backoffDecreaseThreshold
protected int baseNumJobsToAcquire
protected boolean executionSaturated
protected long executionSaturationWaitTime
public BackoffJobAcquisitionStrategy(long baseIdleWaitTime, float idleIncreaseFactor, long maxIdleTime, long baseBackoffWaitTime, float backoffIncreaseFactor, long maxBackoffTime, int backoffDecreaseThreshold, int baseNumJobsToAcquire)
public BackoffJobAcquisitionStrategy(JobExecutor jobExecutor)
protected void initializeMaxLevels()
protected double log(double base, double value)
public void reconfigure(JobAcquisitionContext context)
reconfigure
in interface JobAcquisitionStrategy
protected boolean allSubmittedJobsRejected(JobAcquisitionContext context)
protected void reconfigureIdleLevel(JobAcquisitionContext context)
protected void reconfigureBackoffLevel(JobAcquisitionContext context)
protected void reconfigureNumberOfJobsToAcquire(JobAcquisitionContext context)
public long getWaitTime()
getWaitTime
in interface JobAcquisitionStrategy
protected long calculateIdleTime()
protected long calculateBackoffTime()
public int getNumJobsToAcquire(String processEngine)
getNumJobsToAcquire
in interface JobAcquisitionStrategy
Copyright © 2022. All rights reserved.