protected void doSchedule(Object taskKey, Runnable task, ListenableFuture<?> lf, long delayInMs) { LimiterContainer lc = getLimiterContainer(taskKey); lc.limiter.doSchedule(lc.wrap(task), lf, delayInMs); }
protected void doSchedule(Object taskKey, Runnable task, ListenableFuture<?> lf, long delayInMs) { LimiterContainer lc = getLimiterContainer(taskKey); lc.limiter.doSchedule(lc.wrap(task), lf, delayInMs); }
/** * Schedule a fixed rate recurring task to run. The recurring delay will be the same, * regardless of how long task execution takes. A given runnable will not run concurrently * (unless it is submitted to the scheduler multiple times). Instead of execution takes longer * than the period, the next run will occur immediately (given thread availability in the pool). * <p> * Unlike {@link java.util.concurrent.ScheduledExecutorService} if the task throws an exception, * subsequent executions are NOT suppressed or prevented. So if the task throws an exception on * every run, the task will continue to be executed at the provided recurring delay (possibly * throwing an exception on each execution). * <p> * The key is used to identify this threads execution limit. Tasks with matching keys will be * limited concurrent execution to the level returned by {@link #getMaxConcurrencyPerKey()}. * <p> * See also: {@link SubmitterScheduler#scheduleAtFixedRate(Runnable, long, long)} * * @param taskKey Key to use for identifying execution limit * @param task runnable to be executed * @param initialDelay delay in milliseconds until first run * @param period amount of time in milliseconds between the start of recurring executions */ public void scheduleAtFixedRate(Object taskKey, Runnable task, long initialDelay, long period) { ArgumentVerifier.assertNotNull(taskKey, "taskKey"); LimiterContainer lc = getLimiterContainer(taskKey); // we don't wrap the task here because it is recurring, this limiter can never be removed lc.limiter.scheduleAtFixedRate(task, initialDelay, period); }
/** * Schedule a fixed delay recurring task to run. The recurring delay time will be from the * point where execution has finished. So the execution frequency is the * {@code recurringDelay + runtime} for the provided task. * <p> * Unlike {@link java.util.concurrent.ScheduledExecutorService} if the task throws an exception, * subsequent executions are NOT suppressed or prevented. So if the task throws an exception on * every run, the task will continue to be executed at the provided recurring delay (possibly * throwing an exception on each execution). * <p> * The key is used to identify this threads execution limit. Tasks with matching keys will be * limited concurrent execution to the level returned by {@link #getMaxConcurrencyPerKey()}. * <p> * See also: {@link SubmitterScheduler#scheduleWithFixedDelay(Runnable, long, long)} * * @param taskKey Key to use for identifying execution limit * @param task runnable to be executed * @param initialDelay delay in milliseconds until first run * @param recurringDelay delay in milliseconds for running task after last finish */ public void scheduleWithFixedDelay(Object taskKey, Runnable task, long initialDelay, long recurringDelay) { ArgumentVerifier.assertNotNull(taskKey, "taskKey"); LimiterContainer lc = getLimiterContainer(taskKey); // we don't wrap the task here because it is recurring, this limiter can never be removed lc.limiter.scheduleWithFixedDelay(task, initialDelay, recurringDelay); }
/** * Schedule a fixed delay recurring task to run. The recurring delay time will be from the * point where execution has finished. So the execution frequency is the * {@code recurringDelay + runtime} for the provided task. * <p> * Unlike {@link java.util.concurrent.ScheduledExecutorService} if the task throws an exception, * subsequent executions are NOT suppressed or prevented. So if the task throws an exception on * every run, the task will continue to be executed at the provided recurring delay (possibly * throwing an exception on each execution). * <p> * The key is used to identify this threads execution limit. Tasks with matching keys will be * limited concurrent execution to the level returned by {@link #getMaxConcurrencyPerKey()}. * <p> * See also: {@link SubmitterScheduler#scheduleWithFixedDelay(Runnable, long, long)} * * @param taskKey Key to use for identifying execution limit * @param task runnable to be executed * @param initialDelay delay in milliseconds until first run * @param recurringDelay delay in milliseconds for running task after last finish */ public void scheduleWithFixedDelay(Object taskKey, Runnable task, long initialDelay, long recurringDelay) { ArgumentVerifier.assertNotNull(taskKey, "taskKey"); LimiterContainer lc = getLimiterContainer(taskKey); // we don't wrap the task here because it is recurring, this limiter can never be removed lc.limiter.scheduleWithFixedDelay(task, initialDelay, recurringDelay); }
/** * Schedule a fixed rate recurring task to run. The recurring delay will be the same, * regardless of how long task execution takes. A given runnable will not run concurrently * (unless it is submitted to the scheduler multiple times). Instead of execution takes longer * than the period, the next run will occur immediately (given thread availability in the pool). * <p> * Unlike {@link java.util.concurrent.ScheduledExecutorService} if the task throws an exception, * subsequent executions are NOT suppressed or prevented. So if the task throws an exception on * every run, the task will continue to be executed at the provided recurring delay (possibly * throwing an exception on each execution). * <p> * The key is used to identify this threads execution limit. Tasks with matching keys will be * limited concurrent execution to the level returned by {@link #getMaxConcurrencyPerKey()}. * <p> * See also: {@link SubmitterScheduler#scheduleAtFixedRate(Runnable, long, long)} * * @param taskKey Key to use for identifying execution limit * @param task runnable to be executed * @param initialDelay delay in milliseconds until first run * @param period amount of time in milliseconds between the start of recurring executions */ public void scheduleAtFixedRate(Object taskKey, Runnable task, long initialDelay, long period) { ArgumentVerifier.assertNotNull(taskKey, "taskKey"); LimiterContainer lc = getLimiterContainer(taskKey); // we don't wrap the task here because it is recurring, this limiter can never be removed lc.limiter.scheduleAtFixedRate(task, initialDelay, period); }