是否可以尝试连接

@param retryAfterSecend 在n秒后重试
@return
970821
public boolean canTryToConnect(int retryAfterSecend) {
        // 如果是有效连接
        if (this.available) {
            return true;
            // 如果连接无效，并且达到重试时间
        } else if ((System.currentTimeMillis() - lastUnavailableTime) > retryAfterSecend * 1000) {
            return true;
        }
        return false;
    }
100212
function(error) {
          logger.entry('Client._tryService.tryNextService', _id);

          if (serviceList.length === 1) {
            // We've tried all services without success. Pause for a while
            // before trying again
            logger.log('data', _id, 'End of service list');

            client._setState(STATE_RETRYING);
            var retry = function() {
              logger.entryLevel('entry_often', 'Client._tryService.retry', _id);
              if (!client.isStopped()) {
                process.nextTick(function() {
                  client._performConnect(false, true);
                });
              }
              logger.exitLevel('exit_often', 'Client._tryService.retry',
                               _id, null);
            };

            client._retryCount++;
            var retryCap = 60000;
            // Limit to the power of 8 as anything above this will put the
            // interval higher than the cap straight away.
            var exponent = (client._retryCount <= 8) ? client._retryCount : 8;
            var upperBound = Math.pow(2, exponent);
            var lowerBound = 0.75 * upperBound;
            var jitter = Math.random() * (0.25 * upperBound);
            var interval = Math.min(retryCap, (lowerBound + jitter) * 1000);
            // times by CONNECT_RETRY_INTERVAL for unittest purposes
            interval = Math.round(interval) * CONNECT_RETRY_INTERVAL;
            logger.log('data', _id, 'trying to connect again ' +
                       'after ' + (interval / 1000) + ' seconds');
            setTimeout(retry, interval);
            if (error) {
              setImmediate(function() {
                logger.log('emit', _id, 'error', error);
                client.emit('error', error);
              });
            }
          } else {
            // Try the next service in the list
            logger.log('data', _id, 'Trying next service');
            client._tryService(serviceList.slice(1));
          }

          logger.exit('Client._tryService.tryNextService', _id, null);
        }
423541
@Nonnull
  public final HttpClientFactory setRetryMode (@Nonnull final ERetryMode eRetryMode)
  {
    ValueEnforcer.notNull (eRetryMode, "RetryMode");
    m_eRetryMode = eRetryMode;
    return this;
  }
510438
public Retryer<R> randomWait(long maximum, TimeUnit timeUnit) {
        return randomWait(0L, checkNotNull(timeUnit).toMillis(maximum));
    }
1354956
@FFDCIgnore({NumberFormatException.class, IllegalArgumentException.class, ParseException.class})
    private long handleRetry(String retryValue) {


        // RETRY_AFTER is a String that can either correspond to seconds (long) 
        // or a HTTP-Date (which can be one of 7 variations)"
        if (!(retryValue.contains(":"))) {
            // Must be a long since all dates include ":"
            try {
                Long retryLong = Long.valueOf(retryValue);
                //The RETRY_AFTER value is in seconds so change units
                return TimeUnit.MILLISECONDS.convert(retryLong.longValue(), TimeUnit.SECONDS);
            } catch (NumberFormatException e) {
                LOG.fine("SSE RETRY_AFTER Incorrect time value: " + e);
            }
        } else {
            char[] retryValueArray = retryValue.toCharArray();
            //handle date
            try {
                SimpleDateFormat sdf = null;
                // Determine the appropriate HTTP-Date pattern
                if (retryValueArray[3] == ',') {
                    sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z"); // RTC 822, updated by RFC 1123
                } else if (retryValueArray[6] == ',') {
                    sdf = new SimpleDateFormat("EEEEEE, dd-MMM-yy HH:mm:ss z"); // RFC 850, obsoleted by RFC 1036
                } else if (retryValueArray[7] == ',') {
                    sdf = new SimpleDateFormat("EEEEEEE, dd-MMM-yy HH:mm:ss z"); // RFC 850, obsoleted by RFC 1036
                } else if (retryValueArray[8] == ',') {
                    sdf = new SimpleDateFormat("EEEEEEEE, dd-MMM-yy HH:mm:ss z"); // RFC 850, obsoleted by RFC 1036
                } else if (retryValueArray[9] == ',') {
                    sdf = new SimpleDateFormat("EEEEEEEEE, dd-MMM-yy HH:mm:ss z"); // RFC 850, obsoleted by RFC 1036
                } else if (retryValueArray[8] == ',') {
                    sdf = new SimpleDateFormat("EEEEEEEE, dd-MMM-yy HH:mm:ss z"); // RFC 850, obsoleted by RFC 1036
                } else if (retryValueArray[8] == ' ') {
                    sdf = new SimpleDateFormat("EEE MMM  d HH:mm:ss yyyy");  // ANSI C's asctime() format
                } else {
                    sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss yyyy"); // ANSI C's asctime() format
                }
                Date retryDate = sdf.parse(retryValue);

                long retryTime = retryDate.getTime();
                long now = System.currentTimeMillis();
                long delayTime = retryTime - now;
                if (delayTime > 0) {
                    return delayTime;//HTTP Date is in milliseconds
                }
                LOG.fine("SSE RETRY_AFTER Date value represents a time already past");
            } catch (IllegalArgumentException ex) {
                LOG.fine("SSE RETRY_AFTER Date value format incorrect:  " + ex);
            } catch (ParseException e2) {
                LOG.fine("SSE RETRY_AFTER Date value cannot be parsed: " + e2);
            }
        }
        return -1L;

    }
