Package com.castlabs.android.network
Class RetryConfiguration
- java.lang.Object
-
- com.castlabs.android.network.RetryConfiguration
-
- All Implemented Interfaces:
Parcelable
public class RetryConfiguration extends Object implements 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 asbaseDelayMs
Every following retry delay is calculated as the previous retry delay times thebackoffFactor
. 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 theRetryConfiguration.Builder
.- Since:
- 4.1.11
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RetryConfiguration.Builder
Use this builder to create new instances of the retry configuration-
Nested classes/interfaces inherited from interface android.os.Parcelable
Parcelable.ClassLoaderCreator<T extends Object>, Parcelable.Creator<T extends Object>
-
-
Field Summary
Fields Modifier and Type Field Description float
backoffFactor
The multiplication factor between retries applied after the first retrylong
baseDelayMs
The initial delay applied to the first retrystatic Parcelable.Creator<RetryConfiguration>
CREATOR
static float
DEFAULT_BACKOFF_FACTOR_MS
The default backoff factor of 2static int
DEFAULT_BASE_DELAY_MS
The default base delay of 1 secondstatic float
DEFAULT_FUZZY_FACTOR
The default fuzzy factor of 0.5static RetryConfiguration
DEFAULT_LIVE_CONFIGURATION
Default retry parameters for Live playback.static int
DEFAULT_MAX_ATTEMPTS
The default number of permitted attemptsstatic int
DEFAULT_MAX_DELAY_MS
The default maximum delay of 5 seconds.static RetryConfiguration
DEFAULT_NO_RETRIES_CONFIGURATION
Retry parameter configuration that does not permit any retriesstatic RetryConfiguration
DEFAULT_VOD_CONFIGURATION
Default retry parameters for VOD playback.float
fuzzFactor
The fuzzy factor applied to each retry delayint
maxAttempts
The maximum number of requests before the request will fail.long
maxDelayMs
The upper bound for delays.-
Fields inherited from interface android.os.Parcelable
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE
-
-
Constructor Summary
Constructors Constructor Description RetryConfiguration(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
describeContents()
boolean
equals(Object obj)
int
hashCode()
boolean
retryCode(int code)
Checks whether the provided code triggers retries or notboolean
retryException(Exception exception)
com.google.android.exoplayer2.upstream.RetryCounter
toCounter()
INTERNAL: Converts this configuration to the retry counter that will be used by the playervoid
writeToParcel(Parcel dest, int flags)
-
-
-
Field Detail
-
DEFAULT_MAX_ATTEMPTS
public static final int DEFAULT_MAX_ATTEMPTS
The default number of permitted attempts- See Also:
- Constant Field Values
-
DEFAULT_BASE_DELAY_MS
public static final int DEFAULT_BASE_DELAY_MS
The default base delay of 1 second- See Also:
- Constant Field Values
-
DEFAULT_FUZZY_FACTOR
public static final float DEFAULT_FUZZY_FACTOR
The default fuzzy factor of 0.5- See Also:
- Constant Field Values
-
DEFAULT_BACKOFF_FACTOR_MS
public static final float DEFAULT_BACKOFF_FACTOR_MS
The default backoff factor of 2- See Also:
- Constant Field Values
-
DEFAULT_MAX_DELAY_MS
public static final int DEFAULT_MAX_DELAY_MS
The default maximum delay of 5 seconds.- See Also:
- Constant Field Values
-
DEFAULT_NO_RETRIES_CONFIGURATION
public static final RetryConfiguration DEFAULT_NO_RETRIES_CONFIGURATION
Retry parameter configuration that does not permit any retries
-
DEFAULT_VOD_CONFIGURATION
public static final RetryConfiguration DEFAULT_VOD_CONFIGURATION
Default retry parameters for VOD playback. This uses all the default values and permits 3 attempts (2 retries)
-
DEFAULT_LIVE_CONFIGURATION
public static final RetryConfiguration DEFAULT_LIVE_CONFIGURATION
Default retry parameters for Live playback. This uses all the default values and permits 6 attempts (5 retries)
-
CREATOR
public static final Parcelable.Creator<RetryConfiguration> CREATOR
-
maxAttempts
public final int maxAttempts
The maximum number of requests before the request will fail. A value of 1 will disable any retry attempts.
-
baseDelayMs
public final long baseDelayMs
The initial delay applied to the first retry
-
backoffFactor
public final float backoffFactor
The multiplication factor between retries applied after the first retry
-
fuzzFactor
public final float fuzzFactor
The fuzzy factor applied to each retry delay
-
maxDelayMs
public final long maxDelayMs
The upper bound for delays. The player will never delay a retry longer than this value.
-
-
Constructor Detail
-
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 Detail
-
describeContents
public int describeContents()
- Specified by:
describeContents
in interfaceParcelable
-
writeToParcel
public void writeToParcel(Parcel dest, int flags)
- Specified by:
writeToParcel
in interfaceParcelable
-
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
public boolean retryException(@NonNull Exception exception)
-
-