Class ExponentialBackOffTrigger
java.lang.Object
com.netflix.genie.common.internal.util.ExponentialBackOffTrigger
- All Implemented Interfaces:
org.springframework.scheduling.Trigger
@ThreadSafe
public class ExponentialBackOffTrigger
extends Object
implements org.springframework.scheduling.Trigger
Trigger implementation whose scheduling delay grows exponentially based on a given factor.
The delay is bound between some minimum and maximum.
The delay can be relative to the previous task scheduling/execution/completion.
- Since:
- 3.3.9
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
How the delay is calculated. -
Constructor Summary
ConstructorDescriptionConstructor with properties.ExponentialBackOffTrigger
(ExponentialBackOffTrigger.DelayType delayType, long minDelay, long maxDelay, float factor) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionnextExecutionTime
(org.springframework.scheduling.TriggerContext triggerContext) void
reset()
Reset the delay to the minimum given at construction time.
-
Constructor Details
-
ExponentialBackOffTrigger
Constructor with properties. Loads all values during construction. I.e. does not respond to subsequent changes to property values dynamically.- Parameters:
properties
- the properties
-
ExponentialBackOffTrigger
public ExponentialBackOffTrigger(ExponentialBackOffTrigger.DelayType delayType, long minDelay, long maxDelay, float factor) Constructor.- Parameters:
delayType
- type of delayminDelay
- minimum delay in millisecondsmaxDelay
- maximum delay in millisecondsfactor
- multiplier factor to grow the delay- Throws:
IllegalArgumentException
- if the minimum delay is smaller than 1, the max delay is smaller than the minimum, or the factor is not positive.
-
-
Method Details
-
nextExecutionTime
- Specified by:
nextExecutionTime
in interfaceorg.springframework.scheduling.Trigger
-
reset
public void reset()Reset the delay to the minimum given at construction time. Example usage: if the trigger is used to slow down attempt to contact a remote service in case of error, then a successful request can invoke reset, ensuring the next attempt will not be delayed.
-