use of com.hazelcast.jet.retry.RetryStrategy in project hazelcast by hazelcast.
the class RetryTrackerTest method when_attemptsNegative_retryIndefinitely.
@Test
public void when_attemptsNegative_retryIndefinitely() {
RetryStrategy strategy = RetryStrategies.custom().maxAttempts(-1).build();
RetryTracker tracker = new RetryTracker(strategy, timeSupplier);
assertFalse(tracker.needsToWait());
for (int i = 0; i < 1_000_000; i++) {
tracker.attemptFailed();
assertTrue(tracker.shouldTryAgain());
assertTrue(tracker.needsToWait());
advanceTime(tracker.getNextWaitTimeMs());
assertFalse(tracker.needsToWait());
}
}
use of com.hazelcast.jet.retry.RetryStrategy in project hazelcast by hazelcast.
the class RetryTrackerTest method when_exponentialBackoff.
@Test
public void when_exponentialBackoff() {
RetryStrategy strategy = RetryStrategies.custom().intervalFunction((IntervalFunction) attempt -> attempt * 1000L).build();
RetryTracker tracker = new RetryTracker(strategy, timeSupplier);
assertFalse(tracker.needsToWait());
tracker.attemptFailed();
assertTrue(tracker.needsToWait());
advanceTime(999);
assertTrue(tracker.needsToWait());
advanceTime(1);
assertFalse(tracker.needsToWait());
tracker.attemptFailed();
assertTrue(tracker.needsToWait());
advanceTime(1999);
assertTrue(tracker.needsToWait());
advanceTime(1);
assertFalse(tracker.needsToWait());
tracker.attemptFailed();
assertTrue(tracker.needsToWait());
advanceTime(2999);
assertTrue(tracker.needsToWait());
advanceTime(1);
assertFalse(tracker.needsToWait());
}
Aggregations