Creates {@link RetrySettings} for non-streaming idempotent method.
18044
private static RetrySettings buildIdempotentRetrySettings(RetrySettings retrySettings,
      BigtableOptions options) {
    RetryOptions retryOptions = options.getRetryOptions();
    CallOptionsConfig callOptions = options.getCallOptionsConfig();
    RetrySettings.Builder retryBuilder = retrySettings.toBuilder();

    if (retryOptions.allowRetriesWithoutTimestamp()) {
      throw new UnsupportedOperationException("Retries without Timestamp does not support yet.");
    }

    // if useTimeout is false, then RPC's are defaults to 6 minutes.
    Duration rpcTimeout = ofMillis(callOptions.isUseTimeout()
        ? callOptions.getShortRpcTimeoutMs()
        : RPC_DEADLINE_MS);

    retryBuilder
        .setInitialRetryDelay(ofMillis(retryOptions.getInitialBackoffMillis()))
        .setRetryDelayMultiplier(retryOptions.getBackoffMultiplier())
        .setMaxRetryDelay(ofMillis(MAX_RETRY_TIMEOUT_MS))
        .setInitialRpcTimeout(rpcTimeout)
        .setMaxRpcTimeout(rpcTimeout)
        .setMaxAttempts(0)
        .setTotalTimeout(ofMillis(retryOptions.getMaxElapsedBackoffMillis()));

    return retryBuilder.build();
  }
72310
<T> T callWithRetries(Callable<T> callable, RecurringPolicy<?> recurringPolicy,
      RecurringStats retryStats, Set<Class<? extends Exception>> retryableExceptions,
      boolean recoverable, boolean logFailures) throws Exception {
    boolean recovery = retryStats != null;

    while (true) {
      try {
        return callable.call();
      } catch (Exception e) {
        ShutdownSignalException sse = extractCause(e, ShutdownSignalException.class);
        if (sse == null && logFailures && recurringPolicy != null
            && recurringPolicy.allowsAttempts())
          log.error("Invocation of {} failed.", callable, e);

        if (sse != null && (recovery || !recoverable))
          throw e;

        if (!closed) {
          try {
            // Retry on channel recovery failure or retryable exception
            boolean retryable =
                recurringPolicy != null && recurringPolicy.allowsAttempts()
                    && isRetryable(retryableExceptions, e, sse);
            long startTime = System.nanoTime();

            if (retryable) {
              if (retryStats == null) 
                retryStats = new RecurringStats(recurringPolicy);
                
              // Wait for pending recovery
              if (sse != null) {
                if (recurringPolicy.getMaxDuration() == null)
                  circuit.await();
                else if (!circuit.await(retryStats.getMaxWaitTime())) {
                  log.debug("Exceeded max wait time while waiting for {} to recover", this);
                  throw e;
                }
              }

              // Continue retries
              retryStats.incrementAttempts();
              if (!retryStats.isPolicyExceeded()) {
                long remainingWaitTime =
                    retryStats.getWaitTime().toNanos() - (System.nanoTime() - startTime);
                if (remainingWaitTime > 0)
                  retryWaiter.await(Duration.nanos(remainingWaitTime));
                continue;
              }
            }
          } catch (Throwable ignore) {
          }
        }

        throw e;
      }
    }
  }
566762
public void setListeners(Collection<RetryListener> globalListeners) {
		ArrayList<RetryListener> retryListeners = new ArrayList<RetryListener>(
				globalListeners);
		AnnotationAwareOrderComparator.sort(retryListeners);
		this.globalListeners = retryListeners.toArray(new RetryListener[0]);
	}
1348541
def retry(tries=10, delay=1, backoff=2, retry_exception=None):
    
    assert tries > 0, "tries must be 1 or greater"
    catching_mode = bool(retry_exception)

    def deco_retry(f):
        @functools.wraps(f)
        def f_retry(*args, **kwargs):
            mtries, mdelay = tries, delay

            while mtries > 0:
                time.sleep(mdelay)
                mdelay *= backoff
                try:
                    rv = f(*args, **kwargs)
                    if not catching_mode and rv:
                        return rv
                except retry_exception:
                    pass
                else:
                    if catching_mode:
                        return rv
                mtries -= 1
                if mtries is 0 and not catching_mode:
                    return False
                if mtries is 0 and catching_mode:
                    return f(*args, **kwargs)  # extra try, to avoid except-raise syntax
                log.debug("{0} try, sleeping for {1} sec".format(tries-mtries, mdelay))
            raise Exception("unreachable code")
        return f_retry
    return deco_retry
