com.google.api.client.http
Class ExponentialBackOffPolicy.Builder

java.lang.Object
  extended by com.google.api.client.http.ExponentialBackOffPolicy.Builder
Enclosing class:
ExponentialBackOffPolicy

public static class ExponentialBackOffPolicy.Builder
extends Object

Builder for ExponentialBackOffPolicy.

Implementation is not thread-safe.

Since:
1.7

Constructor Summary
protected ExponentialBackOffPolicy.Builder()
           
 
Method Summary
 ExponentialBackOffPolicy build()
          Builds a new instance of ExponentialBackOffPolicy.
 int getInitialIntervalMillis()
          Returns the initial retry interval in milliseconds.
 int getMaxElapsedTimeMillis()
          Returns the maximum elapsed time in milliseconds.
 int getMaxIntervalMillis()
          Returns the maximum value of the back off period in milliseconds.
 double getMultiplier()
          Returns the value to multiply the current interval with for each retry attempt.
 double getRandomizationFactor()
          Returns the randomization factor to use for creating a range around the retry interval.
 ExponentialBackOffPolicy.Builder setInitialIntervalMillis(int initialIntervalMillis)
          Sets the initial retry interval in milliseconds.
 ExponentialBackOffPolicy.Builder setMaxElapsedTimeMillis(int maxElapsedTimeMillis)
          Sets the maximum elapsed time in milliseconds.
 ExponentialBackOffPolicy.Builder setMaxIntervalMillis(int maxIntervalMillis)
          Sets the maximum value of the back off period in milliseconds.
 ExponentialBackOffPolicy.Builder setMultiplier(double multiplier)
          Sets the value to multiply the current interval with for each retry attempt.
 ExponentialBackOffPolicy.Builder setRandomizationFactor(double randomizationFactor)
          Sets the randomization factor to use for creating a range around the retry interval.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExponentialBackOffPolicy.Builder

protected ExponentialBackOffPolicy.Builder()
Method Detail

build

public ExponentialBackOffPolicy build()
Builds a new instance of ExponentialBackOffPolicy.


getInitialIntervalMillis

public final int getInitialIntervalMillis()
Returns the initial retry interval in milliseconds. The default value is ExponentialBackOffPolicy.DEFAULT_INITIAL_INTERVAL_MILLIS.


setInitialIntervalMillis

public ExponentialBackOffPolicy.Builder setInitialIntervalMillis(int initialIntervalMillis)
Sets the initial retry interval in milliseconds. The default value is ExponentialBackOffPolicy.DEFAULT_INITIAL_INTERVAL_MILLIS. Must be > 0.


getRandomizationFactor

public final double getRandomizationFactor()
Returns the randomization factor to use for creating a range around the retry interval. The default value is ExponentialBackOffPolicy.DEFAULT_RANDOMIZATION_FACTOR.

A randomization factor of 0.5 results in a random period ranging between 50% below and 50% above the retry interval.


setRandomizationFactor

public ExponentialBackOffPolicy.Builder setRandomizationFactor(double randomizationFactor)
Sets the randomization factor to use for creating a range around the retry interval. The default value is ExponentialBackOffPolicy.DEFAULT_RANDOMIZATION_FACTOR. Must fall in the range 0 <= randomizationFactor < 1.

A randomization factor of 0.5 results in a random period ranging between 50% below and 50% above the retry interval.


getMultiplier

public final double getMultiplier()
Returns the value to multiply the current interval with for each retry attempt. The default value is ExponentialBackOffPolicy.DEFAULT_MULTIPLIER.


setMultiplier

public ExponentialBackOffPolicy.Builder setMultiplier(double multiplier)
Sets the value to multiply the current interval with for each retry attempt. The default value is ExponentialBackOffPolicy.DEFAULT_MULTIPLIER. Must be >= 1.


getMaxIntervalMillis

public final int getMaxIntervalMillis()
Returns the maximum value of the back off period in milliseconds. Once the current interval reaches this value it stops increasing. The default value is ExponentialBackOffPolicy.DEFAULT_MAX_INTERVAL_MILLIS. Must be >= initialInterval.


setMaxIntervalMillis

public ExponentialBackOffPolicy.Builder setMaxIntervalMillis(int maxIntervalMillis)
Sets the maximum value of the back off period in milliseconds. Once the current interval reaches this value it stops increasing. The default value is ExponentialBackOffPolicy.DEFAULT_MAX_INTERVAL_MILLIS.


getMaxElapsedTimeMillis

public final int getMaxElapsedTimeMillis()
Returns the maximum elapsed time in milliseconds. The default value is ExponentialBackOffPolicy.DEFAULT_MAX_ELAPSED_TIME_MILLIS.

If the time elapsed since an ExponentialBackOffPolicy instance is created goes past the max_elapsed_time then the method ExponentialBackOffPolicy.getNextBackOffMillis() starts returning BackOffPolicy.STOP. The elapsed time can be reset by calling ExponentialBackOffPolicy.reset().


setMaxElapsedTimeMillis

public ExponentialBackOffPolicy.Builder setMaxElapsedTimeMillis(int maxElapsedTimeMillis)
Sets the maximum elapsed time in milliseconds. The default value is ExponentialBackOffPolicy.DEFAULT_MAX_ELAPSED_TIME_MILLIS. Must be > 0.

If the time elapsed since an ExponentialBackOffPolicy instance is created goes past the max_elapsed_time then the method ExponentialBackOffPolicy.getNextBackOffMillis() starts returning BackOffPolicy.STOP. The elapsed time can be reset by calling ExponentialBackOffPolicy.reset().



Copyright © 2011-2012 Google. All Rights Reserved.