/** * Causes the currently executing thread to sleep (temporarily cease execution) for the specified * number of milliseconds. The thread does not lose ownership of any monitors. */ public static void sleepMillis(long millis) throws InterruptedException { INSTANCE.sleep(millis); } }
/** * Runs the next iteration of the back-off policy, and returns whether to continue to retry the * operation. * * <p>If {@code true}, it will call {@link Sleeper#sleep(long)} with the specified number of * milliseconds from {@link BackOff#nextBackOffMillis()}. * * @param sleeper sleeper * @param backOff back-off policy * @return whether to continue to back off; in other words, whether {@link * BackOff#nextBackOffMillis()} did not return {@link BackOff#STOP} * @throws InterruptedException if any thread has interrupted the current thread */ public static boolean next(Sleeper sleeper, BackOff backOff) throws InterruptedException, IOException { long backOffTime = backOff.nextBackOffMillis(); if (backOffTime == BackOff.STOP) { return false; } sleeper.sleep(backOffTime); return true; }
LOG.info("Delaying request due to previous failures"); throttledSeconds.inc(WriteBatcherImpl.DATASTORE_BATCH_TARGET_LATENCY_MS / 1000); sleeper.sleep(WriteBatcherImpl.DATASTORE_BATCH_TARGET_LATENCY_MS); continue;