当前位置: 首页>>代码示例>>Java>>正文


Java RetryPolicy.RetryAction方法代码示例

本文整理汇总了Java中org.apache.hadoop.io.retry.RetryPolicy.RetryAction方法的典型用法代码示例。如果您正苦于以下问题:Java RetryPolicy.RetryAction方法的具体用法?Java RetryPolicy.RetryAction怎么用?Java RetryPolicy.RetryAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.io.retry.RetryPolicy的用法示例。


在下文中一共展示了RetryPolicy.RetryAction方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shouldRetry

import org.apache.hadoop.io.retry.RetryPolicy; //导入方法依赖的package包/类
/**
 * Predicate to determine whether a failed operation should be attempted
 * again. If a retry is advised, the exception is automatically logged and
 * the filesystem statistic {@link Statistic#IGNORED_ERRORS} incremented.
 * The method then sleeps for the sleep time suggested by the sleep policy;
 * if the sleep is interrupted then {@code Thread.interrupted()} is set to
 * indicate the thread was interrupted; then false is returned.
 *
 * @param operation operation for log message
 * @param e exception raised
 * @param retryCount number of retries already attempted
 * @return true if another attempt should be made
 */
private boolean shouldRetry(String operation, AmazonClientException e, int retryCount) {
  try {
    RetryPolicy.RetryAction retryAction = retryPolicy.shouldRetry(e, retryCount, 0, true);
    boolean retry = retryAction == RetryPolicy.RetryAction.RETRY;
    if (retry) {
      LOG.info("Retrying {} after exception ", operation, e);
      Thread.sleep(retryAction.delayMillis);
    }
    return retry;
  } catch (InterruptedException ex) {
    Thread.currentThread().interrupt();
    return false;
  } catch (Exception ignored) {
    return false;
  }
}
 
开发者ID:SparkTC,项目名称:stocator,代码行数:30,代码来源:COSBlockOutputStream.java

示例2: shouldRetry

import org.apache.hadoop.io.retry.RetryPolicy; //导入方法依赖的package包/类
private void shouldRetry(final IOException ioe, final int retry
    ) throws IOException {
  if (checkRetry) {
    try {
      final RetryPolicy.RetryAction a = retryPolicy.shouldRetry(
          ioe, retry, 0, true);
      if (a.action == RetryPolicy.RetryAction.RetryDecision.RETRY) {
        LOG.info("Retrying connect to namenode: " + nnAddr
            + ". Already tried " + retry + " time(s); retry policy is "
            + retryPolicy + ", delay " + a.delayMillis + "ms.");      
        Thread.sleep(a.delayMillis);
        return;
      }
    } catch(Exception e) {
      LOG.warn("Original exception is ", ioe);
      throw toIOException(e);
    }
  }
  throw toIOException(ioe);
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:21,代码来源:WebHdfsFileSystem.java

示例3: shouldRetry

import org.apache.hadoop.io.retry.RetryPolicy; //导入方法依赖的package包/类
private void shouldRetry(final IOException ioe, final int retry)
    throws IOException {
  if (checkRetry) {
    try {
      final RetryPolicy.RetryAction a =
          retryPolicy.shouldRetry(ioe, retry, 0, true);
      if (a.action == RetryPolicy.RetryAction.RetryDecision.RETRY) {
        LOG.info(
            "Retrying connect to namenode: " + nnAddr + ". Already tried " +
                retry + " time(s); retry policy is " + retryPolicy +
                ", delay " + a.delayMillis + "ms.");
        Thread.sleep(a.delayMillis);
        return;
      }
    } catch (Exception e) {
      LOG.warn("Original exception is ", ioe);
      throw toIOException(e);
    }
  }
  throw toIOException(ioe);
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:22,代码来源:WebHdfsFileSystem.java

示例4: shouldRetry

import org.apache.hadoop.io.retry.RetryPolicy; //导入方法依赖的package包/类
private void shouldRetry(final IOException ioe, final int retry
    ) throws IOException {
  InetSocketAddress nnAddr = getCurrentNNAddr();
  if (checkRetry) {
    try {
      final RetryPolicy.RetryAction a = retryPolicy.shouldRetry(
          ioe, retry, 0, true);

      boolean isRetry = a.action == RetryPolicy.RetryAction.RetryDecision.RETRY;
      boolean isFailoverAndRetry =
          a.action == RetryPolicy.RetryAction.RetryDecision.FAILOVER_AND_RETRY;

      if (isRetry || isFailoverAndRetry) {
        LOG.info("Retrying connect to namenode: " + nnAddr
            + ". Already tried " + retry + " time(s); retry policy is "
            + retryPolicy + ", delay " + a.delayMillis + "ms.");

        if (isFailoverAndRetry) {
          resetStateToFailOver();
        }

        Thread.sleep(a.delayMillis);
        return;
      }
    } catch(Exception e) {
      LOG.warn("Original exception is ", ioe);
      throw toIOException(e);
    }
  }
  throw toIOException(ioe);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:32,代码来源:WebHdfsFileSystem.java

示例5: shouldRetry

import org.apache.hadoop.io.retry.RetryPolicy; //导入方法依赖的package包/类
private void shouldRetry(final IOException ioe, final int retry
) throws IOException {
  InetSocketAddress nnAddr = getCurrentNNAddr();
  if (checkRetry) {
    try {
      final RetryPolicy.RetryAction a = retryPolicy.shouldRetry(
          ioe, retry, 0, true);

      boolean isRetry =
          a.action == RetryPolicy.RetryAction.RetryDecision.RETRY;
      boolean isFailoverAndRetry =
          a.action == RetryPolicy.RetryAction.RetryDecision.FAILOVER_AND_RETRY;

      if (isRetry || isFailoverAndRetry) {
        LOG.info("Retrying connect to namenode: {}. Already tried {}"
                + " time(s); retry policy is {}, delay {}ms.",
            nnAddr, retry, retryPolicy, a.delayMillis);

        if (isFailoverAndRetry) {
          resetStateToFailOver();
        }

        Thread.sleep(a.delayMillis);
        return;
      }
    } catch(Exception e) {
      LOG.warn("Original exception is ", ioe);
      throw toIOException(e);
    }
  }
  throw toIOException(ioe);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:33,代码来源:WebHdfsFileSystem.java

示例6: getNextTgtRenewalTime

import org.apache.hadoop.io.retry.RetryPolicy; //导入方法依赖的package包/类
/**
 * Get time for next login retry. This will allow the thread to retry with
 * exponential back-off, until tgt endtime.
 * Last retry is {@link #kerberosMinSecondsBeforeRelogin} before endtime.
 *
 * @param tgtEndTime EndTime of the tgt.
 * @param now Current time.
 * @param rp The retry policy.
 * @return Time for next login retry.
 */
@VisibleForTesting
static long getNextTgtRenewalTime(final long tgtEndTime, final long now,
    final RetryPolicy rp) throws Exception {
  final long lastRetryTime = tgtEndTime - kerberosMinSecondsBeforeRelogin;
  final RetryPolicy.RetryAction ra = rp.shouldRetry(null,
      metrics.renewalFailures.value(), 0, false);
  return Math.min(lastRetryTime, now + ra.delayMillis);
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:19,代码来源:UserGroupInformation.java


注:本文中的org.apache.hadoop.io.retry.RetryPolicy.RetryAction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。