T
- the task typepublic interface BucketedExecutor<T extends Serializable>
construction time
, a
BucketedExecutorSettings
is provided that defines the maximum concurrency level, the task bucketing logic
and the BucketProcessor
that's called for processing buckets of tasks.Modifier and Type | Method and Description |
---|---|
void |
schedule(T task,
long delay,
TimeUnit timeUnit)
Add a task to be processed and schedule the
BucketProcessor to process the task's bucket with a
delay . |
void |
shutdown()
Shuts down the executor and releases all resources acquired by the executor.
|
void |
submit(T task)
Submit a task for processing and schedule the
BucketProcessor to process the task's bucket immediately. |
void schedule(@Nonnull T task, long delay, @Nonnull TimeUnit timeUnit)
BucketProcessor
to process the task's bucket with a
delay
. The task may still be processed earlier if a prior task for the same bucket has been scheduled
to run before the scheduled time.task
- the task to submitdelay
- the processing delaytimeUnit
- the delay's timeUnitvoid shutdown()
Note: All plugins which request
a bucketed
executor must shut it down when the plugin is disabled. Failing to do so will leave behind
orphaned instances. On plugin upgrade this can be particularly problematic given the fact that when the new
version of the plugin requests an executor it will be provided with the old stale instance which may trigger
unexpected behavior, like ClassCastException
s caused by ClassLoader
mismatches. This behaviour
will continue until the next time the system restarts (in a clustered environment this means every node).
void submit(@Nonnull T task)
BucketProcessor
to process the task's bucket immediately.
This is equivalent to calling schedule(Serializable, long, TimeUnit)
with a delay
of 0
.task
- the task to submitCopyright © 2022 Atlassian. All rights reserved.