com.google.ipc.invalidation.util.ExponentialBackoffDelayGenerator Java Examples
The following examples show how to use
com.google.ipc.invalidation.util.ExponentialBackoffDelayGenerator.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AndroidChannel.java From android-chromium with BSD 2-Clause "Simplified" License | 6 votes |
/** * A utility function to run an async runnable with exponential backoff after failures. * @param runnable the asynchronous runnable. * @param scheduler used to schedule retries. * @param backOffGenerator a backoff generator that returns how to long to wait between retries. * The client must pass a new instance or reset the backoff generator before calling this * method. */ static void retryUntilSuccessWithBackoff(final SystemResources.Scheduler scheduler, final ExponentialBackoffDelayGenerator backOffGenerator, final AsyncRunnable runnable) { logger.fine("Running %s", runnable); runnable.run(new CompletionCallback() { @Override public void success() { logger.fine("%s succeeded", runnable); } @Override public void failure() { int nextDelay = backOffGenerator.getNextDelay(); logger.fine("%s failed, retrying after %s ms", nextDelay); scheduler.schedule(nextDelay, new Runnable() { @Override public void run() { retryUntilSuccessWithBackoff(scheduler, backOffGenerator, runnable); } }); } }); }
Example #2
Source File: AndroidChannel.java From android-chromium with BSD 2-Clause "Simplified" License | 6 votes |
@Override public void setSystemResources(SystemResources resources) { this.resources = resources; // Prefetch the auth sub token. Since this might require an HTTP round trip, we do this // as soon as the resources are available. // TODO: Find a better place to fetch the auth token; this method // doesn't sound like one that should be doing work. retryUntilSuccessWithBackoff(resources.getInternalScheduler(), new ExponentialBackoffDelayGenerator( new Random(), INITIAL_AUTH_TOKEN_RETRY_DELAY_MS, MAX_AUTH_TOKEN_RETRY_FACTOR), new AsyncRunnable() { @Override public void run(CompletionCallback callback) { requestAuthToken(callback); } }); }
Example #3
Source File: AndroidChannel.java From android-chromium with BSD 2-Clause "Simplified" License | 6 votes |
/** * A utility function to run an async runnable with exponential backoff after failures. * @param runnable the asynchronous runnable. * @param scheduler used to schedule retries. * @param backOffGenerator a backoff generator that returns how to long to wait between retries. * The client must pass a new instance or reset the backoff generator before calling this * method. */ static void retryUntilSuccessWithBackoff(final SystemResources.Scheduler scheduler, final ExponentialBackoffDelayGenerator backOffGenerator, final AsyncRunnable runnable) { logger.fine("Running %s", runnable); runnable.run(new CompletionCallback() { @Override public void success() { logger.fine("%s succeeded", runnable); } @Override public void failure() { int nextDelay = backOffGenerator.getNextDelay(); logger.fine("%s failed, retrying after %s ms", nextDelay); scheduler.schedule(nextDelay, new Runnable() { @Override public void run() { retryUntilSuccessWithBackoff(scheduler, backOffGenerator, runnable); } }); } }); }
Example #4
Source File: AndroidChannel.java From android-chromium with BSD 2-Clause "Simplified" License | 6 votes |
@Override public void setSystemResources(SystemResources resources) { this.resources = resources; // Prefetch the auth sub token. Since this might require an HTTP round trip, we do this // as soon as the resources are available. // TODO: Find a better place to fetch the auth token; this method // doesn't sound like one that should be doing work. retryUntilSuccessWithBackoff(resources.getInternalScheduler(), new ExponentialBackoffDelayGenerator( new Random(), INITIAL_AUTH_TOKEN_RETRY_DELAY_MS, MAX_AUTH_TOKEN_RETRY_FACTOR), new AsyncRunnable() { @Override public void run(CompletionCallback callback) { requestAuthToken(callback); } }); }
Example #5
Source File: RecurringTask.java From 365browser with Apache License 2.0 | 4 votes |
/** Returns the delay generator, if any. */ ExponentialBackoffDelayGenerator getDelayGenerator() { return delayGenerator; }
Example #6
Source File: RecurringTask.java From android-chromium with BSD 2-Clause "Simplified" License | 4 votes |
/** Returns the delay generator, if any. */ ExponentialBackoffDelayGenerator getDelayGenerator() { return delayGenerator; }
Example #7
Source File: RecurringTask.java From android-chromium with BSD 2-Clause "Simplified" License | 4 votes |
/** Returns the delay generator, if any. */ ExponentialBackoffDelayGenerator getDelayGenerator() { return delayGenerator; }