129740
public RetryTemplateBuilder withListener(RetryListener listener) {
		Assert.notNull(listener, "Listener should not be null");
		listenersList().add(listener);
		return this;
	}
840617
@SafeVarargs
    public final Builder retryOn(Class<? extends Exception>... exceptions) {
      for (Class<? extends Exception> exception : exceptions) {
        retriableExceptions.add(checkNotNull(exception));
      }
      return this;
    }
176945
public MultiPrimaryProtocolBuilder withRetryDelay(long retryDelay, TimeUnit timeUnit) {
    return withRetryDelay(Duration.ofMillis(timeUnit.toMillis(retryDelay)));
  }
1192543
public RetryerBuilder<V> retryIfRuntimeException() {
        rejectionPredicate = Predicates.or(rejectionPredicate, new ExceptionClassPredicate<V>(RuntimeException.class));
        return this;
    }
694656
protected void retryDelay(int attemptCount) {
        if (attemptCount > 0) {
            try {
                Thread.sleep(attemptCount * retryDelay);
            } catch (InterruptedException e) {
                LOG.debug("Failed to sleep: " + e, e);
            }
        }
    }
2408
public void setRetryInterval(String retryInterval)
    {
        _retryInterval = (retryInterval == null ? null : Integer.valueOf(retryInterval));
    }
993677
private void scheduleRetryFuture() {
        Log.v(Log.TAG_SYNC, "%s: Failed to xfer; will retry in %d sec", this, RETRY_DELAY_SECONDS);
        synchronized (executor) {
            if (!executor.isShutdown()) {
                this.retryFuture = executor.schedule(new Runnable() {
                    public void run() {
                        retryIfReady();
                    }
                }, RETRY_DELAY_SECONDS, TimeUnit.SECONDS);
            }
        }
    }
258326
public Map<String, Long> resetRetryCounter() {
        Map<String, Long> result = retryCounter.asMap();
        retryCounter.clear();
        return result;
    }
1088826
private static void buildReadRowSettings(Builder builder, BigtableOptions options) {
    RetrySettings retrySettings =
        buildIdempotentRetrySettings(builder.readRowSettings().getRetrySettings(), options);

    builder.readRowSettings()
        .setRetrySettings(retrySettings)
        .setRetryableCodes(buildRetryCodes(options.getRetryOptions()));
  }
709046
@SuppressWarnings("unchecked")
  public RetryPolicy<R> abortOn(Class<? extends Throwable>... failures) {
    Assert.notNull(failures, "failures");
    Assert.isTrue(failures.length > 0, "Failures cannot be empty");
    return abortOn(Arrays.asList(failures));
  }
60651
def retry(method):
    

    def inner(self, *args, **kwargs):
        attempt_number = 1
        while attempt_number < self.retries:
            try:
                return method(self, *args, **kwargs)
            except HasOffersException as exc:
                if 'API usage exceeded rate limit' not in str(exc):
                    raise exc
                self.logger.debug('Retrying due: %s', exc)
                time.sleep(self.retry_timeout)
            except requests.exceptions.ConnectionError:
                # This happens when the session gets expired
                self.logger.debug('Recreating session due to ConnectionError')
                self._session = requests.Session()
            attempt_number += 1
        raise MaxRetriesExceeded

    return inner
534026
public RetryWhenFunction build() {
    RetryWithDelayHandler handler;
    Func1<Throwable, Boolean> filter;
    if ((errorsStoppingRetry == null || errorsStoppingRetry.isEmpty()) && retryErrorPredicate == null) {
      //always retry on any error
      filter = null;
    } else if (retryErrorPredicate != null) {
      filter = new InversePredicate(retryErrorPredicate);
    } else {
      filter = new ShouldStopOnError(errorsStoppingRetry, inverse);
    }

    if (scheduler == null) {
      handler = new RetryWithDelayHandler(maxAttempts, delay, filter, doOnRetryAction);
    } else {
      handler = new RetryWithDelayHandler(maxAttempts, delay, filter, doOnRetryAction, scheduler);
    }
    return new RetryWhenFunction(handler);
  }
917323
private static <E extends Throwable> E wrapIfNecessary(Throwable throwable)
			throws RetryException {
		if (throwable instanceof Error) {
			throw (Error) throwable;
		}
		else if (throwable instanceof Exception) {
			@SuppressWarnings("unchecked")
			E rethrow = (E) throwable;
			return rethrow;
		}
		else {
			throw new RetryException("Exception in retry", throwable);
		}
	}