Class MockBackOff
- java.lang.Object
-
- com.google.api.client.testing.util.MockBackOff
-
-
Field Summary
Fields Modifier and Type Field Description private longbackOffMillisFixed back-off milliseconds.private intmaxTriesMaximum number of tries before returningBackOff.STOP.private intnumTriesNumber 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 intgetMaxTries()Returns the maximum number of tries before returningBackOff.STOP.intgetNumberOfTries()Returns the number of tries so far.longnextBackOffMillis()Gets the number of milliseconds to wait before retrying the operation orBackOff.STOPto indicate that no retries should be made.voidreset()Reset to initial state.MockBackOffsetBackOffMillis(long backOffMillis)Sets the fixed back-off milliseconds (defaults to0).MockBackOffsetMaxTries(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.IOExceptionDescription copied from interface:BackOffReset to initial state.
-
nextBackOffMillis
public long nextBackOffMillis() throws java.io.IOExceptionDescription copied from interface:BackOffGets the number of milliseconds to wait before retrying the operation orBackOff.STOPto 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:
nextBackOffMillisin 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.
-
-