Package com.castlabs.android.network
Class RetryConfiguration
java.lang.Object
com.castlabs.android.network.RetryConfiguration
- All Implemented Interfaces:
Parcelable
Configures the network request retry behaviour. When components of the player
perform network requests, and the request fails, for example the server responds
with a 404, the component that issues the request might decide to retry the request again
before a fatal error is raised. Instances of this class are used to configure how
often the component will retry and how much time the component will wait
between tries.
The delay between the tries will increase based on the
backoffFactor
. The delay for the first retry is defined as baseDelayMs
Every following retry delay is calculated as the previous retry delay
times the backoffFactor
. Hence we get
- Attempt 0 (first request) = 0 (no delay)
- Attempt 1 (first retry) = 1s (base delay)
- Attempt 2 (second retry) = (delay of attempt 1) * backoffFactor = 1s * 2 = 2s
- Attempt 3 (third retry) = (delay of attempt 2) * backoffFactor = 2s * 2 = 4s
- delay of 1 ± 50% (0.5 to 1.5)
- delay of 2 ± 50% (1 to 3)
- delay of 4 ± 50% (2 to 6)
You can create instances of this class either using the public constructor
RetryConfiguration(int, long, float, float, long, int[], String[])
or through the RetryConfiguration.Builder
.
- Since:
- 4.1.11
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Use this builder to create new instances of the retry configurationNested classes/interfaces inherited from interface android.os.Parcelable
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>
-
Field Summary
Modifier and TypeFieldDescriptionfinal float
The multiplication factor between retries applied after the first retryfinal long
The initial delay applied to the first retrystatic final Parcelable.Creator
<RetryConfiguration> static final float
The default backoff factor of 2static final int
The default base delay of 1 secondstatic final float
The default fuzzy factor of 0.5static final RetryConfiguration
Default retry parameters for Live playback.static final int
The default number of permitted attemptsstatic final int
The default maximum delay of 5 seconds.static final RetryConfiguration
Retry parameter configuration that does not permit any retriesstatic final RetryConfiguration
Default retry parameters for VOD playback.final float
The fuzzy factor applied to each retry delayfinal int
The maximum number of requests before the request will fail.final long
The upper bound for delays.Fields inherited from interface android.os.Parcelable
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE
-
Constructor Summary
ConstructorDescriptionRetryConfiguration
(int maxAttempts, long baseDelayMs, float backoffFactor, float fuzzFactor, long maxDelayMs) Create a new instance of the counterRetryConfiguration
(int maxAttempts, long baseDelayMs, float backoffFactor, float fuzzFactor, long maxDelayMs, int[] retryCodes, String[] retryExceptionNames) -
Method Summary
Modifier and TypeMethodDescriptionint
boolean
int
hashCode()
boolean
retryCode
(int code) Checks whether the provided code triggers retries or notboolean
retryException
(Exception exception) com.google.android.exoplayer2.upstream.RetryCounter
INTERNAL: Converts this configuration to the retry counter that will be used by the playervoid
writeToParcel
(Parcel dest, int flags)
-
Field Details
-
DEFAULT_MAX_ATTEMPTS
public static final int DEFAULT_MAX_ATTEMPTSThe default number of permitted attempts- See Also:
-
DEFAULT_BASE_DELAY_MS
public static final int DEFAULT_BASE_DELAY_MSThe default base delay of 1 second- See Also:
-
DEFAULT_FUZZY_FACTOR
public static final float DEFAULT_FUZZY_FACTORThe default fuzzy factor of 0.5- See Also:
-
DEFAULT_BACKOFF_FACTOR_MS
public static final float DEFAULT_BACKOFF_FACTOR_MSThe default backoff factor of 2- See Also:
-
DEFAULT_MAX_DELAY_MS
public static final int DEFAULT_MAX_DELAY_MSThe default maximum delay of 5 seconds.- See Also:
-
DEFAULT_NO_RETRIES_CONFIGURATION
Retry parameter configuration that does not permit any retries -
DEFAULT_VOD_CONFIGURATION
Default retry parameters for VOD playback. This uses all the default values and permits 3 attempts (2 retries) -
DEFAULT_LIVE_CONFIGURATION
Default retry parameters for Live playback. This uses all the default values and permits 6 attempts (5 retries) -
CREATOR
-
maxAttempts
public final int maxAttemptsThe maximum number of requests before the request will fail. A value of 1 will disable any retry attempts. -
baseDelayMs
public final long baseDelayMsThe initial delay applied to the first retry -
backoffFactor
public final float backoffFactorThe multiplication factor between retries applied after the first retry -
fuzzFactor
public final float fuzzFactorThe fuzzy factor applied to each retry delay -
maxDelayMs
public final long maxDelayMsThe upper bound for delays. The player will never delay a retry longer than this value.
-
-
Constructor Details
-
RetryConfiguration
public RetryConfiguration(int maxAttempts, long baseDelayMs, float backoffFactor, float fuzzFactor, long maxDelayMs) Create a new instance of the counter- Parameters:
maxAttempts
- The maximum number of requests before the request will fail. A value of 1 will disable any retry attempts.baseDelayMs
- The initial delay applied to the first retrybackoffFactor
- The multiplication factor between retries applied after the first retryfuzzFactor
- The fuzzy factor applied to each retry delaymaxDelayMs
- The upper bound for delays. The player will never delay a retry longer than this value.
-
RetryConfiguration
public RetryConfiguration(int maxAttempts, long baseDelayMs, float backoffFactor, float fuzzFactor, long maxDelayMs, @Nullable int[] retryCodes, @Nullable String[] retryExceptionNames)
-
-
Method Details
-
describeContents
public int describeContents()- Specified by:
describeContents
in interfaceParcelable
-
writeToParcel
- Specified by:
writeToParcel
in interfaceParcelable
-
hashCode
public int hashCode() -
equals
-
toCounter
public com.google.android.exoplayer2.upstream.RetryCounter toCounter()INTERNAL: Converts this configuration to the retry counter that will be used by the player- Returns:
- The retry counter
-
retryCode
public boolean retryCode(int code) Checks whether the provided code triggers retries or not- Parameters:
code
- The code- Returns:
true
in case the retry will be triggered andfalse
otherwise
-
retryException
-