Class ExponentialReconnectionPolicy
- java.lang.Object
-
- 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
Constructors Constructor Description ExponentialReconnectionPolicy(long baseDelayMs, long maxDelayMs)Creates a reconnection policy waiting exponentially longer for each new attempt.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Gets invoked at cluster shutdown.longgetBaseDelayMs()The base delay in milliseconds for this policy (e.g. the delay before the first reconnection attempt).longgetMaxDelayMs()The maximum delay in milliseconds between reconnection attempts for this policy.voidinit(Cluster cluster)Gets invoked at cluster startup.ReconnectionPolicy.ReconnectionSchedulenewSchedule()A new schedule that used an exponentially growing delay between reconnection attempts.
-
-
-
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
iwill be triedMath.min(2^(i-1) * getBaseDelayMs(), getMaxDelayMs())milliseconds after the previous one.- Specified by:
newSchedulein interfaceReconnectionPolicy- Returns:
- the newly created schedule.
-
init
public void init(Cluster cluster)
Description copied from interface:ReconnectionPolicyGets invoked at cluster startup.- Specified by:
initin interfaceReconnectionPolicy- Parameters:
cluster- the cluster that this policy is associated with.
-
close
public void close()
Description copied from interface:ReconnectionPolicyGets invoked at cluster shutdown.This gives the policy the opportunity to perform some cleanup, for instance stop threads that it might have started.
- Specified by:
closein interfaceReconnectionPolicy
-
-