Class TimedReconnectStrategy

  • All Implemented Interfaces:
    ReconnectStrategy

    @Deprecated
    public final class TimedReconnectStrategy
    extends Object
    implements ReconnectStrategy
    Deprecated.
    Swiss army knife equivalent for reconnect strategies. This class is thread-safe.

    This strategy continues to schedule reconnect attempts, each having to complete in a fixed time (connectTime).

    Initial sleep time is specified as minSleep. Each subsequent unsuccessful attempt multiplies this time by a constant factor (sleepFactor) -- this allows for either constant reconnect times (sleepFactor = 1), or various degrees of exponential back-off (sleepFactor > 1). Maximum sleep time between attempts can be capped to a specific value (maxSleep).

    The strategy can optionally give up based on two criteria:

    A preset number of connection retries (maxAttempts) has been reached, or

    A preset absolute deadline is reached (deadline nanoseconds, as reported by System.nanoTime(). In this specific case, both connectTime and maxSleep will be controlled such that the connection attempt is resolved as closely to the deadline as possible.

    Both these caps can be combined, with the strategy giving up as soon as the first one is reached.

    • Constructor Detail

      • TimedReconnectStrategy

        public TimedReconnectStrategy​(io.netty.util.concurrent.EventExecutor executor,
                                      int connectTime,
                                      long minSleep,
                                      double sleepFactor,
                                      Long maxSleep,
                                      Long maxAttempts,
                                      Long deadline)
        Deprecated.
    • Method Detail

      • scheduleReconnect

        public io.netty.util.concurrent.Future<Void> scheduleReconnect​(Throwable cause)
        Deprecated.
        Description copied from interface: ReconnectStrategy
        Schedule a connection attempt. The precise time when the connection should be attempted is signaled by successful completion of returned future.
        Specified by:
        scheduleReconnect in interface ReconnectStrategy
        Parameters:
        cause - Cause of previous failure
        Returns:
        a future tracking the schedule, may not be null
      • reconnectSuccessful

        public void reconnectSuccessful()
        Deprecated.
        Description copied from interface: ReconnectStrategy
        Reset the strategy state. Users call this method once the reconnection process succeeds.
        Specified by:
        reconnectSuccessful in interface ReconnectStrategy