Interface ScheduleOptions
-
@ProviderType public interface ScheduleOptions
Scheduler options provide an extensible way of defining how to schedule a job. An option can be created via the scheduler.- Since:
- 2.3
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ScheduleOptions
canRunConcurrently(boolean flag)
Flag indicating whether the job can be run concurrently.ScheduleOptions
config(java.util.Map<java.lang.String,java.io.Serializable> config)
Add optional configuration for the job.ScheduleOptions
name(java.lang.String name)
Sets the name of the job.ScheduleOptions
onInstancesOnly(java.lang.String[] slingIds)
List of Sling IDs this job should be run on.ScheduleOptions
onLeaderOnly(boolean flag)
Flag indicating whether the job should only be run on the leader.ScheduleOptions
onSingleInstanceOnly(boolean flag)
Flag indicating whether the job should only be run on a single instance in a cluster This defaults to false.ScheduleOptions
threadPoolName(java.lang.String name)
Define the thread pool to be used.
-
-
-
Method Detail
-
config
ScheduleOptions config(java.util.Map<java.lang.String,java.io.Serializable> config)
Add optional configuration for the job.- Parameters:
config
- An optional configuration object - this configuration is only passed to the job the job implementsJob
.- Returns:
- The schedule options.
-
name
ScheduleOptions name(java.lang.String name)
Sets the name of the job. A job only needs a name if it is scheduled and should be cancelled later on. The name can then be used to cancel the job. If a second job with the same name is started, the second one replaces the first one.- Parameters:
name
- The job name- Returns:
- The schedule options.
-
canRunConcurrently
ScheduleOptions canRunConcurrently(boolean flag)
Flag indicating whether the job can be run concurrently. This defaults to false.- Parameters:
flag
- Whether this job can run even if previous scheduled runs are still running.- Returns:
- The schedule options.
-
onLeaderOnly
ScheduleOptions onLeaderOnly(boolean flag)
Flag indicating whether the job should only be run on the leader. This defaults to false. If this job is scheduled on the leader it is started. Scheduling this job on any other instance will not start it. This option should only be used if the schedule call is done on all instances in the cluster. If no topology information is available (= no Apache Sling Discovery Implementation active) the job is not run at all. IfonSingleInstanceOnly(boolean)
oronInstancesOnly(String[])
has been called before, that option is reset and overwritten by the value of this method.- Parameters:
flag
- Whether this job should only be run on the leader- Returns:
- The schedule options.
-
onSingleInstanceOnly
ScheduleOptions onSingleInstanceOnly(boolean flag)
Flag indicating whether the job should only be run on a single instance in a cluster This defaults to false. Scheduling this job might start it or not depending on the topology information. This option should only be used if the schedule call is done on all instances in the cluster. If no topology information is available (= no Apache Sling Discovery Implementation active) this job is not run at all. IfonLeaderOnly(boolean)
oronInstancesOnly(String[])
has been called before, that option is reset and overwritten by the value of this method.- Parameters:
flag
- Whether this job should only be run on a single instance.- Returns:
- The schedule options.
-
onInstancesOnly
ScheduleOptions onInstancesOnly(java.lang.String[] slingIds)
List of Sling IDs this job should be run on. This job is only started if the current instance is in the set of IDs. This option should only be used, if it is scheduled on all instances in the cluster. IfonLeaderOnly(boolean)
oronSingleInstanceOnly(boolean)
has been called before, that option is reset and overwritten by the value of this method.- Parameters:
slingIds
- Array of Sling IDs this job should run on- Returns:
- The schedule options.
-
threadPoolName
ScheduleOptions threadPoolName(java.lang.String name)
Define the thread pool to be used. Scheduled jobs can run using different thread pools. By default, the default thread pool of the scheduler is used. If a thread pool name is specified, it is up to the scheduler to put the job in the defined thread pool or any other thread pool. This option must be used with special care as it might create new thread pools. It should only be used if there is a good reason to not use the default thread pool.- Parameters:
name
- The thread pool name- Returns:
- The schedule options.
- Since:
- 2.5.0
-
-