public class

DefaultRetryPolicy

extends Object
implements RetryPolicy
java.lang.Object
   ↳ com.neomades.content.retry.DefaultRetryPolicy

Class Overview

Default retry policy for queries.

The default retry policy has three characteristics:

  • Initial timeout: the time after which the request is stopped when no answer is received
  • Maximal number of retry: The maximal number of times we relaunch the request after it was stopped because of timeout
  • Backoff multiplier: the value by which to multiply the timeout before each retry. The formula applied before each retry is the following: currentTimeout += (currentTimeout * backoffMultiplier);

Summary

Public Constructors
DefaultRetryPolicy()
Constructs a new retry policy using the default values.
DefaultRetryPolicy(int initialTimeoutMs, int maxNumRetries, float backoffMultiplier)
Constructs a new retry policy.
Public Methods
int getCurrentRetryCount()
Returns the current retry count (this getter is used for logging).
int getCurrentTimeout()
Returns the current timeout (this getter is used for logging).
void retry(ContentError error)
Prepares for the next retry by applying a backoff to the timeout.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.neomades.content.retry.RetryPolicy

Public Constructors

public DefaultRetryPolicy ()

Constructs a new retry policy using the default values.

  • default timeout: 2,5 seconds
  • maxNumRetries: 1 time
  • Backoff multiplier: 1

public DefaultRetryPolicy (int initialTimeoutMs, int maxNumRetries, float backoffMultiplier)

Constructs a new retry policy.

Parameters
initialTimeoutMs The initial timeout for the policy.
maxNumRetries The maximum number of retries.
backoffMultiplier Backoff multiplier for the policy.

Public Methods

public int getCurrentRetryCount ()

Returns the current retry count (this getter is used for logging).

This getter is used by ContentManager to print out to the console (for logging), after how many retry count the query is retrying.

This value should be used and updated by RetryPolicy implementation.

Returns
  • the current retry count (used for logging).

public int getCurrentTimeout ()

Returns the current timeout (this getter is used for logging).

This getter is used by ContentManager to print out to the console (for logging), after which timeout the query is retrying.

This value should be used and updated by RetryPolicy implementation.

Returns
  • the current timeout (used for logging).

public void retry (ContentError error)

Prepares for the next retry by applying a backoff to the timeout.

Current timeout will increase each time this method will be called. If the max number of retries has been reached this method will throw an exception to stop retrying.

Parameters
error The error of the last attempt.