Class RetryPolicy

java.lang.Object
co.yellowdog.platform.model.RetryPolicy
All Implemented Interfaces:
Serializable

public class RetryPolicy extends Object implements Serializable
Policy that can be specified in a RunSpecification to control how many times a Task can retry in the event that an attempt to execute the Task errors.
See Also:
  • Constructor Details

    • RetryPolicy

      public RetryPolicy(int maxRetries, Selection<TaskErrorSelector> retryErrors)
      Creates a new RetryPolicy instance.
      Parameters:
      maxRetries - The maximum number of times a Task can be retried. The maximum total number of attempts will always be `maxRetries + 1` because the first attempt is not a retry. Must be 0 or higher. Zero is allowed if you want to be explicit, and to make it easy to change the number of retries without having to omit the policy. Specifying zero is effectively the same as having no RetryPolicy.
      retryErrors - Optional Selection which, if specified, only allows attempts matching the Selection to be retried. Note that it is only the TaskError from the most recent attempt that is evaluated by the Selection.
  • Method Details

    • retry

      public static RetryPolicy retry(int maxRetries)
      Retry Tasks for the maxRetries specified regardless of why a Task errored
      Parameters:
      maxRetries - The maximum number of times a Task can be retried, must be 0 or more
      Returns:
      The RetryPolicy
    • retry

      public static RetryPolicy retry(int maxRetries, Selection<TaskErrorSelector> retryErrors)
      Retry Tasks for the maxRetries specified. Only retry if the most recent error matches the Selection.
      Parameters:
      maxRetries - The maximum number of times a Task can be retried, must be 0 or more
      retryErrors - Which errors can be retried, if the Selection is null, all Tasks can be retried
      Returns:
      The RetryPolicy
    • builder

      public static RetryPolicy.Builder builder()
    • getMaxRetries

      public int getMaxRetries()
      The maximum number of times a Task can be retried. The maximum total number of attempts will always be `maxRetries + 1` because the first attempt is not a retry. Must be 0 or higher. Zero is allowed if you want to be explicit, and to make it easy to change the number of retries without having to omit the policy. Specifying zero is effectively the same as having no RetryPolicy.
    • getRetryErrors

      public Selection<TaskErrorSelector> getRetryErrors()
      Optional Selection which, if specified, only allows attempts matching the Selection to be retried. Note that it is only the TaskError from the most recent attempt that is evaluated by the Selection.