...
Code Block | ||
---|---|---|
| ||
public class CustomJobServiceImpl extends SimpleServiceComponent implements CustomJobService { public void onStart() { // Run the job only on the master and not on the read-only slaves if (myJcrRepositoryService.isReadOnly()) { LOG.warning("This cluster is read only. This job is only executed on the master. Job '" + JOB_NAME + "' not scheduled."); return; } public void onStop() { // Stop listening to update events on the schedule myConfigurationManagement.removeListener(this); // Remove the job from the schedule unscheduleJob(); } public void run(SchedulerJob job) { // Check whether this instance is the cluster task master if (!myFrameworkConfig.isClusterTaskMaster()) { LOG.log(Level.INFO, "Execution of job '" + JOB_NAME + "' skipped on this server."); return; } } |
...