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.
@FunctionalInterface public interface ElapsedTimeStrategy
Encapsulates the logic of determining a delay when some criteria is met.- Author:
- Randall Hauch
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static ElapsedTimeStrategy
constant(Clock clock, long delayInMilliseconds)
Create a strategy whose time periods are constant.static ElapsedTimeStrategy
constant(Clock clock, Duration delay)
Create a strategy whose time periods are constant.static ElapsedTimeStrategy
exponential(Clock clock, long initialDelayInMilliseconds, long maxDelayInMilliseconds)
Create a strategy whose time periods increase exponentially.static ElapsedTimeStrategy
exponential(Clock clock, long initialDelayInMilliseconds, long maxDelayInMilliseconds, double multiplier)
Create a strategy whose time periods increase exponentially.boolean
hasElapsed()
Determine if the time period has elapsed since this method was last called.static ElapsedTimeStrategy
linear(Clock clock, long delayInMilliseconds)
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, long preStepDelayInMilliseconds, BooleanSupplier stepFunction, long postStepDelayInMilliseconds)
Create a strategy whose time periods start out at one length but then change to another length after another period has elapsed.
-
-
-
Method Detail
-
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
static ElapsedTimeStrategy none()
Create an elapsed time strategy that always is elapsed.- Returns:
- the strategy; never null
-
constant
static ElapsedTimeStrategy constant(Clock clock, long delayInMilliseconds)
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
static ElapsedTimeStrategy constant(Clock clock, Duration delay)
Create a strategy whose time periods are constant.
-
step
static ElapsedTimeStrategy step(Clock clock, long preStepDelayInMilliseconds, BooleanSupplier stepFunction, long postStepDelayInMilliseconds)
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 nullpreStepDelayInMilliseconds
- the time period before the step has occurred; must be positivestepFunction
- the function that determines if the step time has elapsed; may not be nullpostStepDelayInMilliseconds
- the time period before the step has occurred; must be positive- Returns:
- the strategy; never null
-
linear
static ElapsedTimeStrategy linear(Clock clock, long delayInMilliseconds)
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 nulldelayInMilliseconds
- the initial delay; must be positive- Returns:
- the strategy; never null
-
exponential
static ElapsedTimeStrategy exponential(Clock clock, long initialDelayInMilliseconds, long maxDelayInMilliseconds)
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 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
-
-