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 the
sJob
getTriggersForJob
(String jobKey) Get all of the Triggers that are associated to the given Job.void
initialize
(SchedulerSignaler signaler) Called by the QuartzScheduler before theJobStore
is used, in order to give the it a chance to initialize.void
releaseAcquiredTrigger
(OperableTrigger trigger) Inform theJobStore
that the scheduler no longer plans to fire the givenTrigger
, that it had previously acquired (reserved).boolean
boolean
removeTrigger
(String triggerKey) Remove (delete) the
with the given key.Trigger
boolean
replaceTrigger
(String triggerKey, OperableTrigger newTrigger) Remove (delete) the
with the given key, and store the new given one - which must be associated with the same job.Trigger
retrieveCalendar
(String calName) Retrieve the given
.Trigger
retrieveJob
(String jobKey) retrieveTrigger
(String triggerKey) Retrieve the given
.Trigger
void
Called by the QuartzScheduler to inform theJobStore
that the scheduler has started.void
setThreadPoolSize
(int poolSize) Tells the JobStore the pool size used to execute jobsvoid
Store the given
.JobDetail
void
storeJobAndTrigger
(JobDetail newJob, OperableTrigger newTrigger) void
storeTrigger
(OperableTrigger newTrigger, boolean replaceExisting) Store the given
.Trigger
void
triggeredJobComplete
(OperableTrigger trigger, JobDetail jobDetail, Trigger.CompletedExecutionInstruction triggerInstCode) Inform theJobStore
that the scheduler has completed the firing of the givenTrigger
(and the execution of its associatedJob
completed, threw an exception, or was vetoed), and that the
in the givenJobDataMap
JobDetail
should be updated if theJob
is stateful.triggersFired
(List<OperableTrigger> triggers) Inform theJobStore
that the scheduler is now firing the givenTrigger
(executing its associatedJob
), that it had previously acquired (reserved).
-
Method Details
-
initialize
Called by the QuartzScheduler before theJobStore
is used, in order to give the it a chance to initialize.- Throws:
SchedulerConfigException
-
schedulerStarted
Called by the QuartzScheduler to inform theJobStore
that the scheduler has started.- Throws:
SchedulerException
-
storeJobAndTrigger
void storeJobAndTrigger(JobDetail newJob, OperableTrigger newTrigger) throws ObjectAlreadyExistsException, JobPersistenceException - Parameters:
newJob
- TheJobDetail
to be stored.newTrigger
- TheTrigger
to be stored.- Throws:
ObjectAlreadyExistsException
- if aJob
with the same name/group already exists.JobPersistenceException
-
storeJob
void storeJob(JobDetail newJob, boolean replaceExisting) throws ObjectAlreadyExistsException, JobPersistenceException Store the given
.JobDetail
- Parameters:
newJob
- TheJobDetail
to be stored.replaceExisting
- Iftrue
, anyJob
existing in theJobStore
with the same name should be over-written.- Throws:
ObjectAlreadyExistsException
- if aJob
with the same name/group already exists, and replaceExisting is set to false.JobPersistenceException
-
removeJob
Remove (delete) the
with the given key, and anyJob
Trigger
If removal of the
Job
results in an empty group, the group should be removed from theJobStore
's list of known group names.- Returns:
true
if aJob
with 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
- TheTrigger
to be stored.replaceExisting
- Iftrue
, anyTrigger
existing in theJobStore
with the same name invalid input: '&' group should be over-written.- Throws:
ObjectAlreadyExistsException
- if aTrigger
with the same name/group already exists, and replaceExisting is set to false.JobPersistenceException
-
removeTrigger
Remove (delete) the
with the given key.Trigger
If removal of the
Trigger
results in an empty group, the group should be removed from theJobStore
's list of known group names.If removal of the
Trigger
results in an 'orphaned'Job
that is not 'durable', then theJob
should be deleted also.- Returns:
true
if aTrigger
with the given name was found and removed from the store.- Throws:
JobPersistenceException
-
replaceTrigger
boolean replaceTrigger(String triggerKey, OperableTrigger newTrigger) throws JobPersistenceException Remove (delete) the
with the given key, and store the new given one - which must be associated with the same job.Trigger
- Parameters:
newTrigger
- The newTrigger
to be stored.- Returns:
true
if aTrigger
with 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 theCalendar
to 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 the
sJob
If 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 theJobStore
that 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 theJobStore
that 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 theJobStore
that the scheduler has completed the firing of the givenTrigger
(and the execution of its associatedJob
completed, threw an exception, or was vetoed), and that the
in the givenJobDataMap
JobDetail
should be updated if theJob
is 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
-