Package com.ultikits.ultitools.websocket
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 ClassesModifier and TypeClassDescriptionstatic classDeprecated, for removal: This API element is subject to removal in a future version.There is no replacement, as forExponentialBackoffStrategy. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intDeprecated, for removal: This API element is subject to removal in a future version.static final longDeprecated, for removal: This API element is subject to removal in a future version.Initial delay in milliseconds (5 seconds).static final intDeprecated, for removal: This API element is subject to removal in a future version.Default maximum number of attempts (0 = unlimited).static final longDeprecated, for removal: This API element is subject to removal in a future version.Maximum delay in milliseconds (5 minutes).static final doubleDeprecated, for removal: This API element is subject to removal in a future version.Default multiplier for exponential growth.private final longDeprecated, for removal: This API element is subject to removal in a future version.private final intDeprecated, for removal: This API element is subject to removal in a future version.private final longDeprecated, for removal: This API element is subject to removal in a future version.private final doubleDeprecated, for removal: This API element is subject to removal in a future version. -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated, 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 TypeMethodDescriptionbuilder()Deprecated, for removal: This API element is subject to removal in a future version.Creates a builder for custom configuration.intDeprecated, for removal: This API element is subject to removal in a future version.Gets the current attempt count.longDeprecated, for removal: This API element is subject to removal in a future version.Gets the delay in milliseconds before the next reconnection attempt.voidreset()Deprecated, for removal: This API element is subject to removal in a future version.Resets the strategy state (called on successful connection).booleanDeprecated, for removal: This API element is subject to removal in a future version.Checks if reconnection should continue.static ExponentialBackoffStrategyDeprecated, for removal: This API element is subject to removal in a future version.Creates a strategy that tries forever with default backoff.static ExponentialBackoffStrategywithMaxAttempts(int maxAttempts) Deprecated, for removal: This API element is subject to removal in a future version.Creates a strategy with limited attempts.
-
Field Details
-
DEFAULT_INITIAL_DELAY
public static final long DEFAULT_INITIAL_DELAYDeprecated, 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_DELAYDeprecated, 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_MULTIPLIERDeprecated, 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_ATTEMPTSDeprecated, 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 initialDelayDeprecated, for removal: This API element is subject to removal in a future version. -
maxDelay
private final long maxDelayDeprecated, for removal: This API element is subject to removal in a future version. -
multiplier
private final double multiplierDeprecated, for removal: This API element is subject to removal in a future version. -
maxAttempts
private final int maxAttemptsDeprecated, for removal: This API element is subject to removal in a future version. -
attemptCount
private int attemptCountDeprecated, 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 millisecondsmaxDelay- maximum delay in millisecondsmultiplier- multiplier for exponential growthmaxAttempts- 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:ReconnectStrategyGets the delay in milliseconds before the next reconnection attempt.- Specified by:
getNextDelayin interfaceReconnectStrategy- 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:ReconnectStrategyResets the strategy state (called on successful connection).- Specified by:
resetin interfaceReconnectStrategy
-
getAttemptCount
public int getAttemptCount()Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:ReconnectStrategyGets the current attempt count.- Specified by:
getAttemptCountin interfaceReconnectStrategy- 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:ReconnectStrategyChecks if reconnection should continue.- Specified by:
shouldContinuein interfaceReconnectStrategy- Returns:
- true if more reconnection attempts should be made
-
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
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
Deprecated, for removal: This API element is subject to removal in a future version.Creates a builder for custom configuration.- Returns:
- a new builder
-