public class PlainTerracottaJobStore<T extends ClusteredJobStore> extends Object implements TerracottaJobStoreExtensions
| Modifier and Type | Field and Description |
|---|---|
protected ToolkitInternal |
toolkit |
| Constructor and Description |
|---|
PlainTerracottaJobStore(ToolkitInternal toolkit) |
| Modifier and Type | Method and Description |
|---|---|
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.
|
boolean |
checkExists(JobKey jobKey)
Determine whether a
Job with the given identifier already
exists within the scheduler. |
boolean |
checkExists(TriggerKey triggerKey)
Determine whether a
Trigger with the given identifier already
exists within the scheduler. |
void |
clearAllSchedulingData()
|
protected T |
createNewJobStoreInstance(String schedulerName,
boolean useSynchWrite) |
long |
getAcquireRetryDelay(int failureCount)
Get the amount of time (in ms) to wait when accessing this job store
repeatedly fails.
|
List<String> |
getCalendarNames()
Get the names of all of the
s
in the JobStore. |
protected T |
getClusteredJobStore() |
long |
getEstimatedTimeToReleaseAndAcquireTrigger()
How long (in milliseconds) the
JobStore implementation
estimates that it will take to release a trigger and acquire a new one. |
List<String> |
getJobGroupNames()
Get the names of all of the
groups. |
Set<JobKey> |
getJobKeys(GroupMatcher<JobKey> matcher)
Get the keys of all of the
s that
have the given group name. |
String |
getName()
Get the name of the
JobListener. |
int |
getNumberOfCalendars()
Get the number of
s that are
stored in the JobsStore. |
int |
getNumberOfJobs()
Get the number of
s that are
stored in the JobsStore. |
int |
getNumberOfTriggers()
Get the number of
s that are
stored in the JobsStore. |
Set<String> |
getPausedTriggerGroups() |
List<String> |
getTriggerGroupNames()
Get the names of all of the
groups. |
Set<TriggerKey> |
getTriggerKeys(GroupMatcher<TriggerKey> matcher)
Get the names of all of the
s
that have the given group name. |
List<OperableTrigger> |
getTriggersForJob(JobKey jobKey)
Get all of the Triggers that are associated to the given Job.
|
Trigger.TriggerState |
getTriggerState(TriggerKey triggerKey)
Get the current state of the identified
. |
String |
getUUID() |
void |
initialize(ClassLoadHelper loadHelper,
SchedulerSignaler signaler)
Called by the QuartzScheduler before the
JobStore is
used, in order to give the it a chance to initialize. |
boolean |
isClustered()
Whether or not the
JobStore implementation is clustered. |
void |
jobExecutionVetoed(JobExecutionContext context)
Called by the
when a
was about to be executed (an associated
has occurred), but a vetoed it's
execution. |
void |
jobToBeExecuted(JobExecutionContext context)
|
void |
jobWasExecuted(JobExecutionContext context,
JobExecutionException jobException)
|
void |
pauseAll()
Pause all triggers - equivalent of calling
pauseTriggerGroup(group)
on every group. |
void |
pauseJob(JobKey jobKey)
Pause the
with the given name - by
pausing all of its current Triggers. |
Collection<String> |
pauseJobs(GroupMatcher<JobKey> matcher)
Pause all of the
in the given
group - by pausing all of their Triggers. |
void |
pauseTrigger(TriggerKey triggerKey)
Pause the
with the given key. |
Collection<String> |
pauseTriggers(GroupMatcher<TriggerKey> matcher)
Pause all of the
in the
given group. |
void |
releaseAcquiredTrigger(OperableTrigger trigger)
Inform the
JobStore that the scheduler no longer plans to
fire the given Trigger, that it had previously acquired
(reserved). |
boolean |
removeCalendar(String calName)
Remove (delete) the
with the
given name. |
boolean |
removeJob(JobKey jobKey)
|
boolean |
removeJobs(List<JobKey> jobKeys) |
boolean |
removeTrigger(TriggerKey triggerKey)
Remove (delete) the
with the
given key. |
boolean |
removeTriggers(List<TriggerKey> triggerKeys) |
boolean |
replaceTrigger(TriggerKey triggerKey,
OperableTrigger newTrigger)
Remove (delete) the
with the
given key, and store the new given one - which must be associated
with the same job. |
void |
resetTriggerFromErrorState(TriggerKey triggerKey)
Reset the current state of the identified
from Trigger.TriggerState.ERROR to Trigger.TriggerState.NORMAL or
Trigger.TriggerState.PAUSED as appropriate. |
void |
resumeAll()
Resume (un-pause) all triggers - equivalent of calling
resumeTriggerGroup(group)
on every group. |
void |
resumeJob(JobKey jobKey)
Resume (un-pause) the
with the
given key. |
Collection<String> |
resumeJobs(GroupMatcher<JobKey> matcher)
Resume (un-pause) all of the
in
the given group. |
void |
resumeTrigger(TriggerKey triggerKey)
Resume (un-pause) the
with the
given key. |
Collection<String> |
resumeTriggers(GroupMatcher<TriggerKey> matcher)
Resume (un-pause) all of the
in the given group. |
Calendar |
retrieveCalendar(String calName)
Retrieve the given
. |
JobDetail |
retrieveJob(JobKey jobKey)
|
OperableTrigger |
retrieveTrigger(TriggerKey triggerKey)
Retrieve the given
. |
void |
schedulerPaused()
Called by the QuartzScheduler to inform the
JobStore that
the scheduler has been paused. |
void |
schedulerResumed()
Called by the QuartzScheduler to inform the
JobStore that
the scheduler has resumed after being paused. |
void |
schedulerStarted()
Called by the QuartzScheduler to inform the
JobStore that
the scheduler has started. |
void |
setEstimatedTimeToReleaseAndAcquireTrigger(long estimate) |
void |
setInstanceId(String schedInstId)
Inform the
JobStore of the Scheduler instance's Id,
prior to initialize being invoked. |
void |
setInstanceName(String schedName)
Inform the
JobStore of the Scheduler instance's name,
prior to initialize being invoked. |
void |
setMisfireThreshold(long threshold) |
void |
setSynchronousWrite(String synchWrite) |
void |
setTcRetryInterval(long retryInterval) |
void |
setThreadPoolSize(int size)
Tells the JobStore the pool size used to execute jobs
|
void |
shutdown()
Called by the QuartzScheduler to inform the
JobStore that
it should free up all of it's resources because the scheduler is
shutting down. |
void |
storeCalendar(String name,
Calendar calendar,
boolean replaceExisting,
boolean updateTriggers)
Store the given
. |
void |
storeJob(JobDetail newJob,
boolean replaceExisting)
Store the given
. |
void |
storeJobAndTrigger(JobDetail newJob,
OperableTrigger newTrigger)
|
void |
storeJobsAndTriggers(Map<JobDetail,Set<? extends Trigger>> triggersAndJobs,
boolean replace) |
void |
storeTrigger(OperableTrigger newTrigger,
boolean replaceExisting)
Store the given
. |
boolean |
supportsPersistence() |
String |
toString() |
void |
triggeredJobComplete(OperableTrigger trigger,
JobDetail jobDetail,
Trigger.CompletedExecutionInstruction triggerInstCode)
Inform the
JobStore that the scheduler has completed the
firing of the given Trigger (and the execution of its
associated Job completed, threw an exception, or was vetoed),
and that the
in the given JobDetail should be updated if the Job
is stateful. |
List<TriggerFiredResult> |
triggersFired(List<OperableTrigger> triggers)
Inform the
JobStore that the scheduler is now firing the
given Trigger (executing its associated Job),
that it had previously acquired (reserved). |
public void setSynchronousWrite(String synchWrite)
setSynchronousWrite in interface TerracottaJobStoreExtensionspublic void setThreadPoolSize(int size)
JobStoresetThreadPoolSize in interface JobStoresetThreadPoolSize in interface TerracottaJobStoreExtensionssize - amount of threads allocated for job executionpublic List<OperableTrigger> acquireNextTriggers(long noLaterThan, int maxCount, long timeWindow) throws JobPersistenceException
JobStoreacquireNextTriggers in interface JobStorenoLaterThan - If > 0, the JobStore should only return a Trigger
that will fire no later than the time represented in this value as
milliseconds.JobPersistenceExceptionJobStore.releaseAcquiredTrigger(OperableTrigger)public List<String> getCalendarNames() throws JobPersistenceException
JobStoreCalendar s
in the JobStore.
If there are no Calendars in the given group name, the result should be
a zero-length array (not null).
getCalendarNames in interface JobStoreJobPersistenceExceptionpublic List<String> getJobGroupNames() throws JobPersistenceException
JobStoreJob
groups.
If there are no known group names, the result should be a zero-length
array (not null).
getJobGroupNames in interface JobStoreJobPersistenceExceptionpublic Set<JobKey> getJobKeys(GroupMatcher<JobKey> matcher) throws JobPersistenceException
JobStoreJob s that
have the given group name.
If there are no jobs in the given group name, the result should be
an empty collection (not null).
getJobKeys in interface JobStoreJobPersistenceExceptionpublic int getNumberOfCalendars()
throws JobPersistenceException
JobStoreCalendar s that are
stored in the JobsStore.getNumberOfCalendars in interface JobStoreJobPersistenceExceptionpublic int getNumberOfJobs()
throws JobPersistenceException
JobStoreJob s that are
stored in the JobsStore.getNumberOfJobs in interface JobStoreJobPersistenceExceptionpublic int getNumberOfTriggers()
throws JobPersistenceException
JobStoreTrigger s that are
stored in the JobsStore.getNumberOfTriggers in interface JobStoreJobPersistenceExceptionpublic Set<String> getPausedTriggerGroups() throws JobPersistenceException
getPausedTriggerGroups in interface JobStoreJobPersistenceExceptionpublic List<String> getTriggerGroupNames() throws JobPersistenceException
JobStoreTrigger
groups.
If there are no known group names, the result should be a zero-length
array (not null).
getTriggerGroupNames in interface JobStoreJobPersistenceExceptionpublic Set<TriggerKey> getTriggerKeys(GroupMatcher<TriggerKey> matcher) throws JobPersistenceException
JobStoreTrigger s
that have the given group name.
If there are no triggers in the given group name, the result should be a
zero-length array (not null).
getTriggerKeys in interface JobStoreJobPersistenceExceptionpublic List<OperableTrigger> getTriggersForJob(JobKey jobKey) throws JobPersistenceException
JobStoreIf there are no matches, a zero-length array should be returned.
getTriggersForJob in interface JobStoreJobPersistenceExceptionpublic Trigger.TriggerState getTriggerState(TriggerKey triggerKey) throws JobPersistenceException
JobStoreTrigger.getTriggerState in interface JobStoreJobPersistenceExceptionTrigger.TriggerStatepublic void resetTriggerFromErrorState(TriggerKey triggerKey) throws JobPersistenceException
JobStoreTrigger
from Trigger.TriggerState.ERROR to Trigger.TriggerState.NORMAL or
Trigger.TriggerState.PAUSED as 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.
resetTriggerFromErrorState in interface JobStoreJobPersistenceExceptionpublic void initialize(ClassLoadHelper loadHelper, SchedulerSignaler signaler) throws SchedulerConfigException
JobStoreJobStore is
used, in order to give the it a chance to initialize.initialize in interface JobStoreSchedulerConfigExceptionpublic void pauseAll()
throws JobPersistenceException
JobStorepauseTriggerGroup(group)
on every group.
When resumeAll() is called (to un-pause), trigger misfire
instructions WILL be applied.
pauseAll in interface JobStoreJobPersistenceExceptionJobStore.resumeAll(),
JobStore.pauseTriggers(GroupMatcher)public void pauseJob(JobKey jobKey) throws JobPersistenceException
JobStoreJob with the given name - by
pausing all of its current Triggers.pauseJob in interface JobStoreJobPersistenceExceptionJobStore.resumeJob(JobKey)public Collection<String> pauseJobs(GroupMatcher<JobKey> matcher) throws JobPersistenceException
JobStoreJobs in the given
group - by pausing all of their Triggers.
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.
pauseJobs in interface JobStoreJobPersistenceExceptionJobStore.resumeJobs(GroupMatcher)public void pauseTrigger(TriggerKey triggerKey) throws JobPersistenceException
JobStoreTrigger with the given key.pauseTrigger in interface JobStoreJobPersistenceExceptionJobStore.resumeTrigger(TriggerKey)public Collection<String> pauseTriggers(GroupMatcher<TriggerKey> matcher) throws JobPersistenceException
JobStoreTriggers in the
given group.
The 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.
pauseTriggers in interface JobStoreJobPersistenceExceptionJobStore.resumeTriggers(GroupMatcher)public void releaseAcquiredTrigger(OperableTrigger trigger)
JobStoreJobStore that the scheduler no longer plans to
fire the given Trigger, that it had previously acquired
(reserved).releaseAcquiredTrigger in interface JobStorepublic List<TriggerFiredResult> triggersFired(List<OperableTrigger> triggers) throws JobPersistenceException
JobStoreJobStore that the scheduler is now firing the
given Trigger (executing its associated Job),
that it had previously acquired (reserved).triggersFired in interface JobStoreJobPersistenceExceptionpublic boolean removeCalendar(String calName) throws JobPersistenceException
JobStoreCalendar with the
given name.
If removal of the Calendar would result in
Triggers pointing to non-existent calendars, then a
JobPersistenceException will be thrown.
removeCalendar in interface JobStorecalName - The name of the Calendar to be removed.true if a Calendar with the given name
was found and removed from the store.JobPersistenceExceptionpublic boolean removeJob(JobKey jobKey) throws JobPersistenceException
JobStoreJob with the given
key, and any Trigger s that reference
it.
If removal of the Job results in an empty group, the
group should be removed from the JobStore's list of
known group names.
removeJob in interface JobStoretrue if a Job with the given name &
group was found and removed from the store.JobPersistenceExceptionpublic boolean removeTrigger(TriggerKey triggerKey) throws JobPersistenceException
JobStoreTrigger with the
given key.
If removal of the Trigger results in an empty group, the
group should be removed from the JobStore's list of
known group names.
If removal of the Trigger results in an 'orphaned' Job
that is not 'durable', then the Job should be deleted
also.
removeTrigger in interface JobStoretrue if a Trigger with the given
name & group was found and removed from the store.JobPersistenceExceptionpublic boolean removeJobs(List<JobKey> jobKeys) throws JobPersistenceException
removeJobs in interface JobStoreJobPersistenceExceptionpublic boolean removeTriggers(List<TriggerKey> triggerKeys) throws JobPersistenceException
removeTriggers in interface JobStoreJobPersistenceExceptionpublic void storeJobsAndTriggers(Map<JobDetail,Set<? extends Trigger>> triggersAndJobs, boolean replace) throws JobPersistenceException
storeJobsAndTriggers in interface JobStoreJobPersistenceExceptionpublic boolean replaceTrigger(TriggerKey triggerKey, OperableTrigger newTrigger) throws JobPersistenceException
JobStoreTrigger with the
given key, and store the new given one - which must be associated
with the same job.replaceTrigger in interface JobStorenewTrigger - The new Trigger to be stored.true if a Trigger with the given
name & group was found and removed from the store.JobPersistenceExceptionpublic void resumeAll()
throws JobPersistenceException
JobStoreresumeTriggerGroup(group)
on every group.
If any Trigger missed one or more fire-times, then the
Trigger's misfire instruction will be applied.
resumeAll in interface JobStoreJobPersistenceExceptionJobStore.pauseAll()public void resumeJob(JobKey jobKey) throws JobPersistenceException
JobStoreJob with the
given key.
If any of the Job'sTrigger s missed one
or more fire-times, then the Trigger's misfire
instruction will be applied.
resumeJob in interface JobStoreJobPersistenceExceptionJobStore.pauseJob(JobKey)public Collection<String> resumeJobs(GroupMatcher<JobKey> matcher) throws JobPersistenceException
JobStoreJobs in
the given group.
If any of the Job s had Trigger s that
missed one or more fire-times, then the Trigger's
misfire instruction will be applied.
resumeJobs in interface JobStoreJobPersistenceExceptionJobStore.pauseJobs(GroupMatcher)public void resumeTrigger(TriggerKey triggerKey) throws JobPersistenceException
JobStoreTrigger with the
given key.
If the Trigger missed one or more fire-times, then the
Trigger's misfire instruction will be applied.
resumeTrigger in interface JobStoreJobPersistenceExceptionJobStore.pauseTrigger(TriggerKey)public Collection<String> resumeTriggers(GroupMatcher<TriggerKey> matcher) throws JobPersistenceException
JobStoreTriggers
in the given group.
If any Trigger missed one or more fire-times, then the
Trigger's misfire instruction will be applied.
resumeTriggers in interface JobStoreJobPersistenceExceptionJobStore.pauseTriggers(GroupMatcher)public Calendar retrieveCalendar(String calName) throws JobPersistenceException
JobStoreTrigger.retrieveCalendar in interface JobStorecalName - The name of the Calendar to be retrieved.Calendar, or null if there is no
match.JobPersistenceExceptionpublic JobDetail retrieveJob(JobKey jobKey) throws JobPersistenceException
JobStoreretrieveJob in interface JobStoreJob, or null if there is no match.JobPersistenceExceptionpublic OperableTrigger retrieveTrigger(TriggerKey triggerKey) throws JobPersistenceException
JobStoreTrigger.retrieveTrigger in interface JobStoreTrigger, or null if there is no
match.JobPersistenceExceptionpublic boolean checkExists(JobKey jobKey) throws JobPersistenceException
JobStoreJob with the given identifier already
exists within the scheduler.checkExists in interface JobStorejobKey - the identifier to check forJobPersistenceExceptionpublic boolean checkExists(TriggerKey triggerKey) throws JobPersistenceException
JobStoreTrigger with the given identifier already
exists within the scheduler.checkExists in interface JobStoretriggerKey - the identifier to check forJobPersistenceExceptionpublic void clearAllSchedulingData()
throws JobPersistenceException
JobStoreclearAllSchedulingData in interface JobStoreJobPersistenceExceptionpublic void schedulerStarted()
throws SchedulerException
JobStoreJobStore that
the scheduler has started.schedulerStarted in interface JobStoreSchedulerExceptionpublic void schedulerPaused()
JobStoreJobStore that
the scheduler has been paused.schedulerPaused in interface JobStorepublic void schedulerResumed()
JobStoreJobStore that
the scheduler has resumed after being paused.schedulerResumed in interface JobStorepublic void shutdown()
JobStoreJobStore that
it should free up all of it's resources because the scheduler is
shutting down.public void storeCalendar(String name, Calendar calendar, boolean replaceExisting, boolean updateTriggers) throws JobPersistenceException
JobStoreCalendar.storeCalendar in interface JobStorecalendar - The Calendar to be stored.replaceExisting - If true, any Calendar existing
in the JobStore with the same name & group
should be over-written.updateTriggers - If true, any Triggers existing
in the JobStore that reference an existing
Calendar with the same name with have their next fire time
re-computed with the new Calendar.ObjectAlreadyExistsException - if a Calendar with the same name already
exists, and replaceExisting is set to false.JobPersistenceExceptionpublic void storeJob(JobDetail newJob, boolean replaceExisting) throws JobPersistenceException
JobStoreJobDetail.storeJob in interface JobStorenewJob - The JobDetail to be stored.replaceExisting - If true, any Job existing in the
JobStore with the same name & group should be
over-written.ObjectAlreadyExistsException - if a Job with the same name/group already
exists, and replaceExisting is set to false.JobPersistenceExceptionpublic void storeJobAndTrigger(JobDetail newJob, OperableTrigger newTrigger) throws JobPersistenceException
JobStorestoreJobAndTrigger in interface JobStorenewJob - The JobDetail to be stored.newTrigger - The Trigger to be stored.ObjectAlreadyExistsException - if a Job with the same name/group already
exists.JobPersistenceExceptionpublic void storeTrigger(OperableTrigger newTrigger, boolean replaceExisting) throws JobPersistenceException
JobStoreTrigger.storeTrigger in interface JobStorenewTrigger - The Trigger to be stored.replaceExisting - If true, any Trigger existing in
the JobStore with the same name & group should
be over-written.ObjectAlreadyExistsException - if a Trigger with the same name/group already
exists, and replaceExisting is set to false.JobPersistenceExceptionJobStore.pauseTriggers(org.quartz.impl.matchers.GroupMatcher)public boolean supportsPersistence()
supportsPersistence in interface JobStorepublic void triggeredJobComplete(OperableTrigger trigger, JobDetail jobDetail, Trigger.CompletedExecutionInstruction triggerInstCode)
JobStoreJobStore that the scheduler has completed the
firing of the given Trigger (and the execution of its
associated Job completed, threw an exception, or was vetoed),
and that the JobDataMap
in the given JobDetail should be updated if the Job
is stateful.triggeredJobComplete in interface JobStorepublic void setMisfireThreshold(long threshold)
setMisfireThreshold in interface TerracottaJobStoreExtensionspublic void setEstimatedTimeToReleaseAndAcquireTrigger(long estimate)
setEstimatedTimeToReleaseAndAcquireTrigger in interface TerracottaJobStoreExtensionspublic void setInstanceId(String schedInstId)
JobStoreJobStore of the Scheduler instance's Id,
prior to initialize being invoked.setInstanceId in interface JobStorepublic void setInstanceName(String schedName)
JobStoreJobStore of the Scheduler instance's name,
prior to initialize being invoked.setInstanceName in interface JobStorepublic void setTcRetryInterval(long retryInterval)
setTcRetryInterval in interface TerracottaJobStoreExtensionspublic long getAcquireRetryDelay(int failureCount)
JobStoreJobStore.acquireNextTriggers(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.getAcquireRetryDelay in interface JobStorefailureCount - the number of successive failures seen so farpublic String getUUID()
getUUID in interface TerracottaJobStoreExtensionsprotected T createNewJobStoreInstance(String schedulerName, boolean useSynchWrite)
public long getEstimatedTimeToReleaseAndAcquireTrigger()
JobStoreJobStore implementation
estimates that it will take to release a trigger and acquire a new one.getEstimatedTimeToReleaseAndAcquireTrigger in interface JobStorepublic boolean isClustered()
JobStoreJobStore implementation is clustered.isClustered in interface JobStoreprotected T getClusteredJobStore()
public String getName()
JobListener
Get the name of the JobListener.
getName in interface JobListenerpublic void jobToBeExecuted(JobExecutionContext context)
JobListener
Called by the when a Scheduler
is about to be executed (an associated JobDetail
has occurred).
Trigger
This method will not be invoked if the execution of the Job was vetoed
by a .
TriggerListener
jobToBeExecuted in interface JobListenerJobListener.jobExecutionVetoed(JobExecutionContext)public void jobExecutionVetoed(JobExecutionContext context)
JobListener
Called by the when a Scheduler
was about to be executed (an associated JobDetail
has occurred), but a Trigger vetoed it's
execution.
TriggerListener
jobExecutionVetoed in interface JobListenerJobListener.jobToBeExecuted(JobExecutionContext)public void jobWasExecuted(JobExecutionContext context, JobExecutionException jobException)
JobListener
Called by the after a Scheduler
has been executed, and be for the associated JobDetailTrigger's
triggered(xx) method has been called.
jobWasExecuted in interface JobListenerCopyright 2001-2019, Terracotta, Inc.