作者:纤妍内衣天旺店 | 来源:互联网 | 2023-08-26 16:53
本文整理了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);
}