Class RestartStrategies


  • @PublicEvolving
    public class RestartStrategies
    extends Object
    This class defines methods to generate RestartStrategyConfigurations. These configurations are used to create RestartStrategies at runtime.

    The RestartStrategyConfigurations are used to decouple the core module from the runtime module.

    • Constructor Detail

      • RestartStrategies

        public RestartStrategies()
    • Method Detail

      • fixedDelayRestart

        public static RestartStrategies.RestartStrategyConfiguration fixedDelayRestart​(int restartAttempts,
                                                                                       long delayBetweenAttempts)
        Generates a FixedDelayRestartStrategyConfiguration.
        Parameters:
        restartAttempts - Number of restart attempts for the FixedDelayRestartStrategy
        delayBetweenAttempts - Delay in-between restart attempts for the FixedDelayRestartStrategy
        Returns:
        FixedDelayRestartStrategy
      • fixedDelayRestart

        public static RestartStrategies.RestartStrategyConfiguration fixedDelayRestart​(int restartAttempts,
                                                                                       Time delayInterval)
        Generates a FixedDelayRestartStrategyConfiguration.
        Parameters:
        restartAttempts - Number of restart attempts for the FixedDelayRestartStrategy
        delayInterval - Delay in-between restart attempts for the FixedDelayRestartStrategy
        Returns:
        FixedDelayRestartStrategy
      • failureRateRestart

        public static RestartStrategies.FailureRateRestartStrategyConfiguration failureRateRestart​(int failureRate,
                                                                                                   Time failureInterval,
                                                                                                   Time delayInterval)
        Generates a FailureRateRestartStrategyConfiguration.
        Parameters:
        failureRate - Maximum number of restarts in given interval failureInterval before failing a job
        failureInterval - Time interval for failures
        delayInterval - Delay in-between restart attempts
      • exponentialDelayRestart

        public static RestartStrategies.ExponentialDelayRestartStrategyConfiguration exponentialDelayRestart​(Time initialBackoff,
                                                                                                             Time maxBackoff,
                                                                                                             double backoffMultiplier,
                                                                                                             Time resetBackoffThreshold,
                                                                                                             double jitterFactor)
        Generates a ExponentialDelayRestartStrategyConfiguration.
        Parameters:
        initialBackoff - Starting duration between restarts
        maxBackoff - The highest possible duration between restarts
        backoffMultiplier - Delay multiplier how many times is the delay longer than before
        resetBackoffThreshold - How long the job must run smoothly to reset the time interval
        jitterFactor - How much the delay may differ (in percentage)