public TimeBasedRetryPolicy(
                IErrorDetectionStrategy strategy,
                TimeSpan minTotalRetryTimeLimit,
                TimeSpan maxTotalRetryTimeLimit,
                double totalRetryTimeLimitRate,
                TimeSpan minInterval,
                TimeSpan maxInterval,
                double intervalFactor)
                : base(strategy)
            {
                Contract.Assert(minTotalRetryTimeLimit.Ticks >= 0);
                Contract.Assert(maxTotalRetryTimeLimit.Ticks >= minTotalRetryTimeLimit.Ticks);
                Contract.Assert(totalRetryTimeLimitRate >= 0);

                Contract.Assert(minInterval.Ticks >= 0);
                Contract.Assert(maxInterval.Ticks >= minInterval.Ticks);
                Contract.Assert(intervalFactor >= 1);

                _minTotalRetryTimeLimit  = minTotalRetryTimeLimit;
                _maxTotalRetryTimeLimit  = maxTotalRetryTimeLimit;
                _totalRetryTimeLimitRate = totalRetryTimeLimitRate;

                _minInterval    = minInterval;
                _maxInterval    = maxInterval;
                _intervalFactor = intervalFactor;

                _stopwatch = Stopwatch.StartNew();
            }
            /// <summary>
            /// Constructs a new instance of the TRetryPolicy class with the specified number of retry attempts and time interval between retries.
            /// </summary>
            /// <param name="strategy">The <see cref="RetryPolicy.IErrorDetectionStrategy"/> to use when checking whether an error is retryable</param>
            /// <param name="maxRetryCount">The max number of retry attempts. Should be 1-indexed.</param>
            /// <param name="intervalBetweenRetries">The interval between retries.</param>
            public FixedDelayPolicy(IErrorDetectionStrategy strategy, int maxRetryCount, TimeSpan intervalBetweenRetries)
                : base(strategy)
            {
                Contract.Assert(maxRetryCount >= 0, "maxRetryCount cannot be a negative number");
                Contract.Assert(intervalBetweenRetries.Ticks >= 0, "intervalBetweenRetries cannot be negative");

                _maxRetryCount          = maxRetryCount;
                _intervalBetweenRetries = intervalBetweenRetries;
            }
Exemple #3
0
 public TestFixedDelayPolicy(
     IErrorDetectionStrategy strategy,
     int maxRetryCount,
     TimeSpan intervalBetweenRetries)
     : base(strategy,
            maxRetryCount,
            intervalBetweenRetries)
 {
 }
        protected RetryPolicy(IErrorDetectionStrategy strategy)
        {
            Contract.Assert(strategy != null);

            _errorDetectionStrategy = strategy;
            this.FastFirstRetry     = true;

            //TODO Defect 1078447 Validate whether CommandTimeout needs to be used differently in schema/data scenarios
            this.CommandTimeoutInSeconds = AmbientSettings.LongRunningQueryTimeoutSeconds;
        }
            /// <summary>
            /// Constructs a new instance of the TRetryPolicy class with the specified number of retry attempts and parameters defining the progressive delay between retries.
            /// </summary>
            /// <param name="strategy">The <see cref="RetryPolicy.IErrorDetectionStrategy"/> to use when checking whether an error is retryable</param>
            /// <param name="maxRetryCount">The maximum number of retry attempts. Should be 1-indexed.</param>
            /// <param name="initialInterval">The initial interval which will apply for the first retry.</param>
            /// <param name="increment">The incremental time value which will be used for calculating the progressive delay between retries.</param>
            public ProgressiveRetryPolicy(IErrorDetectionStrategy strategy, int maxRetryCount, TimeSpan initialInterval, TimeSpan increment)
                : base(strategy)
            {
                Contract.Assert(maxRetryCount >= 0, "maxRetryCount cannot be a negative number");
                Contract.Assert(initialInterval.Ticks >= 0, "retryInterval cannot be negative");
                Contract.Assert(increment.Ticks >= 0, "retryInterval cannot be negative");

                _maxRetryCount   = maxRetryCount;
                _initialInterval = initialInterval;
                _increment       = increment;
            }
Exemple #6
0
 public TestProgressiveRetryPolicy(
     IErrorDetectionStrategy strategy,
     int maxRetryCount,
     TimeSpan initialInterval,
     TimeSpan increment)
     : base(strategy,
            maxRetryCount,
            initialInterval,
            increment)
 {
 }
            /// <summary>
            /// Constructs a new instance of the TRetryPolicy class with the specified number of retry attempts and parameters defining the progressive delay between retries.
            /// </summary>
            /// <param name="strategy">The <see cref="RetryPolicy.IErrorDetectionStrategy"/> to use when checking whether an error is retryable</param>
            /// <param name="maxRetryCount">The maximum number of retry attempts.</param>
            /// <param name="intervalFactor">Controls the speed at which the delay increases - the retryCount is raised to this power as
            /// part of the function </param>
            /// <param name="minInterval">Minimum interval between retries. The basis for all backoff calculations</param>
            /// <param name="maxInterval">Maximum interval between retries. Backoff will not take longer than this period.</param>
            public ExponentialDelayRetryPolicy(IErrorDetectionStrategy strategy, int maxRetryCount, double intervalFactor, TimeSpan minInterval, TimeSpan maxInterval)
                : base(strategy)
            {
                Contract.Assert(maxRetryCount >= 0, "maxRetryCount cannot be a negative number");
                Contract.Assert(intervalFactor > 1, "intervalFactor Must be > 1 so that the delay increases exponentially");
                Contract.Assert(minInterval.Ticks >= 0, "minInterval cannot be negative");
                Contract.Assert(maxInterval.Ticks >= 0, "maxInterval cannot be negative");
                Contract.Assert(maxInterval.Ticks >= minInterval.Ticks, "maxInterval must be greater than minInterval");

                _maxRetryCount  = maxRetryCount;
                _intervalFactor = intervalFactor;
                _minInterval    = minInterval;
                _maxInterval    = maxInterval;
            }
Exemple #8
0
 public TestTimeBasedRetryPolicy(
     IErrorDetectionStrategy strategy,
     TimeSpan minTotalRetryTimeLimit,
     TimeSpan maxTotalRetryTimeLimit,
     double totalRetryTimeLimitRate,
     TimeSpan minInterval,
     TimeSpan maxInterval,
     double intervalFactor)
     : base(
         strategy,
         minTotalRetryTimeLimit,
         maxTotalRetryTimeLimit,
         totalRetryTimeLimitRate,
         minInterval,
         maxInterval,
         intervalFactor)
 {
 }