Interface ReconnectionPolicy
-
- All Superinterfaces:
AutoCloseable
public interface ReconnectionPolicy extends AutoCloseable
Decides how often the driver tries to re-establish lost connections.When a reconnection starts, the driver invokes this policy to create a
ReconnectionScheduleinstance. That schedule'snextDelay()method will get called each time the driver needs to program the next connection attempt. When the reconnection succeeds, the schedule is discarded; if the connection is lost again later, the next reconnection attempt will query the policy again to obtain a new schedule.There are two types of reconnection:
- for regular node connections: when the connection pool
for a node does not have its configured number of connections (see
advanced.connection.pool.*.sizein the configuration), a reconnection starts for that pool. - for the control connection: when the
control node goes down, a reconnection starts to find another node to replace it. This is
also used if the configuration option
advanced.reconnect-on-initis set and the driver has to retry the initial connection.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceReconnectionPolicy.ReconnectionScheduleThe reconnection schedule from the time a connection is lost, to the time all connections to this node have been restored.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclose()Called when the cluster that this policy is associated with closes.ReconnectionPolicy.ReconnectionSchedulenewControlConnectionSchedule(boolean isInitialConnection)Creates a new schedule for the control connection.ReconnectionPolicy.ReconnectionSchedulenewNodeSchedule(Node node)Creates a new schedule for the given node.
-
-
-
Method Detail
-
newNodeSchedule
@NonNull ReconnectionPolicy.ReconnectionSchedule newNodeSchedule(@NonNull Node node)
Creates a new schedule for the given node.
-
newControlConnectionSchedule
@NonNull ReconnectionPolicy.ReconnectionSchedule newControlConnectionSchedule(boolean isInitialConnection)
Creates a new schedule for the control connection.- Parameters:
isInitialConnection- whether this schedule is generated for the driver's initial attempt to connect to the cluster.truemeans that the configuration optionadvanced.reconnect-on-initis set, the driver failed to reach any contact point, and it is now scheduling reattempts.falsemeans that the driver was already initialized, lost connection to the control node, and is now scheduling attempts to connect to another node.
-
close
void close()
Called when the cluster that this policy is associated with closes.- Specified by:
closein interfaceAutoCloseable
-
-