Class MockBackOff (1.43.0)

public class MockBackOff implements BackOff

Beta
Mock for BackOff that always returns a fixed number.

Implementation is not thread-safe.

Inheritance

java.lang.Object > MockBackOff

Implements

BackOff

Constructors

MockBackOff()

public MockBackOff()

Methods

getMaxTries()

public final int getMaxTries()

Returns the maximum number of tries before returning #STOP.

Returns
TypeDescription
int

getNumberOfTries()

public final int getNumberOfTries()

Returns the number of tries so far.

Returns
TypeDescription
int

nextBackOffMillis()

public long nextBackOffMillis()

Gets the number of milliseconds to wait before retrying the operation or #STOP to indicate that no retries should be made.

Example usage:

long backOffMillis = backoff.nextBackOffMillis(); if (backOffMillis == Backoff.STOP) { // do not retry operation } else { // sleep for backOffMillis milliseconds and retry operation }

Returns
TypeDescription
long
Exceptions
TypeDescription
IOException

reset()

public void reset()

Reset to initial state.

Exceptions
TypeDescription
IOException

setBackOffMillis(long backOffMillis)

public MockBackOff setBackOffMillis(long backOffMillis)

Sets the fixed back-off milliseconds (defaults to 0).

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.

Parameter
NameDescription
backOffMillislong
Returns
TypeDescription
MockBackOff

setMaxTries(int maxTries)

public MockBackOff setMaxTries(int maxTries)

Sets the maximum number of tries before returning #STOP (defaults to 10).

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.

Parameter
NameDescription
maxTriesint
Returns
TypeDescription
MockBackOff