Interface JobStore
-
- All Known Implementing Classes:
JobStoreCMT,JobStoreSupport,JobStoreTX,RAMJobStore
public interface JobStoreThe interface to be implemented by classes that want to provide a
andJobstorage mechanism for theTrigger's use.QuartzSchedulerStorage of
Jobs andTriggers should be keyed on the combination of their name and group for uniqueness.- Author:
- James House, Eric Mueller
- See Also:
QuartzScheduler,Trigger,Job,JobDetail,JobDataMap,Calendar
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.List<OperableTrigger>acquireNextTriggers(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.booleancheckExists(JobKey jobKey)Determine whether aJobwith the given identifier already exists within the scheduler.booleancheckExists(TriggerKey triggerKey)Determine whether aTriggerwith the given identifier already exists within the scheduler.voidclearAllSchedulingData()longgetAcquireRetryDelay(int failureCount)Get the amount of time (in ms) to wait when accessing this job store repeatedly fails.java.util.List<java.lang.String>getCalendarNames()Get the names of all of thes in theCalendarJobStore.longgetEstimatedTimeToReleaseAndAcquireTrigger()How long (in milliseconds) theJobStoreimplementation estimates that it will take to release a trigger and acquire a new one.java.util.List<java.lang.String>getJobGroupNames()Get the names of all of thegroups.Jobjava.util.Set<JobKey>getJobKeys(GroupMatcher<JobKey> matcher)Get the keys of all of thes that have the given group name.JobintgetNumberOfCalendars()Get the number ofs that are stored in theCalendarJobsStore.intgetNumberOfJobs()Get the number ofs that are stored in theJobJobsStore.intgetNumberOfTriggers()Get the number ofs that are stored in theTriggerJobsStore.java.util.Set<java.lang.String>getPausedTriggerGroups()java.util.List<java.lang.String>getTriggerGroupNames()Get the names of all of thegroups.Triggerjava.util.Set<TriggerKey>getTriggerKeys(GroupMatcher<TriggerKey> matcher)Get the names of all of thes that have the given group name.Triggerjava.util.List<OperableTrigger>getTriggersForJob(JobKey jobKey)Get all of the Triggers that are associated to the given Job.Trigger.TriggerStategetTriggerState(TriggerKey triggerKey)Get the current state of the identified.Triggervoidinitialize(ClassLoadHelper loadHelper, SchedulerSignaler signaler)Called by the QuartzScheduler before theJobStoreis used, in order to give the it a chance to initialize.booleanisClustered()Whether or not theJobStoreimplementation is clustered.voidpauseAll()Pause all triggers - equivalent of callingpauseTriggerGroup(group)on every group.voidpauseJob(JobKey jobKey)Pause thewith the given name - by pausing all of its currentJobTriggers.java.util.Collection<java.lang.String>pauseJobs(GroupMatcher<JobKey> groupMatcher)Pause all of thein the given group - by pausing all of theirJobsTriggers.voidpauseTrigger(TriggerKey triggerKey)Pause thewith the given key.Triggerjava.util.Collection<java.lang.String>pauseTriggers(GroupMatcher<TriggerKey> matcher)Pause all of thein the given group.TriggersvoidreleaseAcquiredTrigger(OperableTrigger trigger)Inform theJobStorethat the scheduler no longer plans to fire the givenTrigger, that it had previously acquired (reserved).booleanremoveCalendar(java.lang.String calName)Remove (delete) thewith the given name.CalendarbooleanremoveJob(JobKey jobKey)booleanremoveJobs(java.util.List<JobKey> jobKeys)booleanremoveTrigger(TriggerKey triggerKey)Remove (delete) thewith the given key.TriggerbooleanremoveTriggers(java.util.List<TriggerKey> triggerKeys)booleanreplaceTrigger(TriggerKey triggerKey, OperableTrigger newTrigger)Remove (delete) thewith the given key, and store the new given one - which must be associated with the same job.TriggervoidresetTriggerFromErrorState(TriggerKey triggerKey)Reset the current state of the identifiedfromTriggerTrigger.TriggerState.ERRORtoTrigger.TriggerState.NORMALorTrigger.TriggerState.PAUSEDas appropriate.voidresumeAll()Resume (un-pause) all triggers - equivalent of callingresumeTriggerGroup(group)on every group.voidresumeJob(JobKey jobKey)Resume (un-pause) thewith the given key.Jobjava.util.Collection<java.lang.String>resumeJobs(GroupMatcher<JobKey> matcher)Resume (un-pause) all of thein the given group.JobsvoidresumeTrigger(TriggerKey triggerKey)Resume (un-pause) thewith the given key.Triggerjava.util.Collection<java.lang.String>resumeTriggers(GroupMatcher<TriggerKey> matcher)Resume (un-pause) all of thein the given group.TriggersCalendarretrieveCalendar(java.lang.String calName)Retrieve the given.TriggerJobDetailretrieveJob(JobKey jobKey)OperableTriggerretrieveTrigger(TriggerKey triggerKey)Retrieve the given.TriggervoidschedulerPaused()Called by the QuartzScheduler to inform theJobStorethat the scheduler has been paused.voidschedulerResumed()Called by the QuartzScheduler to inform theJobStorethat the scheduler has resumed after being paused.voidschedulerStarted()Called by the QuartzScheduler to inform theJobStorethat the scheduler has started.voidsetInstanceId(java.lang.String schedInstId)Inform theJobStoreof the Scheduler instance's Id, prior to initialize being invoked.voidsetInstanceName(java.lang.String schedName)Inform theJobStoreof the Scheduler instance's name, prior to initialize being invoked.voidsetThreadPoolSize(int poolSize)Tells the JobStore the pool size used to execute jobsvoidshutdown()Called by the QuartzScheduler to inform theJobStorethat it should free up all of it's resources because the scheduler is shutting down.voidstoreCalendar(java.lang.String name, Calendar calendar, boolean replaceExisting, boolean updateTriggers)Store the given.CalendarvoidstoreJob(JobDetail newJob, boolean replaceExisting)Store the given.JobDetailvoidstoreJobAndTrigger(JobDetail newJob, OperableTrigger newTrigger)voidstoreJobsAndTriggers(java.util.Map<JobDetail,java.util.Set<? extends Trigger>> triggersAndJobs, boolean replace)voidstoreTrigger(OperableTrigger newTrigger, boolean replaceExisting)Store the given.TriggerbooleansupportsPersistence()voidtriggeredJobComplete(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.java.util.List<TriggerFiredResult>triggersFired(java.util.List<OperableTrigger> triggers)Inform theJobStorethat the scheduler is now firing the givenTrigger(executing its associatedJob), that it had previously acquired (reserved).
-
-
-
Method Detail
-
initialize
void initialize(ClassLoadHelper loadHelper, SchedulerSignaler signaler) throws SchedulerConfigException
Called by the QuartzScheduler before theJobStoreis used, in order to give the it a chance to initialize.- Throws:
SchedulerConfigException
-
schedulerStarted
void schedulerStarted() throws SchedulerExceptionCalled by the QuartzScheduler to inform theJobStorethat the scheduler has started.- Throws:
SchedulerException
-
schedulerPaused
void schedulerPaused()
Called by the QuartzScheduler to inform theJobStorethat the scheduler has been paused.
-
schedulerResumed
void schedulerResumed()
Called by the QuartzScheduler to inform theJobStorethat the scheduler has resumed after being paused.
-
shutdown
void shutdown()
Called by the QuartzScheduler to inform theJobStorethat it should free up all of it's resources because the scheduler is shutting down.
-
supportsPersistence
boolean supportsPersistence()
-
getEstimatedTimeToReleaseAndAcquireTrigger
long getEstimatedTimeToReleaseAndAcquireTrigger()
How long (in milliseconds) theJobStoreimplementation estimates that it will take to release a trigger and acquire a new one.
-
isClustered
boolean isClustered()
Whether or not theJobStoreimplementation is clustered.
-
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 and group should be over-written.- Throws:
ObjectAlreadyExistsException- if aJobwith the same name/group already exists, and replaceExisting is set to false.JobPersistenceException
-
storeJobsAndTriggers
void storeJobsAndTriggers(java.util.Map<JobDetail,java.util.Set<? extends Trigger>> triggersAndJobs, boolean replace) throws ObjectAlreadyExistsException, JobPersistenceException
-
removeJob
boolean removeJob(JobKey jobKey) throws JobPersistenceException
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 and group was found and removed from the store.- Throws:
JobPersistenceException
-
removeJobs
boolean removeJobs(java.util.List<JobKey> jobKeys) throws JobPersistenceException
- Throws:
JobPersistenceException
-
retrieveJob
JobDetail retrieveJob(JobKey jobKey) throws JobPersistenceException
- 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 and group should be over-written.- Throws:
ObjectAlreadyExistsException- if aTriggerwith the same name/group already exists, and replaceExisting is set to false.JobPersistenceException- See Also:
pauseTriggers(org.quartz.impl.matchers.GroupMatcher)
-
removeTrigger
boolean removeTrigger(TriggerKey triggerKey) throws JobPersistenceException
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 and group was found and removed from the store.- Throws:
JobPersistenceException
-
removeTriggers
boolean removeTriggers(java.util.List<TriggerKey> triggerKeys) throws JobPersistenceException
- Throws:
JobPersistenceException
-
replaceTrigger
boolean replaceTrigger(TriggerKey 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 and group was found and removed from the store.- Throws:
JobPersistenceException
-
retrieveTrigger
OperableTrigger retrieveTrigger(TriggerKey triggerKey) throws JobPersistenceException
Retrieve the given.Trigger- Returns:
- The desired
Trigger, or null if there is no match. - Throws:
JobPersistenceException
-
checkExists
boolean checkExists(JobKey jobKey) throws JobPersistenceException
Determine whether aJobwith the given identifier already exists within the scheduler.- Parameters:
jobKey- the identifier to check for- Returns:
- true if a Job exists with the given identifier
- Throws:
JobPersistenceException
-
checkExists
boolean checkExists(TriggerKey triggerKey) throws JobPersistenceException
Determine whether aTriggerwith the given identifier already exists within the scheduler.- Parameters:
triggerKey- the identifier to check for- Returns:
- true if a Trigger exists with the given identifier
- Throws:
JobPersistenceException
-
clearAllSchedulingData
void clearAllSchedulingData() throws JobPersistenceException- Throws:
JobPersistenceException
-
storeCalendar
void storeCalendar(java.lang.String name, Calendar calendar, boolean replaceExisting, boolean updateTriggers) throws ObjectAlreadyExistsException, JobPersistenceExceptionStore the given.Calendar- Parameters:
calendar- TheCalendarto be stored.replaceExisting- Iftrue, anyCalendarexisting in theJobStorewith the same name and group should be over-written.updateTriggers- Iftrue, anyTriggers existing in theJobStorethat reference an existing Calendar with the same name with have their next fire time re-computed with the newCalendar.- Throws:
ObjectAlreadyExistsException- if aCalendarwith the same name already exists, and replaceExisting is set to false.JobPersistenceException
-
removeCalendar
boolean removeCalendar(java.lang.String calName) throws JobPersistenceExceptionRemove (delete) thewith the given name.CalendarIf removal of the
*Calendarwould result inTriggers pointing to nonexistent calendars, then aJobPersistenceExceptionwill be thrown.- Parameters:
calName- The name of theCalendarto be removed.- Returns:
trueif aCalendarwith the given name was found and removed from the store.- Throws:
JobPersistenceException
-
retrieveCalendar
Calendar retrieveCalendar(java.lang.String calName) throws JobPersistenceException
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
-
getNumberOfJobs
int getNumberOfJobs() throws JobPersistenceExceptionGet the number ofs that are stored in theJobJobsStore.- Throws:
JobPersistenceException
-
getNumberOfTriggers
int getNumberOfTriggers() throws JobPersistenceExceptionGet the number ofs that are stored in theTriggerJobsStore.- Throws:
JobPersistenceException
-
getNumberOfCalendars
int getNumberOfCalendars() throws JobPersistenceExceptionGet the number ofs that are stored in theCalendarJobsStore.- Throws:
JobPersistenceException
-
getJobKeys
java.util.Set<JobKey> getJobKeys(GroupMatcher<JobKey> matcher) throws JobPersistenceException
Get the keys of all of thes that have the given group name.JobIf there are no jobs in the given group name, the result should be an empty collection (not
null).- Throws:
JobPersistenceException
-
getTriggerKeys
java.util.Set<TriggerKey> getTriggerKeys(GroupMatcher<TriggerKey> matcher) throws JobPersistenceException
Get the names of all of thes that have the given group name.TriggerIf there are no triggers in the given group name, the result should be a zero-length array (not
null).- Throws:
JobPersistenceException
-
getJobGroupNames
java.util.List<java.lang.String> getJobGroupNames() throws JobPersistenceExceptionGet the names of all of thegroups.JobIf there are no known group names, the result should be a zero-length array (not
null).- Throws:
JobPersistenceException
-
getTriggerGroupNames
java.util.List<java.lang.String> getTriggerGroupNames() throws JobPersistenceExceptionGet the names of all of thegroups.TriggerIf there are no known group names, the result should be a zero-length array (not
null).- Throws:
JobPersistenceException
-
getCalendarNames
java.util.List<java.lang.String> getCalendarNames() throws JobPersistenceExceptionGet the names of all of thes in theCalendarJobStore.If there are no Calendars in the given group name, the result should be a zero-length array (not
null).- Throws:
JobPersistenceException
-
getTriggersForJob
java.util.List<OperableTrigger> getTriggersForJob(JobKey jobKey) throws JobPersistenceException
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
-
getTriggerState
Trigger.TriggerState getTriggerState(TriggerKey triggerKey) throws JobPersistenceException
Get the current state of the identified.Trigger- Throws:
JobPersistenceException- See Also:
Trigger.TriggerState
-
resetTriggerFromErrorState
void resetTriggerFromErrorState(TriggerKey triggerKey) throws JobPersistenceException
Reset the current state of the identifiedfromTriggerTrigger.TriggerState.ERRORtoTrigger.TriggerState.NORMALorTrigger.TriggerState.PAUSEDas appropriate.Only affects triggers that are in ERROR state - if identified trigger is not in that state then the result is a no-op.
The result will be the trigger returning to the normal, waiting to be fired state, unless the trigger's group has been paused, in which case it will go into the PAUSED state.
- Throws:
JobPersistenceException
-
pauseTrigger
void pauseTrigger(TriggerKey triggerKey) throws JobPersistenceException
Pause thewith the given key.Trigger- Throws:
JobPersistenceException- See Also:
resumeTrigger(TriggerKey)
-
pauseTriggers
java.util.Collection<java.lang.String> pauseTriggers(GroupMatcher<TriggerKey> matcher) throws JobPersistenceException
Pause all of thein the given group.TriggersThe JobStore should "remember" that the group is paused, and impose the pause on any new triggers that are added to the group while the group is paused.
- Throws:
JobPersistenceException- See Also:
resumeTriggers(GroupMatcher)
-
pauseJob
void pauseJob(JobKey jobKey) throws JobPersistenceException
Pause thewith the given name - by pausing all of its currentJobTriggers.- Throws:
JobPersistenceException- See Also:
resumeJob(JobKey)
-
pauseJobs
java.util.Collection<java.lang.String> pauseJobs(GroupMatcher<JobKey> groupMatcher) throws JobPersistenceException
Pause all of thein the given group - by pausing all of theirJobsTriggers.The JobStore should "remember" that the group is paused, and impose the pause on any new jobs that are added to the group while the group is paused.
- Throws:
JobPersistenceException- See Also:
resumeJobs(GroupMatcher)
-
resumeTrigger
void resumeTrigger(TriggerKey triggerKey) throws JobPersistenceException
Resume (un-pause) thewith the given key.TriggerIf the
Triggermissed one or more fire-times, then theTrigger's misfire instruction will be applied.- Throws:
JobPersistenceException- See Also:
pauseTrigger(TriggerKey)
-
resumeTriggers
java.util.Collection<java.lang.String> resumeTriggers(GroupMatcher<TriggerKey> matcher) throws JobPersistenceException
Resume (un-pause) all of thein the given group.TriggersIf any
Triggermissed one or more fire-times, then theTrigger's misfire instruction will be applied.- Throws:
JobPersistenceException- See Also:
pauseTriggers(GroupMatcher)
-
getPausedTriggerGroups
java.util.Set<java.lang.String> getPausedTriggerGroups() throws JobPersistenceException- Throws:
JobPersistenceException
-
resumeJob
void resumeJob(JobKey jobKey) throws JobPersistenceException
Resume (un-pause) thewith the given key.JobIf any of the
Job'sTriggers missed one or more fire-times, then theTrigger's misfire instruction will be applied.- Throws:
JobPersistenceException- See Also:
pauseJob(JobKey)
-
resumeJobs
java.util.Collection<java.lang.String> resumeJobs(GroupMatcher<JobKey> matcher) throws JobPersistenceException
Resume (un-pause) all of thein the given group.JobsIf any of the
Jobs hadTriggers that missed one or more fire-times, then theTrigger's misfire instruction will be applied.- Throws:
JobPersistenceException- See Also:
pauseJobs(GroupMatcher)
-
pauseAll
void pauseAll() throws JobPersistenceExceptionPause all triggers - equivalent of callingpauseTriggerGroup(group)on every group.When
resumeAll()is called (to un-pause), trigger misfire instructions WILL be applied.- Throws:
JobPersistenceException- See Also:
resumeAll(),pauseTriggers(GroupMatcher)
-
resumeAll
void resumeAll() throws JobPersistenceExceptionResume (un-pause) all triggers - equivalent of callingresumeTriggerGroup(group)on every group.If any
Triggermissed one or more fire-times, then theTrigger's misfire instruction will be applied.- Throws:
JobPersistenceException- See Also:
pauseAll()
-
acquireNextTriggers
java.util.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- See Also:
releaseAcquiredTrigger(OperableTrigger)
-
releaseAcquiredTrigger
void releaseAcquiredTrigger(OperableTrigger trigger)
Inform theJobStorethat the scheduler no longer plans to fire the givenTrigger, that it had previously acquired (reserved).
-
triggersFired
java.util.List<TriggerFiredResult> triggersFired(java.util.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)
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.
-
setInstanceId
void setInstanceId(java.lang.String schedInstId)
Inform theJobStoreof the Scheduler instance's Id, prior to initialize being invoked.- Since:
- 1.7
-
setInstanceName
void setInstanceName(java.lang.String schedName)
Inform theJobStoreof the Scheduler instance's name, prior to initialize being invoked.- Since:
- 1.7
-
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
-
getAcquireRetryDelay
long getAcquireRetryDelay(int failureCount)
Get the amount of time (in ms) to wait when accessing this job store repeatedly fails. Called by the executor thread(s) when calls toacquireNextTriggers(long, int, long)fail more than once in succession, and the thread thus wants to wait a bit before trying again, to not consume 100% CPU, write huge amounts of errors into logs, etc. in cases like the DB being offline/restarting. The delay returned by implementations should be between 20 and 600000 milliseconds.- Parameters:
failureCount- the number of successive failures seen so far- Returns:
- the time (in milliseconds) to wait before trying again
-
-