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()
For this schedule, reconnection attempt i
will be tried Math.min(2^(i-1) *
getBaseDelayMs(), getMaxDelayMs())
milliseconds after the previous one.
newSchedule
in interface ReconnectionPolicy
public void init(Cluster cluster)
ReconnectionPolicy
init
in interface ReconnectionPolicy
cluster
- the cluster that this policy is associated with.public void close()
ReconnectionPolicy
This gives the policy the opportunity to perform some cleanup, for instance stop threads that it might have started.
close
in interface ReconnectionPolicy
Copyright © 2012–2020. All rights reserved.