Class MockBackOff
- java.lang.Object
-
- com.google.api.client.testing.util.MockBackOff
-
-
Field Summary
-
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).
-
-
-
Method Detail
-
reset
public void reset() throws IOExceptionDescription copied from interface:BackOffReset to initial state.- Specified by:
resetin interfaceBackOff- Throws:
IOException
-
nextBackOffMillis
public long nextBackOffMillis() throws 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:
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.
-
-