/** * Returns a strategy that sleeps a random amount of time before retrying. * * @param maximumTime the maximum time to sleep * @param timeUnit the unit of the maximum time * @return a wait strategy with a random wait time * @throws IllegalStateException if the maximum sleep time is <= 0. */ public static WaitStrategy randomWait(long maximumTime, @Nonnull TimeUnit timeUnit) { Preconditions.checkNotNull(timeUnit, "The time unit may not be null"); return new RandomWaitStrategy(0L, timeUnit.toMillis(maximumTime)); }
/** * Returns a strategy that sleeps a random amount of time before retrying. * * @param minimumTime the minimum time to sleep * @param minimumTimeUnit the unit of the minimum time * @param maximumTime the maximum time to sleep * @param maximumTimeUnit the unit of the maximum time * @return a wait strategy with a random wait time * @throws IllegalStateException if the minimum sleep time is < 0, or if the * maximum sleep time is less than (or equals to) the minimum. */ public static WaitStrategy randomWait(long minimumTime, @Nonnull TimeUnit minimumTimeUnit, long maximumTime, @Nonnull TimeUnit maximumTimeUnit) { Preconditions.checkNotNull(minimumTimeUnit, "The minimum time unit may not be null"); Preconditions.checkNotNull(maximumTimeUnit, "The maximum time unit may not be null"); return new RandomWaitStrategy(minimumTimeUnit.toMillis(minimumTime), maximumTimeUnit.toMillis(maximumTime)); }
/** * Returns a strategy that sleeps a random amount of time before retrying. * * @param minimumTime the minimum time to sleep * @param minimumTimeUnit the unit of the minimum time * @param maximumTime the maximum time to sleep * @param maximumTimeUnit the unit of the maximum time * @return a wait strategy with a random wait time * @throws IllegalStateException if the minimum sleep time is < 0, or if the * maximum sleep time is less than (or equals to) the minimum. */ public static WaitStrategy randomWait(long minimumTime, @Nonnull TimeUnit minimumTimeUnit, long maximumTime, @Nonnull TimeUnit maximumTimeUnit) { Preconditions.checkNotNull(minimumTimeUnit, "The minimum time unit may not be null"); Preconditions.checkNotNull(maximumTimeUnit, "The maximum time unit may not be null"); return new RandomWaitStrategy(minimumTimeUnit.toMillis(minimumTime), maximumTimeUnit.toMillis(maximumTime)); }
/** * Returns a strategy that sleeps a random amount of time before retrying. * * @param maximumTime the maximum time to sleep * @param timeUnit the unit of the maximum time * @return a wait strategy with a random wait time * @throws IllegalStateException if the maximum sleep time is <= 0. */ public static WaitStrategy randomWait(long maximumTime, @Nonnull TimeUnit timeUnit) { Preconditions.checkNotNull(timeUnit, "The time unit may not be null"); return new RandomWaitStrategy(0L, timeUnit.toMillis(maximumTime)); }