yass.backoff
Class GeometricProgressionBackoffManager

java.lang.Object
  extended by yass.backoff.BackoffManager
      extended by yass.backoff.GeometricProgressionBackoffManager
All Implemented Interfaces:
Advanceable

public class GeometricProgressionBackoffManager
extends BackoffManager

Backoff manager in which the sequence of backoff periods forms a geometric progression. This class generates similar behaviour to that of ExponentialBackoffManager but with a different style of parameterisation which may be more convenient under some circumstances.


Nested Class Summary
 
Nested classes/interfaces inherited from class yass.backoff.BackoffManager
BackoffManager.BackoffState
 
Field Summary
protected  int backoffCycleLimit
          The maximum permitted number of backoff cycles before timeout
protected  double ratio
          The ratio by which the previous backoff period is multiplied to find the next backoff period
 
Fields inherited from class yass.backoff.BackoffManager
backoffCyclesCompleted, currentBackoffPeriod, currentBackoffRemaining, initialBackoffPeriod, nextBackoffPeriod, state
 
Constructor Summary
GeometricProgressionBackoffManager(double initialBackoffPeriod, double ratio, int backoffCycleLimit)
          Creates a new instance of GeometricProgressionBackoffManager
 
Method Summary
 boolean attemptBackoff()
          Attempts to initiate a new backoff period, the duration of which is the next term in the geometric sequence
 BackoffManager clonePrototype()
          Obtains a new GeometricProgressionBackoffManager instance, using the called instance as a template instance
 int getBackoffCycleLimit()
          Obtains the maximum permitted number of backoff cycles before timeout
 double getRatio()
          Obtains the ratio by which adjacent terms in the geometric sequence of backoff times differ
 
Methods inherited from class yass.backoff.BackoffManager
advanceTime, checkBackoffStatePreconditions, getBackoffCyclesCompleted, getCurrentBackoffPeriod, getCurrentBackoffRemaining, getInitialBackoffPeriod, getNextBackoffPeriod, getState, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ratio

protected double ratio
The ratio by which the previous backoff period is multiplied to find the next backoff period


backoffCycleLimit

protected int backoffCycleLimit
The maximum permitted number of backoff cycles before timeout

Constructor Detail

GeometricProgressionBackoffManager

public GeometricProgressionBackoffManager(double initialBackoffPeriod,
                                          double ratio,
                                          int backoffCycleLimit)
Creates a new instance of GeometricProgressionBackoffManager

Parameters:
initialBackoffPeriod - the initial backoff period, in seconds
ratio - ratio by which adjacent terms in geometric sequence of backoff times differ
backoffCycleLimit - maximum permitted number of backoff cycles before timeout
Method Detail

clonePrototype

public BackoffManager clonePrototype()
Obtains a new GeometricProgressionBackoffManager instance, using the called instance as a template instance

Specified by:
clonePrototype in class BackoffManager
Returns:
the GeometricProgressionBackoffManager copy instance

attemptBackoff

public boolean attemptBackoff()
                       throws BackoffException
Attempts to initiate a new backoff period, the duration of which is the next term in the geometric sequence

Specified by:
attemptBackoff in class BackoffManager
Returns:
true if a new backoff period is permitted and has been initiated, otherwise false
Throws:
BackoffException - if called when the backoff manager is not currently in a READY state

getRatio

public double getRatio()
Obtains the ratio by which adjacent terms in the geometric sequence of backoff times differ

Returns:
the ratio by which adjacent terms in the geometric sequence of backoff times differ

getBackoffCycleLimit

public int getBackoffCycleLimit()
Obtains the maximum permitted number of backoff cycles before timeout

Returns:
the maximum permitted number of backoff cycles before timeout