Package org.quartz.core
Interface JobStore
- All Known Implementing Classes:
RAMJobStore
public interface JobStore
The interface to be implemented by classes that want to provide a
Job and Trigger storage
mechanism for the QuartzScheduler's use.
Storage of Job s and Trigger s should be keyed on the combination of
their name and group for uniqueness.
- Author:
- James House, Eric Mueller
-
Method Summary
Modifier and TypeMethodDescriptionacquireNextTriggers(long noLaterThan, int maxCount, long timeWindow) Get a handle to the next trigger to be fired, and mark it as 'reserved' by the calling scheduler.Get the keys of all of thesJobgetTriggersForJob(String jobKey) Get all of the Triggers that are associated to the given Job.voidinitialize(SchedulerSignaler signaler) Called by the QuartzScheduler before theJobStoreis used, in order to give the it a chance to initialize.voidreleaseAcquiredTrigger(OperableTrigger trigger) Inform theJobStorethat the scheduler no longer plans to fire the givenTrigger, that it had previously acquired (reserved).booleanbooleanremoveTrigger(String triggerKey) Remove (delete) thewith the given key.TriggerbooleanreplaceTrigger(String triggerKey, OperableTrigger newTrigger) Remove (delete) thewith the given key, and store the new given one - which must be associated with the same job.TriggerretrieveCalendar(String calName) Retrieve the given.TriggerretrieveJob(String jobKey) retrieveTrigger(String triggerKey) Retrieve the given.TriggervoidCalled by the QuartzScheduler to inform theJobStorethat the scheduler has started.voidsetThreadPoolSize(int poolSize) Tells the JobStore the pool size used to execute jobsvoidStore the given.JobDetailvoidstoreJobAndTrigger(JobDetail newJob, OperableTrigger newTrigger) voidstoreTrigger(OperableTrigger newTrigger, boolean replaceExisting) Store the given.TriggervoidtriggeredJobComplete(OperableTrigger trigger, JobDetail jobDetail, Trigger.CompletedExecutionInstruction triggerInstCode) Inform theJobStorethat the scheduler has completed the firing of the givenTrigger(and the execution of its associatedJobcompleted, threw an exception, or was vetoed), and that thein the givenJobDataMapJobDetailshould be updated if theJobis stateful.triggersFired(List<OperableTrigger> triggers) Inform theJobStorethat the scheduler is now firing the givenTrigger(executing its associatedJob), that it had previously acquired (reserved).
-
Method Details
-
initialize
Called by the QuartzScheduler before theJobStoreis used, in order to give the it a chance to initialize.- Throws:
SchedulerConfigException
-
schedulerStarted
Called by the QuartzScheduler to inform theJobStorethat the scheduler has started.- Throws:
SchedulerException
-
storeJobAndTrigger
void storeJobAndTrigger(JobDetail newJob, OperableTrigger newTrigger) throws ObjectAlreadyExistsException, JobPersistenceException - Parameters:
newJob- TheJobDetailto be stored.newTrigger- TheTriggerto be stored.- Throws:
ObjectAlreadyExistsException- if aJobwith the same name/group already exists.JobPersistenceException
-
storeJob
void storeJob(JobDetail newJob, boolean replaceExisting) throws ObjectAlreadyExistsException, JobPersistenceException Store the given.JobDetail- Parameters:
newJob- TheJobDetailto be stored.replaceExisting- Iftrue, anyJobexisting in theJobStorewith the same name should be over-written.- Throws:
ObjectAlreadyExistsException- if aJobwith the same name/group already exists, and replaceExisting is set to false.JobPersistenceException
-
removeJob
Remove (delete) thewith the given key, and anyJobs that reference it.TriggerIf removal of the
Jobresults in an empty group, the group should be removed from theJobStore's list of known group names.- Returns:
trueif aJobwith the given name invalid input: '&' group was found and removed from the store.- Throws:
JobPersistenceException
-
retrieveJob
- Returns:
- The desired
Job, or null if there is no match. - Throws:
JobPersistenceException
-
storeTrigger
void storeTrigger(OperableTrigger newTrigger, boolean replaceExisting) throws ObjectAlreadyExistsException, JobPersistenceException Store the given.Trigger- Parameters:
newTrigger- TheTriggerto be stored.replaceExisting- Iftrue, anyTriggerexisting in theJobStorewith the same name invalid input: '&' group should be over-written.- Throws:
ObjectAlreadyExistsException- if aTriggerwith the same name/group already exists, and replaceExisting is set to false.JobPersistenceException
-
removeTrigger
Remove (delete) thewith the given key.TriggerIf removal of the
Triggerresults in an empty group, the group should be removed from theJobStore's list of known group names.If removal of the
Triggerresults in an 'orphaned'Jobthat is not 'durable', then theJobshould be deleted also.- Returns:
trueif aTriggerwith the given name was found and removed from the store.- Throws:
JobPersistenceException
-
replaceTrigger
boolean replaceTrigger(String triggerKey, OperableTrigger newTrigger) throws JobPersistenceException Remove (delete) thewith the given key, and store the new given one - which must be associated with the same job.Trigger- Parameters:
newTrigger- The newTriggerto be stored.- Returns:
trueif aTriggerwith the given name was found and removed from the store.- Throws:
JobPersistenceException
-
retrieveTrigger
Retrieve the given.Trigger- Returns:
- The desired
Trigger, or null if there is no match. - Throws:
JobPersistenceException
-
retrieveCalendar
Retrieve the given.Trigger- Parameters:
calName- The name of theCalendarto be retrieved.- Returns:
- The desired
Calendar, or null if there is no match. - Throws:
JobPersistenceException
-
getTriggersForJob
Get all of the Triggers that are associated to the given Job.If there are no matches, a zero-length array should be returned.
- Throws:
JobPersistenceException
-
getJobKeys
Get the keys of all of thesJobIf there are no jobs in the given group name, the result should be an empty collection (not
null).- Throws:
JobPersistenceException
-
acquireNextTriggers
List<OperableTrigger> acquireNextTriggers(long noLaterThan, int maxCount, long timeWindow) throws JobPersistenceException Get a handle to the next trigger to be fired, and mark it as 'reserved' by the calling scheduler.- Parameters:
noLaterThan- If > 0, the JobStore should only return a Trigger that will fire no later than the time represented in this value as milliseconds.- Throws:
JobPersistenceException
-
releaseAcquiredTrigger
Inform theJobStorethat the scheduler no longer plans to fire the givenTrigger, that it had previously acquired (reserved).- Throws:
JobPersistenceException
-
triggersFired
List<TriggerFiredResult> triggersFired(List<OperableTrigger> triggers) throws JobPersistenceException Inform theJobStorethat the scheduler is now firing the givenTrigger(executing its associatedJob), that it had previously acquired (reserved).- Returns:
- may return null if all the triggers or their calendars no longer exist, or if the trigger was not successfully put into the 'executing' state. Preference is to return an empty list if none of the triggers could be fired.
- Throws:
JobPersistenceException
-
triggeredJobComplete
void triggeredJobComplete(OperableTrigger trigger, JobDetail jobDetail, Trigger.CompletedExecutionInstruction triggerInstCode) throws JobPersistenceException Inform theJobStorethat the scheduler has completed the firing of the givenTrigger(and the execution of its associatedJobcompleted, threw an exception, or was vetoed), and that thein the givenJobDataMapJobDetailshould be updated if theJobis stateful.- Throws:
JobPersistenceException
-
setThreadPoolSize
void setThreadPoolSize(int poolSize) Tells the JobStore the pool size used to execute jobs- Parameters:
poolSize- amount of threads allocated for job execution- Since:
- 2.0
-