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 ReconnectionSchedule instance. That schedule's nextDelay() 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.*.size in 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-init is set and the driver has to retry the initial connection.
    This interface defines separate methods for those two cases, but implementations are free to delegate to the same method internally if the same type of schedule can be used.
    • Method Detail

      • 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.
        • true means that the configuration option advanced.reconnect-on-init is set, the driver failed to reach any contact point, and it is now scheduling reattempts.
        • false means 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:
        close in interface AutoCloseable