com.datastax.driver.core.policies
Class ExponentialReconnectionPolicy

java.lang.Object
  extended by com.datastax.driver.core.policies.ExponentialReconnectionPolicy
All Implemented Interfaces:
ReconnectionPolicy

public class ExponentialReconnectionPolicy
extends Object
implements ReconnectionPolicy

A reconnection policy that waits exponentially longer between each reconnection attempt (but keeps a constant delay once a maximum delay is reached).


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.datastax.driver.core.policies.ReconnectionPolicy
ReconnectionPolicy.ReconnectionSchedule
 
Constructor Summary
ExponentialReconnectionPolicy(long baseDelayMs, long maxDelayMs)
          Creates a reconnection policy waiting exponentially longer for each new attempt.
 
Method Summary
 long getBaseDelayMs()
          The base delay in milliseconds for this policy (e.g.
 long getMaxDelayMs()
          The maximum delay in milliseconds between reconnection attempts for this policy.
 ReconnectionPolicy.ReconnectionSchedule newSchedule()
          A new schedule that used an exponentially growing delay between reconnection attempts.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExponentialReconnectionPolicy

public ExponentialReconnectionPolicy(long baseDelayMs,
                                     long maxDelayMs)
Creates a reconnection policy waiting exponentially longer for each new attempt.

Parameters:
baseDelayMs - the base delay in milliseconds to use for the schedules created by this policy.
maxDelayMs - the maximum delay to wait between two attempts.
Method Detail

getBaseDelayMs

public long getBaseDelayMs()
The base delay in milliseconds for this policy (e.g. the delay before the first reconnection attempt).

Returns:
the base delay in milliseconds for this policy.

getMaxDelayMs

public long getMaxDelayMs()
The maximum delay in milliseconds between reconnection attempts for this policy.

Returns:
the maximum delay in milliseconds between reconnection attempts for this policy.

newSchedule

public ReconnectionPolicy.ReconnectionSchedule newSchedule()
A new schedule that used an exponentially growing delay between reconnection attempts.

For this schedule, reconnection attempt i will be tried Math.min(2^(i-1) * getBaseDelayMs(), getMaxDelayMs()) milliseconds after the previous one.

Specified by:
newSchedule in interface ReconnectionPolicy
Returns:
the newly created schedule.


Copyright © 2013. All Rights Reserved.