Class Delay
java.lang.Object
com.couchbase.client.dcp.core.time.Delay
- Direct Known Subclasses:
ExponentialDelay,FixedDelay,LinearDelay
Parent class of
Delays and provides factory methods to create them.-
Method Summary
Modifier and TypeMethodDescriptionabstract longcalculate(long attempt) Calculate a specific delay based on the attempt passed in.static Delayexponential(TimeUnit unit) Creates a newExponentialDelaywith default boundaries and factor (1, 2, 4, 8, 16, 32...).static Delayexponential(TimeUnit unit, long upper) Creates a newExponentialDelaywith custom upper boundary and default factor (eg.static Delayexponential(TimeUnit unit, long upper, long lower) Creates a newExponentialDelaywith custom boundaries and default factor (eg.static Delayexponential(TimeUnit unit, long upper, long lower, long growBy) Creates a newExponentialDelaywith custom boundaries and factor (eg.static Delayexponential(TimeUnit unit, long upper, long lower, long growBy, int powersOf) Creates a newExponentialDelayon a base different from powers of two, with custom boundaries and factor (eg.static DelayCreates a newFixedDelay.static DelayCreates a newLinearDelaywith no bounds and default factor.static DelayCreates a newLinearDelaywith a custom upper boundary and the default factor.static DelayCreates a newLinearDelaywith a custom boundaries and the default factor.static DelayCreates a newLinearDelaywith a custom boundaries and factor.unit()
-
Method Details
-
unit
- Returns:
- the time unit.
-
calculate
public abstract long calculate(long attempt) Calculate a specific delay based on the attempt passed in.This method is to be implemented by the child implementations and depending on the params that were set during construction time.
- Parameters:
attempt- the attempt to calculate the delay from.- Returns:
- the calculate delay.
-
fixed
Creates a newFixedDelay.- Parameters:
delay- the time of the delay.unit- the unit of the delay.- Returns:
- a created
FixedDelay.
-
linear
Creates a newLinearDelaywith no bounds and default factor.- Parameters:
unit- the unit of the delay.- Returns:
- a created
LinearDelay.
-
linear
Creates a newLinearDelaywith a custom upper boundary and the default factor.- Parameters:
unit- the unit of the delay.upper- the upper boundary.- Returns:
- a created
LinearDelay.
-
linear
Creates a newLinearDelaywith a custom boundaries and the default factor.- Parameters:
unit- the unit of the delay.upper- the upper boundary.lower- the lower boundary.- Returns:
- a created
LinearDelay.
-
linear
Creates a newLinearDelaywith a custom boundaries and factor.- Parameters:
unit- the unit of the delay.upper- the upper boundary.lower- the lower boundary.growBy- the multiplication factor.- Returns:
- a created
LinearDelay.
-
exponential
Creates a newExponentialDelaywith default boundaries and factor (1, 2, 4, 8, 16, 32...).- Parameters:
unit- the unit of the delay.- Returns:
- a created
ExponentialDelay.
-
exponential
Creates a newExponentialDelaywith custom upper boundary and default factor (eg. with upper 8: 1, 2, 4, 8, 8, 8...).- Parameters:
unit- the unit of the delay.upper- the upper boundary.- Returns:
- a created
ExponentialDelay.
-
exponential
Creates a newExponentialDelaywith custom boundaries and default factor (eg. with upper 8, lower 3: 3, 3, 4, 8, 8, 8...).- Parameters:
unit- the unit of the delay.upper- the upper boundary.lower- the lower boundary.- Returns:
- a created
ExponentialDelay.
-
exponential
Creates a newExponentialDelaywith custom boundaries and factor (eg. with upper 300, lower 0, growBy 10: 10, 20, 40, 80, 160, 300, ...).- Parameters:
unit- the unit of the delay.upper- the upper boundary.lower- the lower boundary.growBy- the multiplication factor.- Returns:
- a created
ExponentialDelay.
-
exponential
Creates a newExponentialDelayon a base different from powers of two, with custom boundaries and factor (eg. with upper 9000, lower 0, growBy 3, powerOf 10: 3, 30, 300, 3000, 9000, 9000, 9000, ...).- Parameters:
unit- the unit of the delay.upper- the upper boundary.lower- the lower boundary.growBy- the multiplication factor (or basis for the size of each delay).powersOf- the base for exponential growth (eg. powers of 2, powers of 10, etc...)- Returns:
- a created
ExponentialDelay.
-