default value is 3.
@param maxRetriesBeforeRequeue the number of retries before the particular chunk of work is requeued at the end
of the queue
354535
public void setMaxRetriesBeforeRequeue(int maxRetriesBeforeRequeue)
    {
        this.maxRetriesBeforeRequeue = maxRetriesBeforeRequeue;
        this.transactionStyle = new TransactionStyle(MithraManagerProvider.getMithraManager().getTransactionTimeout(), maxRetriesBeforeRequeue, this.retryOnTimeout);
    }
1147703
public void setMaxRetriesOnIOError(int retries) {
        if (retries < 0) {
            throw new IllegalArgumentException("Parameter retries must be greater or equal to zero.");
        }

        HttpMethodRetryHandler retryHandler = new DefaultHttpMethodRetryHandler(retries, false);
        client.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, retryHandler);
        clientViaProxy.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, retryHandler);
    }
1232603
public RetryInterceptorBuilder<T> maxAttempts(int maxAttempts) {
		Assert.isNull(this.retryOperations,
				"cannot alter the retry policy when a custom retryOperations has been set");
		Assert.isTrue(!this.retryPolicySet,
				"cannot alter the retry policy when a custom retryPolicy has been set");
		this.simpleRetryPolicy.setMaxAttempts(maxAttempts);
		this.retryTemplate.setRetryPolicy(this.simpleRetryPolicy);
		this.templateAltered = true;
		return this;
	}
1281568
def ShouldRetry(self, exception):
        
        if (self.current_retry_attempt_count < self._max_retry_attempt_count) and self.needsRetry(exception.status_code):
            self.current_retry_attempt_count += 1
            return True
        return False
239117
def retry(self, queue=None, delay=None, max_retries=None):
        

        max_retries = max_retries
        if max_retries is None:
            max_retries = self.max_retries

        if self.data.get("retry_count", 0) >= max_retries:
            raise MaxRetriesInterrupt()

        exc = RetryInterrupt()

        exc.queue = queue or self.queue or self.data.get("queue") or "default"
        exc.retry_count = self.data.get("retry_count", 0) + 1
        exc.delay = delay
        if exc.delay is None:
            exc.delay = self.retry_delay

        self._attach_original_exception(exc)

        raise exc
959245
public static <Return> Return retryUntilNoException(Callable<Return> callable, int maxTry, Class<? extends Throwable> exceptionClass) throws Exception {
        String errMsg = "连续重试失败" + maxTry + "次。";
        Exception t = null;
        while (maxTry > 0) {
            try {
                return callable.call();
            } catch (Exception throwable) {
                if (exceptionClass.isAssignableFrom(throwable.getClass())) {
                    //只对指定的异常重试，其他异常直接抛出去
                    maxTry--;
                    t = throwable;
                } else {
                    throw throwable;
                }
            }
        }
        LOG.error(new RuntimeException(errMsg, t));
        //这里是对重试N次后依然抛出指定异常的情况，原样抛出
        throw t;
    }
1286223
public Retryer<R> stopAfterAttempt(final int maxAttemptNumber) {
        checkArgument(maxAttemptNumber >= 1, "maxAttemptNumber must be >= 1 but is %d", maxAttemptNumber);
        return withStopStrategy(new StopStrategy() {
            
            @Override public boolean shouldStop(int previousAttemptNumber, long delaySinceFirstAttemptInMillis) {
                return previousAttemptNumber >= maxAttemptNumber;
            }
        });
    }
863867
private long getWaitUntilMillis(int retryAfterSeconds) {
    double multiplier = waitTimeNoiseFactor.get().nextDouble();
    multiplier =
        multiplier * (MAX_WAIT_TIME_MULTIPLIER - MIN_WAIT_TIME_MULTIPLIER)
            + MIN_WAIT_TIME_MULTIPLIER;
    double result = SECONDS.toMillis(retryAfterSeconds) * multiplier;
    return (long) result;
  }
