Distributed & durable implementation similar to, but not directly inherited
ScheduledExecutorService.
IScheduledExecutorService
provides similar API to the
ScheduledExecutorService
with some exceptions
but also additional methods like scheduling tasks on a specific member, on a member who is owner of a specific key, executing a
tasks on multiple members etc.
Tasks (Runnable and/or Callable) scheduled on any partition through an IScheduledExecutorService,
yield some durability characteristics.
- When a node goes down (up to durability config), the scheduled task will get re-scheduled on a replica node.
- In the event of a partition migration, the task will be re-scheduled on the destination node.
Note: The above characteristics don't apply when scheduled on a Member.
Upon scheduling, a task acquires a resource handler, see
ScheduledTaskHandler. The handler is generated before the
actual scheduling of the task on the node, which allows for a way to access the future in an event of a node failure,
immediately after scheduling, and also guarantees no duplicates in the cluster by utilising a unique name per task. A name can
also be defined by the user by having the Runnable or Callable implement the
NamedTask.
Alternatively, one can wrap any task using the
TaskUtils#named(String,Callable)or
TaskUtils#named(String,Runnable) for simplicity.
One difference of this service in comparison to
ScheduledExecutorService is the
#scheduleAtFixedRate(Runnable,long,long,TimeUnit) which has similar semantic to
java.util.concurrent.ScheduledExecutorService#scheduleAtFixedRate(Runnable,long,long,TimeUnit). It guarantees a task won't
be executed by multiple threads concurrently. The difference is that this service will skip a scheduled execution if another
thread is still running the same task, instead of postponing its execution.
The other difference is this service does not offer an equivalent of
java.util.concurrent.ScheduledExecutorService#scheduleWithFixedDelay(Runnable,long,long,TimeUnit)
Tasks that are holding state that needs to be also durable across partitions, will need to implement the
StatefulTask interface.
Supports Quorum
com.hazelcast.config.QuorumConfig since 3.10 in cluster versions 3.10 and higher.