Search in sources :

Example 1 with ExponentialBackOff

use of org.activityinfo.legacy.shared.util.ExponentialBackOff in project activityinfo by bedatadriven.

the class ExponentialBackOffTest method test.

@Test
public void test() throws IOException {
    NanoClock nanoClock = new NanoClock() {

        @Override
        public long nanoTime() {
            return System.nanoTime();
        }
    };
    ExponentialBackOff defaultBackOff = new ExponentialBackOff.Builder().setNanoClock(nanoClock).build();
    ExponentialBackOff backOff = new ExponentialBackOff.Builder().setInitialIntervalMillis(TimeUnit.SECONDS.toMillis(10)).setMultiplier(// increase in 3 times
    2).setNanoClock(nanoClock).build();
    for (int i = 0; i < 10; i++) {
        System.out.println(defaultBackOff.nextBackOffMillis() + " " + backOff.nextBackOffMillis());
    }
}
Also used : NanoClock(org.activityinfo.legacy.shared.util.NanoClock) ExponentialBackOff(org.activityinfo.legacy.shared.util.ExponentialBackOff) Test(org.junit.Test)

Aggregations

ExponentialBackOff (org.activityinfo.legacy.shared.util.ExponentialBackOff)1 NanoClock (org.activityinfo.legacy.shared.util.NanoClock)1 Test (org.junit.Test)1