minor modifications

This commit is contained in:
priyank-sriv 2019-07-23 01:52:22 +05:30
parent 4e22e8b3c6
commit cb686cf9c4
3 changed files with 8 additions and 13 deletions

View File

@ -0,0 +1,2 @@
### Relevant Articles:
- [Better Retries with Exponential Backoff and Jitter](https://baeldung.com/retries-with-exponential-backoff-and-jitter)

View File

@ -8,13 +8,6 @@
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<!--<parent>-->
<!--<artifactId>patterns</artifactId>-->
<!--<groupId>com.baeldung</groupId>-->
<!--<version>1.0.0-SNAPSHOT</version>-->
<!--<relativePath>..</relativePath>-->
<!--</parent>-->
<dependencies>
<dependency>
<groupId>junit</groupId>

View File

@ -39,7 +39,7 @@ public class BackoffWithJitterTest {
}
private PingPongService service;
private static final int NUM_TASKS = 8;
private static final int NUM_CONCURRENT_CLIENTS = 8;
@Before
public void setUp() {
@ -55,7 +55,7 @@ public class BackoffWithJitterTest {
try {
pingPongFn.apply("Hello");
} catch (PingPongServiceException e) {
verify(service, times(MAX_TRIES)).call(anyString());
verify(service, times(MAX_RETRIES)).call(anyString());
}
}
@ -73,8 +73,8 @@ public class BackoffWithJitterTest {
private void test(IntervalFunction intervalFn) throws InterruptedException {
Function<String, String> pingPongFn = getRetryablePingPongFn(intervalFn);
ExecutorService executors = newFixedThreadPool(NUM_TASKS);
List<Callable<String>> tasks = nCopies(NUM_TASKS, () -> pingPongFn.apply("Hello"));
ExecutorService executors = newFixedThreadPool(NUM_CONCURRENT_CLIENTS);
List<Callable<String>> tasks = nCopies(NUM_CONCURRENT_CLIENTS, () -> pingPongFn.apply("Hello"));
when(service.call(anyString())).thenThrow(PingPongServiceException.class);
@ -83,7 +83,7 @@ public class BackoffWithJitterTest {
private Function<String, String> getRetryablePingPongFn(IntervalFunction intervalFn) {
RetryConfig retryConfig = RetryConfig.custom()
.maxAttempts(MAX_TRIES)
.maxAttempts(MAX_RETRIES)
.intervalFunction(intervalFn)
.retryExceptions(PingPongServiceException.class)
.build();
@ -98,6 +98,6 @@ public class BackoffWithJitterTest {
static final Long INITIAL_INTERVAL = 1000L;
static final Double MULTIPLIER = 2.0D;
static final Double RANDOMIZATION_FACTOR = 0.6D;
static final Integer MAX_TRIES = 4;
static final Integer MAX_RETRIES = 4;
}
}