public class ExponentialReconnectionPolicy extends Object implements ReconnectionPolicy
ReconnectionPolicy.ReconnectionSchedule| Constructor and Description |
|---|
ExponentialReconnectionPolicy(long baseDelayMs,
long maxDelayMs)
Creates a reconnection policy waiting exponentially longer for each new attempt.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Gets invoked at cluster shutdown.
|
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.
|
void |
init(Cluster cluster)
Gets invoked at cluster startup.
|
ReconnectionPolicy.ReconnectionSchedule |
newSchedule()
A new schedule that used an exponentially growing delay between reconnection attempts.
|
public ExponentialReconnectionPolicy(long baseDelayMs,
long maxDelayMs)
baseDelayMs - the base delay in milliseconds to use for
the schedules created by this policy.maxDelayMs - the maximum delay to wait between two attempts.public long getBaseDelayMs()
public long getMaxDelayMs()
public ReconnectionPolicy.ReconnectionSchedule newSchedule()
i will be tried
Math.min(2^(i-1) * getBaseDelayMs(), getMaxDelayMs()) milliseconds after the previous one.newSchedule in interface ReconnectionPolicypublic void init(Cluster cluster)
ReconnectionPolicyinit in interface ReconnectionPolicycluster - the cluster that this policy is associated with.public void close()
ReconnectionPolicyclose in interface ReconnectionPolicyCopyright © 2012–2018. All rights reserved.