use of com.hazelcast.jet.retry.RetryStrategy in project hazelcast by hazelcast.
the class CdcSourceP method init.
@Override
protected void init(@Nonnull Context context) {
// workaround for https://github.com/hazelcast/hazelcast-jet/issues/2603
DriverManager.getDrivers();
String name = getName(properties);
this.logger = context.logger();
RetryStrategy retryStrategy = getRetryStrategy(properties);
log(logger, name, "retry strategy", retryStrategy);
this.reconnectTracker = new RetryTracker(retryStrategy);
snapshotting = !NONE.equals(context.processingGuarantee());
if (!snapshotting) {
this.commitPeriod = getCommitPeriod(properties);
log(logger, name, "commit period", commitPeriod);
if (commitPeriod > 0) {
lastCommitTime = System.nanoTime();
}
}
this.clearStateOnReconnect = getClearStateOnReconnect(properties);
log(logger, name, "clear state on reconnect", clearStateOnReconnect);
}
use of com.hazelcast.jet.retry.RetryStrategy in project hazelcast by hazelcast.
the class RetryTrackerTest method when_reset.
@Test
public void when_reset() {
RetryStrategy strategy = RetryStrategies.custom().maxAttempts(1).build();
RetryTracker tracker = new RetryTracker(strategy, timeSupplier);
assertFalse(tracker.needsToWait());
// 1st retry
tracker.attemptFailed();
assertTrue(tracker.shouldTryAgain());
advanceTime(tracker.getNextWaitTimeMs());
assertFalse(tracker.needsToWait());
tracker.attemptFailed();
assertFalse(tracker.shouldTryAgain());
tracker.reset();
// 1st retry
tracker.attemptFailed();
assertTrue(tracker.shouldTryAgain());
advanceTime(tracker.getNextWaitTimeMs());
assertFalse(tracker.needsToWait());
tracker.attemptFailed();
assertFalse(tracker.shouldTryAgain());
}
use of com.hazelcast.jet.retry.RetryStrategy in project hazelcast by hazelcast.
the class RetryTrackerTest method when_attemptsZero_doNotRetry.
@Test
public void when_attemptsZero_doNotRetry() {
RetryStrategy strategy = RetryStrategies.custom().maxAttempts(0).build();
RetryTracker tracker = new RetryTracker(strategy, timeSupplier);
assertFalse(tracker.needsToWait());
tracker.attemptFailed();
assertFalse(tracker.shouldTryAgain());
}
use of com.hazelcast.jet.retry.RetryStrategy in project hazelcast by hazelcast.
the class RetryTrackerTest method when_attemptsPositive_doRetry.
@Test
public void when_attemptsPositive_doRetry() {
RetryStrategy strategy = RetryStrategies.custom().maxAttempts(2).build();
RetryTracker tracker = new RetryTracker(strategy, timeSupplier);
assertFalse(tracker.needsToWait());
// 1st retry
tracker.attemptFailed();
assertTrue(tracker.shouldTryAgain());
advanceTime(tracker.getNextWaitTimeMs());
assertFalse(tracker.needsToWait());
// 2nd retry
tracker.attemptFailed();
assertTrue(tracker.shouldTryAgain());
advanceTime(tracker.getNextWaitTimeMs());
assertFalse(tracker.needsToWait());
tracker.attemptFailed();
assertFalse(tracker.shouldTryAgain());
}
use of com.hazelcast.jet.retry.RetryStrategy in project hazelcast by hazelcast.
the class RetryTrackerTest method when_constantRetryPeriod.
@Test
public void when_constantRetryPeriod() {
RetryStrategy strategy = RetryStrategies.custom().intervalFunction(IntervalFunction.constant(1000)).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(999);
assertTrue(tracker.needsToWait());
advanceTime(1);
assertFalse(tracker.needsToWait());
}
Aggregations