热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

com.github.rholder.retry.RetryerBuilder.withBlockStrategy()方法的使用及代码示例

本文整理了Java中com.github.rholder.retry.RetryerBuilder.withBlockStrategy方法的一些代码示例,展示了

本文整理了Java中com.github.rholder.retry.RetryerBuilder.withBlockStrategy方法的一些代码示例,展示了RetryerBuilder.withBlockStrategy的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RetryerBuilder.withBlockStrategy方法的具体详情如下:
包路径:com.github.rholder.retry.RetryerBuilder
类名称:RetryerBuilder
方法名:withBlockStrategy

RetryerBuilder.withBlockStrategy介绍

[英]Sets the block strategy used to decide how to block between retry attempts. The default strategy is to use Thread#sleep().
[中]设置用于决定如何在重试尝试之间进行阻止的阻止策略。默认策略是使用线程#sleep()。

代码示例

代码示例来源:origin: Netflix/conductor

))
.withStopStrategy(StopStrategies.stopAfterAttempt(retryCount))
.withBlockStrategy(BlockStrategies.threadSleepStrategy())
.withRetryListener(new RetryListener() {
@Override

代码示例来源:origin: com.netflix.conductor/conductor-common

))
.withStopStrategy(StopStrategies.stopAfterAttempt(retryCount))
.withBlockStrategy(BlockStrategies.threadSleepStrategy())
.withRetryListener(new RetryListener() {
@Override

代码示例来源:origin: rhuffman/re-retrying

@Test
public void testWithBlockStrategy() throws Exception {
Callable callable = notNullAfter5Attempts();
final AtomicInteger counter = new AtomicInteger();
BlockStrategy blockStrategy = sleepTime -> counter.incrementAndGet();
Retryer retryer = RetryerBuilder.newBuilder()
.withBlockStrategy(blockStrategy)
.retryIfResult(Objects::isNull)
.build();
final int retryCount = 5;
boolean result = retryer.call(callable);
assertTrue(result);
assertEquals(counter.get(), retryCount);
}

代码示例来源:origin: olacabs/fabric

.withStopStrategy(StopStrategies.neverStop())
.withWaitStrategy(WaitStrategies.fixedWait(1, TimeUnit.SECONDS))
.withBlockStrategy(BlockStrategies.threadSleepStrategy()).build();
final List brokerList = parseBrokerString(brokers);
try {

代码示例来源:origin: rhuffman/re-retrying

@Test
public void testCallWhenBlockerIsInterrupted() throws Exception {
Retryer retryer = RetryerBuilder.newBuilder()
.retryIfException()
.withStopStrategy(StopStrategies.stopAfterAttempt(10))
.withBlockStrategy(new InterruptingBlockStrategy(3))
.build();
Thrower thrower = new Thrower(Exception.class, 5);
boolean interrupted = false;
try {
retryer.call(thrower);
fail("Should have thrown");
} catch (InterruptedException e) {
interrupted = true;
}
//noinspection ConstantConditions
assertTrue(interrupted);
assertEquals(3, thrower.invocations);
}

代码示例来源:origin: rhuffman/re-retrying

@Test
public void testRunWhenBlockerIsInterrupted() throws Exception {
Retryer retryer = RetryerBuilder.newBuilder()
.retryIfException()
.withStopStrategy(StopStrategies.stopAfterAttempt(10))
.withBlockStrategy(new InterruptingBlockStrategy(3))
.build();
Thrower thrower = new Thrower(Exception.class, 5);
boolean interrupted = false;
try {
retryer.run(thrower);
fail("Should have thrown");
} catch (InterruptedException e) {
interrupted = true;
}
//noinspection ConstantConditions
assertTrue(interrupted);
assertEquals(3, thrower.invocations);
}

推荐阅读
author-avatar
纤妍内衣天旺店
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有