use of org.activityinfo.legacy.shared.util.NanoClock in project activityinfo by bedatadriven.
the class RemoteDispatcherTest method setUp.
@Before
public void setUp() {
service = createMock("remoteService", RemoteCommandServiceAsync.class);
proxy = createMock("proxy", CommandCache.class);
AuthenticatedUser auth = new AuthenticatedUser(AUTH_TOKEN, 1, "alex@alex.com");
BackOff backOff = new ExponentialBackOff.Builder().setInitialIntervalMillis(MergingDispatcher.ADVISORY_GET_LOCK_TIMEOUT).setMultiplier(// increase in 2 times
2).setNanoClock(new NanoClock() {
@Override
public long nanoTime() {
return System.nanoTime();
}
}).build();
dispatcher = new CachingDispatcher(proxyManager, new MergingDispatcher(new RemoteDispatcher(auth, service, "en"), scheduler, backOff));
}
use of org.activityinfo.legacy.shared.util.NanoClock 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());
}
}
Aggregations