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


Java RetryAction类代码示例

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


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

示例1: extractActions

import org.apache.hadoop.io.retry.RetryPolicy.RetryAction; //导入依赖的package包/类
private List<RetryAction> extractActions(RetryPolicy policy, Exception ex,
                                         int i, int invocationFailoverCount,
                                         boolean isIdempotentOrAtMostOnce)
        throws Exception {
  List<RetryAction> actions = new LinkedList<>();
  if (ex instanceof MultiException) {
    for (Exception th : ((MultiException) ex).getExceptions().values()) {
      actions.add(policy.shouldRetry(th, i, invocationFailoverCount,
              isIdempotentOrAtMostOnce));
    }
  } else {
    actions.add(policy.shouldRetry(ex, i,
            invocationFailoverCount, isIdempotentOrAtMostOnce));
  }
  return actions;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:17,代码来源:RetryInvocationHandler.java

示例2: setupMockPolicy

import org.apache.hadoop.io.retry.RetryPolicy.RetryAction; //导入依赖的package包/类
private void setupMockPolicy(RetryPolicy mockPolicy,
    final RetryPolicy realPolicy) throws Exception {
  when(mockPolicy.shouldRetry(any(Exception.class), anyInt(), anyInt(),
      anyBoolean())).thenAnswer(new Answer<RetryAction>() {
    @SuppressWarnings("rawtypes")
    @Override
    public RetryAction answer(InvocationOnMock invocation) throws Throwable {
      Object[] args = invocation.getArguments();
      Exception e = (Exception) args[0];
      int retries = (int) args[1];
      int failovers = (int) args[2];
      boolean isIdempotentOrAtMostOnce = (boolean) args[3];
      caughtRetryAction = realPolicy.shouldRetry(e, retries, failovers,
          isIdempotentOrAtMostOnce);
      return caughtRetryAction;
    }
  });
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:19,代码来源:TestRetryProxy.java

示例3: execute

import org.apache.hadoop.io.retry.RetryPolicy.RetryAction; //导入依赖的package包/类
/**
 * The execute() method invokes doExecute() until either: 1. doExecute() succeeds, or 2. the command may no longer be
 * retried (e.g. runs out of retry-attempts).
 *
 * @param arguments The list of arguments for the command.
 * @return Generic "Object" from doExecute(), on success.
 * @throws IOException, IOException, on complete failure.
 */
public T execute(Object... arguments) throws Exception {
  Exception latestException;
  int counter = 0;
  while (true) {
    try {
      return doExecute(arguments);
    } catch (Exception exception) {
      LOG.error("Failure in Retriable command: {}", description, exception);
      latestException = exception;
    }
    counter++;
    RetryAction action = retryPolicy.shouldRetry(latestException, counter, 0, true);
    if (action.action == RetryPolicy.RetryAction.RetryDecision.RETRY) {
      ThreadUtil.sleepAtLeastIgnoreInterrupts(action.delayMillis);
    } else {
      break;
    }
  }

  throw new IOException("Couldn't run retriable-command: " + description, latestException);
}
 
开发者ID:HotelsDotCom,项目名称:circus-train,代码行数:30,代码来源:RetriableCommand.java

示例4: execute

import org.apache.hadoop.io.retry.RetryPolicy.RetryAction; //导入依赖的package包/类
/**
 * The execute() method invokes doExecute() until either:
 *  1. doExecute() succeeds, or
 *  2. the command may no longer be retried (e.g. runs out of retry-attempts).
 * @param arguments The list of arguments for the command.
 * @return Generic "Object" from doExecute(), on success.
 * @throws Exception
 */
public Object execute(Object... arguments) throws Exception {
  Exception latestException;
  int counter = 0;
  while (true) {
    try {
      return doExecute(arguments);
    } catch(Exception exception) {
      LOG.error("Failure in Retriable command: " + description, exception);
      latestException = exception;
    }
    counter++;
    RetryAction action = retryPolicy.shouldRetry(latestException, counter, 0, true);
    if (action.action == RetryPolicy.RetryAction.RetryDecision.RETRY) {
      ThreadUtil.sleepAtLeastIgnoreInterrupts(action.delayMillis);
    } else {
      break;
    }
  }

  throw new IOException("Couldn't run retriable-command: " + description,
                        latestException);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:31,代码来源:RetriableCommand.java

示例5: execute

import org.apache.hadoop.io.retry.RetryPolicy.RetryAction; //导入依赖的package包/类
/**
 * The execute() method invokes doExecute() until either:
 *  1. doExecute() succeeds, or
 *  2. the command may no longer be retried (e.g. runs out of retry-attempts).
 * @param arguments The list of arguments for the command.
 * @return Generic "Object" from doExecute(), on success.
 * @throws IOException, IOException, on complete failure.
 */
public Object execute(Object... arguments) throws Exception {
  Exception latestException;
  int counter = 0;
  while (true) {
    try {
      return doExecute(arguments);
    } catch(Exception exception) {
      LOG.error("Failure in Retriable command: " + description, exception);
      latestException = exception;
    }
    counter++;
    RetryAction action = retryPolicy.shouldRetry(latestException, counter, 0, true);
    if (action.action == RetryPolicy.RetryAction.RetryDecision.RETRY) {
      ThreadUtil.sleepAtLeastIgnoreInterrupts(action.delayMillis);
    } else {
      break;
    }
  }

  throw new IOException("Couldn't run retriable-command: " + description,
                        latestException);
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:31,代码来源:RetriableCommand.java

示例6: getDelayMillis

import org.apache.hadoop.io.retry.RetryPolicy.RetryAction; //导入依赖的package包/类
/**
 * Obtain a retry delay from list of RetryActions.
 */
private long getDelayMillis(List<RetryAction> actions) {
  long retVal = 0;
  for (RetryAction action : actions) {
    if (action.action == RetryAction.RetryDecision.FAILOVER_AND_RETRY ||
            action.action == RetryAction.RetryDecision.RETRY) {
      if (action.delayMillis > retVal) {
        retVal = action.delayMillis;
      }
    }
  }
  return retVal;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:16,代码来源:RetryInvocationHandler.java

示例7: getFailOverAction

import org.apache.hadoop.io.retry.RetryPolicy.RetryAction; //导入依赖的package包/类
/**
 * Return the first FAILOVER_AND_RETRY action.
 */
private RetryAction getFailOverAction(List<RetryAction> actions) {
  for (RetryAction action : actions) {
    if (action.action == RetryAction.RetryDecision.FAILOVER_AND_RETRY) {
      return action;
    }
  }
  return null;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:12,代码来源:RetryInvocationHandler.java

示例8: getFailAction

import org.apache.hadoop.io.retry.RetryPolicy.RetryAction; //导入依赖的package包/类
/**
 * Return the last FAIL action.. only if there are no RETRY actions.
 */
private RetryAction getFailAction(List<RetryAction> actions) {
  RetryAction fAction = null;
  for (RetryAction action : actions) {
    if (action.action == RetryAction.RetryDecision.FAIL) {
      fAction = action;
    } else {
      // Atleast 1 RETRY
      return null;
    }
  }
  return fAction;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:16,代码来源:RetryInvocationHandler.java

示例9: RetryInfo

import org.apache.hadoop.io.retry.RetryPolicy.RetryAction; //导入依赖的package包/类
RetryInfo(long delay, RetryAction action, long expectedFailoverCount,
    Exception failException) {
  this.delay = delay;
  this.retryTime = Time.monotonicNow() + delay;
  this.action = action;
  this.expectedFailoverCount = expectedFailoverCount;
  this.failException = failException;
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:9,代码来源:RetryInvocationHandler.java

示例10: newRetryInfo

import org.apache.hadoop.io.retry.RetryPolicy.RetryAction; //导入依赖的package包/类
static RetryInfo newRetryInfo(RetryPolicy policy, Exception e,
    Counters counters, boolean idempotentOrAtMostOnce,
    long expectedFailoverCount) throws Exception {
  RetryAction max = null;
  long maxRetryDelay = 0;
  Exception ex = null;

  final Iterable<Exception> exceptions = e instanceof MultiException ?
      ((MultiException) e).getExceptions().values()
      : Collections.singletonList(e);
  for (Exception exception : exceptions) {
    final RetryAction a = policy.shouldRetry(exception,
        counters.retries, counters.failovers, idempotentOrAtMostOnce);
    if (a.action != RetryAction.RetryDecision.FAIL) {
      // must be a retry or failover
      if (a.delayMillis > maxRetryDelay) {
        maxRetryDelay = a.delayMillis;
      }
    }

    if (max == null || max.action.compareTo(a.action) < 0) {
      max = a;
      if (a.action == RetryAction.RetryDecision.FAIL) {
        ex = exception;
      }
    }
  }

  return new RetryInfo(maxRetryDelay, max, expectedFailoverCount, ex);
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:31,代码来源:RetryInvocationHandler.java

示例11: isFailover

import org.apache.hadoop.io.retry.RetryPolicy.RetryAction; //导入依赖的package包/类
boolean isFailover() {
  return action != null
      && action.action ==  RetryAction.RetryDecision.FAILOVER_AND_RETRY;
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:5,代码来源:RetryInvocationHandler.java

示例12: isFail

import org.apache.hadoop.io.retry.RetryPolicy.RetryAction; //导入依赖的package包/类
boolean isFail() {
  return action != null
      && action.action ==  RetryAction.RetryDecision.FAIL;
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:5,代码来源:RetryInvocationHandler.java


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