255289
@Override
    public void beforeStep(StepExecution stepExecution) {
        super.beforeStep(stepExecution);
        clearErrors();
        try {
            new Retrier().execute(new Retriable() {
                /*
                 * (non-Javadoc)
                 *
                 * @see org.duracloud.common.retry.Retriable#retry()
                 */
                @Override
                public Object retry() throws Exception {
                    RestoreStatus newStatus = RestoreStatus.VERIFYING_TRANSFERRED_CONTENT;
                    restoreManager.transitionRestoreStatus(restoreId, newStatus, "");
                    return null;
                }
            });
        } catch (Exception ex) {
            addError("failed to transition status to "
                     + RestoreStatus.VERIFYING_TRANSFERRED_CONTENT + ": " + ex.getMessage());
            stepExecution.addFailureException(ex);
        }
    }
348278
public HttpRequestBuilder withRetries(int n) {
    Preconditions.checkArg(n >= 0, "number of retries must be >= 0");
    this.numAttempts = n + 1;
    entry.withMaxAttempts(numAttempts);
    return this;
  }
657631
public static <Return> Return retryUntilNoException(Callable<Return> callable, int maxTry) throws Throwable {
        String errMsg = "连续重试失败" + maxTry + "次。";
        Throwable cause = null;
        while (maxTry > 0) {
            try {
                return callable.call();
            } catch (Throwable throwable) {
                cause = throwable;
                maxTry--;
            }
        }
        LOG.error(new Throwable(errMsg, cause));
        throw cause;
    }
865894
public static <T> T retryS3Operation(Task<T> f) throws Exception
  {
    final int maxTries = 10;
    return RetryUtils.retry(f, S3RETRY, maxTries);
  }
185252
public synchronized ScheduledExecutorService getRetryExecutor() {
    if (retryExecutor == null) {
      retryExecutor = Executors.newScheduledThreadPool(RETRY_THREAD_COUNT,
          ThreadUtil.getThreadFactory(RETRY_THREADPOOL_NAME_PATTERN, true));
    }
    return retryExecutor;
  }
64898
private static Set<StatusCode.Code> buildRetryCodes(RetryOptions retryOptions) {
    ImmutableSet.Builder<StatusCode.Code> statusCodeBuilder = ImmutableSet.builder();
    for (Status.Code retryCode : retryOptions.getRetryableStatusCodes()) {
      statusCodeBuilder.add(GrpcStatusCode.of(retryCode).getCode());
    }

    return statusCodeBuilder.build();
  }
1317701
public com.google.protobuf.Duration getRetryDelay() {
    return retryDelay_ == null ? com.google.protobuf.Duration.getDefaultInstance() : retryDelay_;
  }
453456
public HTTPRequest retry(final int maxRetries, final Retryable retryable, final WaitStrategy waitStrategy) {
        if (maxRetries <= 0) {
            throw new IllegalArgumentException("maxRetries must be > 0");
        }
        if (retryable == null) {
            throw new IllegalArgumentException("retryable must not be null");
        }
        if (waitStrategy == null) {
            throw new IllegalArgumentException("waitStrategy must not be null");
        }
        this.maxRetries = maxRetries;
        this.retryable = retryable;
        this.waitStrategy = waitStrategy;
        return this;
    }
795027
public RetryPolicy<R> onRetry(CheckedConsumer<? extends ExecutionAttemptedEvent<R>> listener) {
    retryListener = EventListener.ofAttempt(Assert.notNull(listener, "listener"));
    return this;
  }
183221
public Retryer<R> withWaitStrategy(WaitStrategy waitStrategy) {
        (this.waitStrategy = (this.waitStrategy.isPresent() 
                ? this.waitStrategy : Optional.of(new CompositeWaitStrategy())))
                .get().put(checkNotNull(waitStrategy, "WaitStrategy cannot be null"));
        return this;
    }
14527
public static boolean isRetryableServiceException(SdkBaseException exception) {
        return isAse(exception) && RETRYABLE_STATUS_CODES.contains(toAse(exception).getStatusCode());
    }
1260208
def get_retry_after(self, response):
        

        retry_after = response.getheader("Retry-After")

        if retry_after is None:
            return None

        return self.parse_retry_after(retry_after)