Class ExponentialBackoffStrategy

java.lang.Object
com.ultikits.ultitools.websocket.ExponentialBackoffStrategy
All Implemented Interfaces:
ReconnectStrategy

@Deprecated(since="6.3.1", forRemoval=true) public class ExponentialBackoffStrategy extends Object implements ReconnectStrategy
Deprecated, for removal: This API element is subject to removal in a future version.
There is no replacement: the framework's own UltiCloud session (protocol 2.0.0) paces its reconnects itself. Removed in 6.4.0.
Exponential backoff reconnection strategy. Delays increase exponentially: 5s, 10s, 20s, 40s... up to max 5 minutes.

As of 6.3.1 nothing in the framework uses it: it paced the protocol v1 reconnect loop, and the protocol 2.0.0 session schedules its own reconnects. It still computes delays as before.

Since:
6.2.0
Version:
1.0.0
Author:
wisdomme
Scheduled removal version:
6.4.0
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Deprecated, for removal: This API element is subject to removal in a future version.
    There is no replacement, as for ExponentialBackoffStrategy.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private int
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    static final long
    Deprecated, for removal: This API element is subject to removal in a future version.
    Initial delay in milliseconds (5 seconds).
    static final int
    Deprecated, for removal: This API element is subject to removal in a future version.
    Default maximum number of attempts (0 = unlimited).
    static final long
    Deprecated, for removal: This API element is subject to removal in a future version.
    Maximum delay in milliseconds (5 minutes).
    static final double
    Deprecated, for removal: This API element is subject to removal in a future version.
    Default multiplier for exponential growth.
    private final long
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    private final int
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    private final long
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    private final double
    Deprecated, for removal: This API element is subject to removal in a future version.
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Deprecated, for removal: This API element is subject to removal in a future version.
    Creates a strategy with default settings.
    ExponentialBackoffStrategy(long initialDelay, long maxDelay, double multiplier, int maxAttempts)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Creates a strategy with custom settings.
  • Method Summary

    Modifier and Type
    Method
    Description
    Deprecated, for removal: This API element is subject to removal in a future version.
    Creates a builder for custom configuration.
    int
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets the current attempt count.
    long
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets the delay in milliseconds before the next reconnection attempt.
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Resets the strategy state (called on successful connection).
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    Checks if reconnection should continue.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Creates a strategy that tries forever with default backoff.
    withMaxAttempts(int maxAttempts)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Creates a strategy with limited attempts.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_INITIAL_DELAY

      public static final long DEFAULT_INITIAL_DELAY
      Deprecated, for removal: This API element is subject to removal in a future version.
      Initial delay in milliseconds (5 seconds).
      See Also:
    • DEFAULT_MAX_DELAY

      public static final long DEFAULT_MAX_DELAY
      Deprecated, for removal: This API element is subject to removal in a future version.
      Maximum delay in milliseconds (5 minutes).
      See Also:
    • DEFAULT_MULTIPLIER

      public static final double DEFAULT_MULTIPLIER
      Deprecated, for removal: This API element is subject to removal in a future version.
      Default multiplier for exponential growth.
      See Also:
    • DEFAULT_MAX_ATTEMPTS

      public static final int DEFAULT_MAX_ATTEMPTS
      Deprecated, for removal: This API element is subject to removal in a future version.
      Default maximum number of attempts (0 = unlimited).
      See Also:
    • initialDelay

      private final long initialDelay
      Deprecated, for removal: This API element is subject to removal in a future version.
    • maxDelay

      private final long maxDelay
      Deprecated, for removal: This API element is subject to removal in a future version.
    • multiplier

      private final double multiplier
      Deprecated, for removal: This API element is subject to removal in a future version.
    • maxAttempts

      private final int maxAttempts
      Deprecated, for removal: This API element is subject to removal in a future version.
    • attemptCount

      private int attemptCount
      Deprecated, for removal: This API element is subject to removal in a future version.
  • Constructor Details

    • ExponentialBackoffStrategy

      public ExponentialBackoffStrategy()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates a strategy with default settings.
    • ExponentialBackoffStrategy

      public ExponentialBackoffStrategy(long initialDelay, long maxDelay, double multiplier, int maxAttempts)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates a strategy with custom settings.
      Parameters:
      initialDelay - initial delay in milliseconds
      maxDelay - maximum delay in milliseconds
      multiplier - multiplier for exponential growth
      maxAttempts - maximum attempts (0 for unlimited)
  • Method Details

    • getNextDelay

      public long getNextDelay()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: ReconnectStrategy
      Gets the delay in milliseconds before the next reconnection attempt.
      Specified by:
      getNextDelay in interface ReconnectStrategy
      Returns:
      the delay in milliseconds
    • reset

      public void reset()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: ReconnectStrategy
      Resets the strategy state (called on successful connection).
      Specified by:
      reset in interface ReconnectStrategy
    • getAttemptCount

      public int getAttemptCount()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: ReconnectStrategy
      Gets the current attempt count.
      Specified by:
      getAttemptCount in interface ReconnectStrategy
      Returns:
      the number of attempts made
    • shouldContinue

      public boolean shouldContinue()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: ReconnectStrategy
      Checks if reconnection should continue.
      Specified by:
      shouldContinue in interface ReconnectStrategy
      Returns:
      true if more reconnection attempts should be made
    • unlimited

      public static ExponentialBackoffStrategy unlimited()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates a strategy that tries forever with default backoff.
      Returns:
      an unlimited retry strategy
    • withMaxAttempts

      public static ExponentialBackoffStrategy withMaxAttempts(int maxAttempts)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates a strategy with limited attempts.
      Parameters:
      maxAttempts - the maximum number of attempts
      Returns:
      a limited retry strategy
    • builder

      public static ExponentialBackoffStrategy.Builder builder()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates a builder for custom configuration.
      Returns:
      a new builder