Class MockBackOff
java.lang.Object
com.google.api.client.testing.util.MockBackOff
- All Implemented Interfaces:
BackOff
- Since:
- 1.15
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate long
Fixed back-off milliseconds.private int
Maximum number of tries before returningBackOff.STOP
.private int
Number of tries so far.Fields inherited from interface com.google.api.client.util.BackOff
STOP, STOP_BACKOFF, ZERO_BACKOFF
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal int
Returns the maximum number of tries before returningBackOff.STOP
.final int
Returns the number of tries so far.long
Gets the number of milliseconds to wait before retrying the operation orBackOff.STOP
to indicate that no retries should be made.void
reset()
Reset to initial state.setBackOffMillis
(long backOffMillis) Sets the fixed back-off milliseconds (defaults to0
).setMaxTries
(int maxTries) Sets the maximum number of tries before returningBackOff.STOP
(defaults to10
).
-
Field Details
-
backOffMillis
private long backOffMillisFixed back-off milliseconds. -
maxTries
private int maxTriesMaximum number of tries before returningBackOff.STOP
. -
numTries
private int numTriesNumber of tries so far.
-
-
Constructor Details
-
MockBackOff
public MockBackOff()
-
-
Method Details
-
reset
Description copied from interface:BackOff
Reset to initial state.- Specified by:
reset
in interfaceBackOff
- Throws:
IOException
-
nextBackOffMillis
Description copied from interface:BackOff
Gets the number of milliseconds to wait before retrying the operation orBackOff.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 }
- Specified by:
nextBackOffMillis
in interfaceBackOff
- Throws:
IOException
-
setBackOffMillis
Sets the fixed back-off milliseconds (defaults to0
).Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
-
setMaxTries
Sets the maximum number of tries before returningBackOff.STOP
(defaults to10
).Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
-
getMaxTries
public final int getMaxTries()Returns the maximum number of tries before returningBackOff.STOP
. -
getNumberOfTries
public final int getNumberOfTries()Returns the number of tries so far.
-