Class ClusterTaskScheduler
- All Implemented Interfaces:
org.springframework.scheduling.TaskScheduler
@Scheduled(cron = "...", scheduler = ClusterTaskScheduler.NAME), and
the scheduler registers it as a job of the kernel's job scheduler, whose
store the nodes of a cluster share: every node registers the same job, the
store fires each of its triggers on one node, and that node runs its own
copy of the method. A scheduled method that names no scheduler runs on every
node.
The job is named after the method, so that every node registers the same
one, and belongs to JobSchedulerService.RUNTIME_JOB_GROUP, which the
job scheduler keeps when a node restarts. A cron expression is read as Spring
reads it; a fixed delay runs at a fixed rate, one run at a time.
The job outlives its method: a version that removes or renames a method
naming this scheduler ships an upgrade plugin that removes its job,
removeJob(new JobInfo("<class>.<method>", JobSchedulerService.RUNTIME_JOB_GROUP, null));
a job no node declares is otherwise fired again once and reported at each
of its runs.
A run missed while no node was up follows Quartz's misfire policy, not Spring's: a cron late by more than the store's misfire threshold fires once as soon as a node can; a fixed rate skips the runs it missed and goes on at the next time of its schedule. That includes its first run, which counts from the first registration of the method in the cluster's store: a stored job keeps its times while its period is unchanged, so a later change of its initial delay has no effect. A node that starts Quartz later than that time plus the misfire threshold runs the method first at the next time of its schedule, at most one period later.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionClusterTaskScheduler(Supplier<org.exoplatform.services.scheduler.JobSchedulerService> jobSchedulerService) -
Method Summary
Modifier and TypeMethodDescriptionscheduleAtFixedRate(Runnable task, Duration period) scheduleAtFixedRate(Runnable task, Instant startTime, Duration period) scheduleWithFixedDelay(Runnable task, Duration delay) scheduleWithFixedDelay(Runnable task, Instant startTime, Duration delay) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.scheduling.TaskScheduler
getClock, schedule, scheduleAtFixedRate, scheduleAtFixedRate, scheduleWithFixedDelay, scheduleWithFixedDelay
-
Field Details
-
NAME
The name of the scheduler, which a scheduled method gives as its scheduler.- See Also:
-
-
Constructor Details
-
ClusterTaskScheduler
public ClusterTaskScheduler(Supplier<org.exoplatform.services.scheduler.JobSchedulerService> jobSchedulerService) - Parameters:
jobSchedulerService- the kernel's job scheduler, looked up when a method is registered, so that a context with no scheduled method naming this scheduler starts without it
-
-
Method Details
-
schedule
- Specified by:
schedulein interfaceorg.springframework.scheduling.TaskScheduler
-
scheduleAtFixedRate
- Specified by:
scheduleAtFixedRatein interfaceorg.springframework.scheduling.TaskScheduler
-
scheduleAtFixedRate
- Specified by:
scheduleAtFixedRatein interfaceorg.springframework.scheduling.TaskScheduler
-
scheduleWithFixedDelay
- Specified by:
scheduleWithFixedDelayin interfaceorg.springframework.scheduling.TaskScheduler
-
scheduleWithFixedDelay
- Specified by:
scheduleWithFixedDelayin interfaceorg.springframework.scheduling.TaskScheduler
-
schedule
- Specified by:
schedulein interfaceorg.springframework.scheduling.TaskScheduler
-