public override bool CanRetry(Context context, OTSException exception)
        {
            if (exception == null)
            {
                // No exception ocurred
                return(false);
            }

            if (RetryUtil.ShouldRetryNoMatterWhichAPI(exception))
            {
                return(true);
            }

            if (RetryUtil.IsRepeatableAPI(context.APIName) &&
                RetryUtil.ShouldRetryWhenAPIRepeatable(exception))
            {
                return(true);
            }

            return(false);
        }
        public override int DelayBeforeNextRetry(Context context, OTSException exception)
        {
            int delayFactor;

            if (RetryUtil.IsServerThrottlingException(exception))
            {
                delayFactor = ServerThrottlingExceptionDelayFactor;
            }
            else
            {
                delayFactor = StabilityExceptionDelayFactor;
            }

            int delayLimit = delayFactor * (int)Math.Pow(ScaleFactor, context.RetryTimes);

            if (delayLimit >= MaxDelay)
            {
                delayLimit = MaxDelay;
            }

            int realDelay = RandomGenerator.Next(delayLimit / 2, delayLimit);

            return(realDelay);
        }