Class MockBackOff
- java.lang.Object
-
- com.google.api.client.testing.util.MockBackOff
-
-
Field Summary
Fields Modifier and Type Field Description private long
backOffMillis
Fixed back-off milliseconds.private int
maxTries
Maximum number of tries before returningBackOff.STOP
.private int
numTries
Number of tries so far.-
Fields inherited from interface com.google.api.client.util.BackOff
STOP, STOP_BACKOFF, ZERO_BACKOFF
-
-
Constructor Summary
Constructors Constructor Description MockBackOff()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getMaxTries()
Returns the maximum number of tries before returningBackOff.STOP
.int
getNumberOfTries()
Returns the number of tries so far.long
nextBackOffMillis()
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.MockBackOff
setBackOffMillis(long backOffMillis)
Sets the fixed back-off milliseconds (defaults to0
).MockBackOff
setMaxTries(int maxTries)
Sets the maximum number of tries before returningBackOff.STOP
(defaults to10
).
-
-
-
Field Detail
-
backOffMillis
private long backOffMillis
Fixed back-off milliseconds.
-
maxTries
private int maxTries
Maximum number of tries before returningBackOff.STOP
.
-
numTries
private int numTries
Number of tries so far.
-
-
Method Detail
-
reset
public void reset() throws java.io.IOException
Description copied from interface:BackOff
Reset to initial state.
-
nextBackOffMillis
public long nextBackOffMillis() throws java.io.IOException
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:
java.io.IOException
-
setBackOffMillis
public MockBackOff setBackOffMillis(long backOffMillis)
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
public MockBackOff setMaxTries(int maxTries)
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.
-
-