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


Java RetryerBuilder.build方法代码示例

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


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

示例1: buildRetryer

import com.github.rholder.retry.RetryerBuilder; //导入方法依赖的package包/类
/**
 * Build Retryer.
 * - If Writer implements Retriable, it will use the RetryerBuilder from the writer.
 * - Otherwise, it will use DEFAULT writer builder.
 *
 * - If Gobblin metrics is enabled, it will emit all failure count in to metrics.
 *
 * @param state
 * @return
 */
private Retryer<Void> buildRetryer(State state) {
  RetryerBuilder<Void> builder = null;
  if (writer instanceof Retriable) {
    builder = ((Retriable) writer).getRetryerBuilder();
  } else {
    builder = createRetryBuilder(state);
  }

  if (GobblinMetrics.isEnabled(state)) {
    final Optional<Meter> retryMeter = Optional.of(Instrumented.getMetricContext(state, getClass()).meter(FAILED_RETRY_WRITES_METER));

    builder.withRetryListener(new RetryListener() {
      @Override
      public <V> void onRetry(Attempt<V> attempt) {
        if (attempt.hasException()) {
          LOG.warn("Caught exception. This may be retried.", attempt.getExceptionCause());
          Instrumented.markMeter(retryMeter);
          failedWrites++;
        }
      }
    });
  }
  return builder.build();
}
 
开发者ID:apache,项目名称:incubator-gobblin,代码行数:35,代码来源:RetryWriter.java

示例2: retry

import com.github.rholder.retry.RetryerBuilder; //导入方法依赖的package包/类
/**
* Attempt to make a call, retrying on timeout
* @param times
* @param callable
* @return
* @throws ExecutionException
* @throws RetryException
*/
public static <T> T retry(int times, Callable<T> callable) throws ExecutionException, RetryException {
  
  // Build the retryer
  RetryerBuilder<T> builder = RetryerBuilder.newBuilder();
  builder.withStopStrategy(StopStrategies.stopAfterAttempt(times));
  builder.withWaitStrategy(WaitStrategies.randomWait(2, TimeUnit.SECONDS, 20, TimeUnit.SECONDS));
  Retryer<T> retryer = builder.build();
  return retryer.call(callable);
  
}
 
开发者ID:zillabyte,项目名称:motherbrain,代码行数:19,代码来源:Utils.java

示例3: init

import com.github.rholder.retry.RetryerBuilder; //导入方法依赖的package包/类
@Override
protected Retryer<Boolean> init(final RetryerBuilder<Boolean> builder) {
    builder.retryIfResult(Predicates.or(Predicates.isNull(), Predicates.equalTo(false)));
    return builder.build();
}
 
开发者ID:jeoffreylim,项目名称:maelstrom,代码行数:6,代码来源:InfiniteRetryStrategy.java


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