Package io.debezium.util
Interface ElapsedTimeStrategy
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Encapsulates the logic of determining a delay when some criteria is met.
- Author:
- Randall Hauch
-
Method Summary
Modifier and TypeMethodDescriptionstatic ElapsedTimeStrategy
Create a strategy whose time periods are constant.static ElapsedTimeStrategy
Create a strategy whose time periods are constant.static ElapsedTimeStrategy
exponential
(Clock clock, long initialDelayInMilliseconds, long maxDelayInMilliseconds, double multiplier) Create a strategy whose time periods increase exponentially.static ElapsedTimeStrategy
exponential
(Clock clock, Duration initialDelay, Duration maxDelay) Create a strategy whose time periods increase exponentially.boolean
Determine if the time period has elapsed since this method was last called.static ElapsedTimeStrategy
Create a strategy whose time periods linearly increase in length.static ElapsedTimeStrategy
none()
Create an elapsed time strategy that always is elapsed.static ElapsedTimeStrategy
step
(Clock clock, Duration preStepDelay, BooleanSupplier stepFunction, Duration postStepDelay) Create a strategy whose time periods start out at one length but then change to another length after another period has elapsed.
-
Method Details
-
hasElapsed
boolean hasElapsed()Determine if the time period has elapsed since this method was last called.- Returns:
true
if this invocation caused the thread to sleep, orfalse
if this method did not sleep
-
none
Create an elapsed time strategy that always is elapsed.- Returns:
- the strategy; never null
-
constant
Create a strategy whose time periods are constant.- Parameters:
clock
- the clock used to determine if sufficient time has elapsed; may not be nulldelayInMilliseconds
- the time period; must be positive- Returns:
- the strategy; never null
-
constant
Create a strategy whose time periods are constant. -
step
static ElapsedTimeStrategy step(Clock clock, Duration preStepDelay, BooleanSupplier stepFunction, Duration postStepDelay) Create a strategy whose time periods start out at one length but then change to another length after another period has elapsed.- Parameters:
clock
- the clock used to determine if sufficient time has elapsed; may not be nullpreStepDelay
- the time period before the step has occurred; must be positivestepFunction
- the function that determines if the step time has elapsed; may not be nullpostStepDelay
- the time period before the step has occurred; must be positive- Returns:
- the strategy; never null
-
linear
Create a strategy whose time periods linearly increase in length.- Parameters:
clock
- the clock used to determine if sufficient time has elapsed; may not be nulldelay
- the initial delay; must be positive- Returns:
- the strategy; never null
-
exponential
Create a strategy whose time periods increase exponentially.- Parameters:
clock
- the clock used to determine if sufficient time has elapsed; may not be nullinitialDelay
- the initial delay; must be positivemaxDelay
- the maximum delay; must be greater than the initial delay- Returns:
- the strategy; never null
-
exponential
static ElapsedTimeStrategy exponential(Clock clock, long initialDelayInMilliseconds, long maxDelayInMilliseconds, double multiplier) Create a strategy whose time periods increase exponentially.- Parameters:
clock
- the clock used to determine if sufficient time has elapsed; may not be nullinitialDelayInMilliseconds
- the initial delay; must be positivemaxDelayInMilliseconds
- the maximum delay; must be greater than the initial delaymultiplier
- the factor by which the delay increases each pass- Returns:
- the strategy
-