Class MockBackOff
java.lang.Object
com.google.api.client.testing.util.MockBackOff
- All Implemented Interfaces:
BackOff
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate longFixed back-off milliseconds.private intMaximum number of tries before returningBackOff.STOP.private intNumber of tries so far.Fields inherited from interface BackOff
STOP, STOP_BACKOFF, ZERO_BACKOFF -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal intReturns the maximum number of tries before returningBackOff.STOP.final intReturns the number of tries so far.longGets the number of milliseconds to wait before retrying the operation orBackOff.STOPto indicate that no retries should be made.voidreset()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:BackOffReset to initial state.- Specified by:
resetin interfaceBackOff- Throws:
IOException
-
nextBackOffMillis
Description 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
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.
-