Terracotta Quartz Scheduler Where introduces an Enterprise feature that allows jobs and triggers to be run on specified Terracotta clients instead of randomly chosen ones. Quartz Scheduler Where is a locality API that can be used to direct jobs to nodes having enough resources or the relevant data for successfully executing those jobs. Also introduced with Quartz 2.0 is a more readable fluent-interface approach to creating and scheduling jobs and triggers.
This section shows you how to install, configure, and use the locality API.
To access the Quartz Scheduler Locality API in a standard installation, include quartz-terracotta-ee-2.0.0-SNAPSHOT.jar in your classpath. This jar is found under the
For DSO installation, see this.
- Set the Enterprise Terracotta JobStore in
- Create or choose an implementation of
org.quartz.spi.InstanceIdGeneratorto generate node IDs to be used in the locality configuration. You can choose from one of the provided classes:
- org.quartz.simpl.HostnameInstanceIdGenerator – Returns the hostname as the instanceId.
- org.quartz.simpl.SimpleInstanceIdGenerator – Returns a mix of hostname and timestamp (to be sure we have a unique name), default!
- org.quartz.simpl.SystemPropertyInstanceIdGenerator – Returns the value of the
org.quartz.scheduler.instanceIdsystem property of the JVM. Available with Quartz 2.0 or higher.
The generator class must be specified in
- Configure the trigger and nodes (Terracotta clients) in
quartzLocality.properties. For example: Any job with a trigger in the "slowTriggers" group will fire only on nodes in the group "slowJobs", while jobs with triggers in "fastTriggers" will fire only on nodes in the group "group1".
quartzLocality.propertiesmust be on the classpath, the same as
Use in Application Code
The following example is a code snippet that uses Quartz Scheduler Where to create a locality-aware trigger and a locality-aware job.
This example showed how memory and node-group constraints are used to route locality-aware triggers and jobs. trigger2, for example, is set to fire myJob2 on a node in a specific group ("allNodes") with a specified minimum amount of free memory. A constraint based on operating system (Linux, Microsoft Windows, Apple OSX, and Oracle Solaris) is also available.
Locality With the Standard Quartz Scheduler API
It is also possible to add locality to jobs and triggers created with the standard Quartz Scheduler API by assigning the triggers to a trigger group specified in
DSO users must install tim-quartz-2.0-ee. First, add the TIM to your Terracotta configuration file (
tc-config.xml by default):
To install the TIMs declared in the Terracotta configuration file, use the following command (UNIX/Linux):
tim-get.bat with Microsoft Windows.