1016406
protected ExecutorService createDefaultExecutorService(ConcurrentAsyncExecutorProvider provider) {
        final int corePoolSize = 0;
        Integer maximumPoolSize = provider != null ? provider.provideMaxPoolSize() : null;
        if (maximumPoolSize == null) {
            maximumPoolSize = 10;
        }
        final long keepAliveTime = 60L;
        final TimeUnit seconds = TimeUnit.SECONDS;
        final BlockingQueue<Runnable> workQueue = createDefaultBlockingQueue();
        final RejectedExecutionHandler rejected = createRejectedExecutionHandler();
        return new ThreadPoolExecutor(corePoolSize, maximumPoolSize, keepAliveTime, seconds, workQueue, rejected);
    }
12903
public QueryPlus<T> withMaxQueuedBytes(long maxQueuedBytes)
  {
    return new QueryPlus<>(
        query.withOverriddenContext(ImmutableMap.of(QueryContexts.MAX_QUEUED_BYTES_KEY, maxQueuedBytes)),
        queryMetrics,
        identity
    );
  }
134613
private void maybeEvictEntries() {
    ArrayList<Entry<K, V>> oldEntries;
    synchronized (this) {
      int maxCount = Math.min(
          mMemoryCacheParams.maxEvictionQueueEntries,
          mMemoryCacheParams.maxCacheEntries - getInUseCount());
      int maxSize = Math.min(
          mMemoryCacheParams.maxEvictionQueueSize,
          mMemoryCacheParams.maxCacheSize - getInUseSizeInBytes());
      oldEntries = trimExclusivelyOwnedEntries(maxCount, maxSize);
      makeOrphans(oldEntries);
    }
    maybeClose(oldEntries);
    maybeNotifyExclusiveEntryRemoval(oldEntries);
  }
812703
public static final RetryPolicy retryUpToMaximumCountWithFixedSleep(int maxRetries, long sleepTime, TimeUnit timeUnit) {
    return new RetryUpToMaximumCountWithFixedSleep(maxRetries, sleepTime, timeUnit);
  }
935645
public int setMaximumConcurrentRequests(int newMax) {
        if (newMax < 1) {
            throw new IllegalArgumentException("Maximum concurrent requests must be at least 1");
        }
        int oldMax = this.max;
        this.max = newMax;
        if(newMax > oldMax) {
            synchronized (this) {
                while (!queue.isEmpty()) {
                    int oldVal, newVal;
                    do {
                        oldVal = requests;
                        if (oldVal >= max) {
                            return oldMax;
                        }
                        newVal = oldVal + 1;
                    } while (!requestsUpdater.compareAndSet(this, oldVal, newVal));
                    SuspendedRequest res = queue.poll();
                    res.exchange.dispatch(res.next);
                }
            }
        }
        return oldMax;
    }
891326
public static ExecutorService newMaxQueueThreadPool(int numWorkerThreads,
            long waitingMillis, int maxQueue) {
        return new ThreadPoolExecutor(numWorkerThreads, numWorkerThreads,
                0L, TimeUnit.MILLISECONDS,
                waitingMillis > 0 ? getWaitingLimitedBlockingQueue(
                        waitingMillis, maxQueue) : getLimitedBlockingQueue(
                        maxQueue));
    }
2267
public static <T> T retry(final Callable<T> f, Predicate<Throwable> shouldRetry, final int maxTries) throws Exception
  {
    return retry(f, shouldRetry, 0, maxTries);
  }
183948
public void setMaxStorageStrategy(int requestedMaxStrategy)
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this,
                        tc,
                        "setMaxStorageStrategy",
                        Integer.valueOf(requestedMaxStrategy));
        maxStorageStrategy = requestedMaxStrategy;
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "setMaxStorageStrategy");
    }
948827
public static void setDefaultExecutorService(
            ExecutorService defaultExecutorService) {
        // If the timer executor service is set to the default
        // executor service, adjust it to the new value as well.
        if (timerExecutorService == Components.defaultExecutorService) {
            timerExecutorService = defaultExecutorService;
        }
        Components.defaultExecutorService = defaultExecutorService;
    }