use of net.jodah.failsafe.RetryPolicy in project samza by apache.
the class TestTableRetryPolicy method testRandomRetry.
@Test
public void testRandomRetry() {
TableRetryPolicy retryPolicy = new TableRetryPolicy();
retryPolicy.withRandomBackoff(Duration.ofMillis(1000), Duration.ofMillis(2000));
// no-op
retryPolicy.withJitter(Duration.ofMillis(100));
Assert.assertEquals(TableRetryPolicy.BackoffType.RANDOM, retryPolicy.getBackoffType());
RetryPolicy fsRetry = FailsafeAdapter.valueOf(retryPolicy);
Assert.assertEquals(1000, fsRetry.getDelayMin().toMillis());
Assert.assertEquals(2000, fsRetry.getDelayMax().toMillis());
Assert.assertEquals("{\"randomMin\":{\"seconds\":1,\"nanos\":0},\"randomMax\":{\"seconds\":2,\"nanos\":0}," + "\"exponentialFactor\":0.0,\"backoffType\":\"RANDOM\",\"retryPredicate\":{}}", retryPolicy.toConfig(null, null).get("TableRetryPolicy"));
}
Aggregations