public abstract class JobStoreSupport extends Object implements JobStore, Constants
Contains base functionality for JDBC-based JobStore implementations.
| Modifier and Type | Class and Description |
|---|---|
protected static class |
JobStoreSupport.RecoverMisfiredJobsResult
Helper class for returning the composite result of trying
to recover misfired jobs.
|
protected static interface |
JobStoreSupport.TransactionCallback
Implement this interface to provide the code to execute within
the a transaction template.
|
protected static interface |
JobStoreSupport.VoidTransactionCallback
Implement this interface to provide the code to execute within
the a transaction template that has no return value.
|
| Modifier and Type | Field and Description |
|---|---|
protected HashMap |
calendarCache |
protected Class |
delegateClass |
protected String |
delegateClassName |
protected String |
dsName |
protected boolean |
firstCheckIn |
protected String |
instanceId |
protected String |
instanceName |
protected long |
lastCheckin |
protected static String |
LOCK_CALENDAR_ACCESS |
protected static String |
LOCK_JOB_ACCESS |
protected static String |
LOCK_MISFIRE_ACCESS |
protected static String |
LOCK_STATE_ACCESS |
protected static String |
LOCK_TRIGGER_ACCESS |
protected int |
maxToRecoverAtATime |
protected String |
tablePrefix |
protected boolean |
useProperties |
ALIAS_COL_NEXT_FIRE_TIME, ALL_GROUPS_PAUSED, COL_BLOB, COL_CALENDAR, COL_CALENDAR_NAME, COL_CHECKIN_INTERVAL, COL_CRON_EXPRESSION, COL_DESCRIPTION, COL_END_TIME, COL_ENTRY_ID, COL_ENTRY_STATE, COL_FIRED_TIME, COL_INSTANCE_NAME, COL_IS_DURABLE, COL_IS_STATEFUL, COL_IS_VOLATILE, COL_JOB_CLASS, COL_JOB_DATAMAP, COL_JOB_GROUP, COL_JOB_LISTENER, COL_JOB_NAME, COL_LAST_CHECKIN_TIME, COL_LOCK_NAME, COL_MISFIRE_INSTRUCTION, COL_NEXT_FIRE_TIME, COL_PREV_FIRE_TIME, COL_PRIORITY, COL_REPEAT_COUNT, COL_REPEAT_INTERVAL, COL_REQUESTS_RECOVERY, COL_START_TIME, COL_TIME_ZONE_ID, COL_TIMES_TRIGGERED, COL_TRIGGER_GROUP, COL_TRIGGER_LISTENER, COL_TRIGGER_NAME, COL_TRIGGER_STATE, COL_TRIGGER_TYPE, DEFAULT_TABLE_PREFIX, STATE_ACQUIRED, STATE_BLOCKED, STATE_COMPLETE, STATE_DELETED, STATE_ERROR, STATE_EXECUTING, STATE_MISFIRED, STATE_PAUSED, STATE_PAUSED_BLOCKED, STATE_WAITING, TABLE_BLOB_TRIGGERS, TABLE_CALENDARS, TABLE_CRON_TRIGGERS, TABLE_FIRED_TRIGGERS, TABLE_JOB_DETAILS, TABLE_JOB_LISTENERS, TABLE_LOCKS, TABLE_PAUSED_TRIGGERS, TABLE_SCHEDULER_STATE, TABLE_SIMPLE_TRIGGERS, TABLE_TRIGGER_LISTENERS, TABLE_TRIGGERS, TTYPE_BLOB, TTYPE_CRON, TTYPE_SIMPLE| Constructor and Description |
|---|
JobStoreSupport() |
| Modifier and Type | Method and Description |
|---|---|
protected Trigger |
acquireNextTrigger(Connection conn,
SchedulingContext ctxt,
long noLaterThan) |
Trigger |
acquireNextTrigger(SchedulingContext ctxt,
long noLaterThan)
Get a handle to the next N triggers to be fired, and mark them as 'reserved'
by the calling scheduler.
|
protected long |
calcFailedIfAfter(SchedulerStateRecord rec) |
protected boolean |
calendarExists(Connection conn,
String calName) |
boolean |
canUseProperties()
Get whether String-only properties will be handled in JobDataMaps.
|
protected String |
checkBlockedState(Connection conn,
SchedulingContext ctxt,
String jobName,
String jobGroupName,
String currentState)
Determines if a Trigger for the given job should be blocked.
|
protected void |
cleanupConnection(Connection conn)
Cleanup the given database connection.
|
protected void |
cleanVolatileTriggerAndJobs()
Removes all volatile data.
|
protected void |
cleanVolatileTriggerAndJobs(Connection conn)
Removes all volatile data.
|
protected void |
closeConnection(Connection conn)
Closes the supplied
Connection. |
protected List |
clusterCheckIn(Connection conn) |
protected void |
clusterRecover(Connection conn,
List failedInstances) |
protected void |
commitConnection(Connection conn)
Commit the supplied connection
|
protected boolean |
doCheckin() |
protected JobStoreSupport.RecoverMisfiredJobsResult |
doRecoverMisfires() |
protected abstract Object |
executeInLock(String lockName,
JobStoreSupport.TransactionCallback txCallback)
Execute the given callback having aquired the given lock.
|
protected void |
executeInLock(String lockName,
JobStoreSupport.VoidTransactionCallback txCallback)
Execute the given callback having aquired the given lock.
|
protected Object |
executeInNonManagedTXLock(String lockName,
JobStoreSupport.TransactionCallback txCallback)
Execute the given callback having optionally aquired the given lock.
|
protected void |
executeInNonManagedTXLock(String lockName,
JobStoreSupport.VoidTransactionCallback txCallback)
Execute the given callback having optionally aquired the given lock.
|
Object |
executeWithoutLock(JobStoreSupport.TransactionCallback txCallback)
Execute the given callback in a transaction.
|
protected List |
findFailedInstances(Connection conn)
Get a list of all scheduler instances in the cluster that may have failed.
|
protected Connection |
getAttributeRestoringConnection(Connection conn)
Wrap the given
Connection in a Proxy such that attributes
that might be set will be restored before the connection is closed
(and potentially restored to a pool). |
protected String[] |
getCalendarNames(Connection conn,
SchedulingContext ctxt) |
String[] |
getCalendarNames(SchedulingContext ctxt)
Get the names of all of the
s
in the JobStore. |
protected ClassLoadHelper |
getClassLoadHelper() |
long |
getClusterCheckinInterval()
Get the frequency (in milliseconds) at which this instance "checks-in"
with the other instances of the cluster.
|
protected Connection |
getConnection() |
String |
getDataSource()
Get the name of the
DataSource that should be used for
performing database functions. |
long |
getDbRetryInterval() |
protected DriverDelegate |
getDelegate()
Get the driver delegate for DB operations.
|
boolean |
getDoubleCheckLockMisfireHandler()
Get whether to check to see if there are Triggers that have misfired
before actually acquiring the lock to recover them.
|
String |
getDriverDelegateClass()
Get the JDBC driver delegate class name.
|
protected String |
getFiredTriggerRecordId() |
String |
getInstanceId()
Get the instance Id of the Scheduler (must be unique within a cluster).
|
String |
getInstanceName()
Get the instance name of the Scheduler (must be unique within this server instance).
|
protected String[] |
getJobGroupNames(Connection conn,
SchedulingContext ctxt) |
String[] |
getJobGroupNames(SchedulingContext ctxt)
Get the names of all of the
groups. |
protected String[] |
getJobNames(Connection conn,
SchedulingContext ctxt,
String groupName) |
String[] |
getJobNames(SchedulingContext ctxt,
String groupName)
Get the names of all of the
s that
have the given group name. |
protected Semaphore |
getLockHandler() |
protected org.apache.commons.logging.Log |
getLog() |
boolean |
getMakeThreadsDaemons()
Get whether the threads spawned by this JobStore should be
marked as daemon.
|
int |
getMaxMisfiresToHandleAtATime()
Get the maximum number of misfired triggers that the misfire handling
thread will try to recover at one time (within one transaction).
|
long |
getMisfireThreshold() |
protected long |
getMisfireTime() |
protected abstract Connection |
getNonManagedTXConnection() |
protected int |
getNumberOfCalendars(Connection conn,
SchedulingContext ctxt) |
int |
getNumberOfCalendars(SchedulingContext ctxt)
Get the number of
s that are
stored in the JobsStore. |
protected int |
getNumberOfJobs(Connection conn,
SchedulingContext ctxt) |
int |
getNumberOfJobs(SchedulingContext ctxt)
Get the number of
s that are
stored in the JobStore. |
protected int |
getNumberOfTriggers(Connection conn,
SchedulingContext ctxt) |
int |
getNumberOfTriggers(SchedulingContext ctxt)
Get the number of
s that are
stored in the JobsStore. |
Set |
getPausedTriggerGroups(Connection conn,
SchedulingContext ctxt)
Pause all of the
in the
given group. |
Set |
getPausedTriggerGroups(SchedulingContext ctxt) |
String |
getSelectWithLockSQL() |
String |
getTablePrefix()
Get the prefix that should be pre-pended to all table names.
|
protected String[] |
getTriggerGroupNames(Connection conn,
SchedulingContext ctxt) |
String[] |
getTriggerGroupNames(SchedulingContext ctxt)
Get the names of all of the
groups. |
protected String[] |
getTriggerNames(Connection conn,
SchedulingContext ctxt,
String groupName) |
String[] |
getTriggerNames(SchedulingContext ctxt,
String groupName)
Get the names of all of the
s
that have the given group name. |
protected Trigger[] |
getTriggersForJob(Connection conn,
SchedulingContext ctxt,
String jobName,
String groupName) |
Trigger[] |
getTriggersForJob(SchedulingContext ctxt,
String jobName,
String groupName)
Get all of the Triggers that are associated to the given Job.
|
int |
getTriggerState(Connection conn,
SchedulingContext ctxt,
String triggerName,
String groupName) |
int |
getTriggerState(SchedulingContext ctxt,
String triggerName,
String groupName)
Get the current state of the identified
. |
boolean |
getUseDBLocks()
Get whether this instance should use database-based thread
synchronization.
|
void |
initialize(ClassLoadHelper loadHelper,
SchedulerSignaler signaler)
Called by the QuartzScheduler before the
JobStore is
used, in order to give it a chance to initialize. |
boolean |
isAcquireTriggersWithinLock()
Whether or not the query and update to acquire a Trigger for firing
should be performed after obtaining an explicit DB lock (to avoid
possible race conditions on the trigger's db row).
|
boolean |
isClustered()
Get whether this instance is part of a cluster.
|
boolean |
isDontSetAutoCommitFalse() |
boolean |
isLockOnInsert() |
boolean |
isThreadsInheritInitializersClassLoadContext()
Get whether to set the class load context of spawned threads to that
of the initializing thread.
|
boolean |
isTxIsolationLevelSerializable() |
protected boolean |
jobExists(Connection conn,
String jobName,
String groupName)
Check existence of a given job.
|
protected void |
logWarnIfNonZero(int val,
String warning) |
void |
pauseAll(Connection conn,
SchedulingContext ctxt)
Pause all triggers - equivalent of calling
pauseTriggerGroup(group)
on every group. |
void |
pauseAll(SchedulingContext ctxt)
Pause all triggers - equivalent of calling
pauseTriggerGroup(group)
on every group. |
void |
pauseJob(SchedulingContext ctxt,
String jobName,
String groupName)
Pause the
with the given name - by
pausing all of its current Triggers. |
void |
pauseJobGroup(SchedulingContext ctxt,
String groupName)
Pause all of the
in the given
group - by pausing all of their Triggers. |
void |
pauseTrigger(Connection conn,
SchedulingContext ctxt,
String triggerName,
String groupName)
Pause the
with the given name. |
void |
pauseTrigger(SchedulingContext ctxt,
String triggerName,
String groupName)
Pause the
with the given name. |
void |
pauseTriggerGroup(Connection conn,
SchedulingContext ctxt,
String groupName)
Pause all of the
in the
given group. |
void |
pauseTriggerGroup(SchedulingContext ctxt,
String groupName)
Pause all of the
in the
given group. |
protected void |
recoverJobs()
Recover any failed or misfired jobs and clean up the data store as
appropriate.
|
protected void |
recoverJobs(Connection conn)
Will recover any failed or misfired jobs and clean up the data store as
appropriate.
|
protected JobStoreSupport.RecoverMisfiredJobsResult |
recoverMisfiredJobs(Connection conn,
boolean recovering) |
protected void |
releaseAcquiredTrigger(Connection conn,
SchedulingContext ctxt,
Trigger trigger) |
void |
releaseAcquiredTrigger(SchedulingContext ctxt,
Trigger trigger)
Inform the
JobStore that the scheduler no longer plans to
fire the given Trigger, that it had previously acquired
(reserved). |
protected void |
releaseLock(Connection conn,
String lockName,
boolean doIt) |
protected boolean |
removeCalendar(Connection conn,
SchedulingContext ctxt,
String calName) |
boolean |
removeCalendar(SchedulingContext ctxt,
String calName)
Remove (delete) the
with the
given name. |
protected boolean |
removeJob(Connection conn,
SchedulingContext ctxt,
String jobName,
String groupName,
boolean activeDeleteSafe) |
boolean |
removeJob(SchedulingContext ctxt,
String jobName,
String groupName)
|
protected boolean |
removeTrigger(Connection conn,
SchedulingContext ctxt,
String triggerName,
String groupName) |
boolean |
removeTrigger(SchedulingContext ctxt,
String triggerName,
String groupName)
Remove (delete) the
with the
given name. |
protected boolean |
replaceTrigger(Connection conn,
SchedulingContext ctxt,
String triggerName,
String groupName,
Trigger newTrigger) |
boolean |
replaceTrigger(SchedulingContext ctxt,
String triggerName,
String groupName,
Trigger newTrigger)
Remove (delete) the
with the
given name, and store the new given one - which must be associated
with the same job. |
void |
resumeAll(Connection conn,
SchedulingContext ctxt)
protected
|
void |
resumeAll(SchedulingContext ctxt)
Resume (un-pause) all triggers - equivalent of calling
resumeTriggerGroup(group)
on every group. |
void |
resumeJob(SchedulingContext ctxt,
String jobName,
String groupName)
Resume (un-pause) the
with the
given name. |
void |
resumeJobGroup(SchedulingContext ctxt,
String groupName)
Resume (un-pause) all of the
in
the given group. |
void |
resumeTrigger(Connection conn,
SchedulingContext ctxt,
String triggerName,
String groupName)
Resume (un-pause) the
with the
given name. |
void |
resumeTrigger(SchedulingContext ctxt,
String triggerName,
String groupName)
Resume (un-pause) the
with the
given name. |
void |
resumeTriggerGroup(Connection conn,
SchedulingContext ctxt,
String groupName)
Resume (un-pause) all of the
in the given group. |
void |
resumeTriggerGroup(SchedulingContext ctxt,
String groupName)
Resume (un-pause) all of the
in the given group. |
protected Calendar |
retrieveCalendar(Connection conn,
SchedulingContext ctxt,
String calName) |
Calendar |
retrieveCalendar(SchedulingContext ctxt,
String calName)
Retrieve the given
. |
protected JobDetail |
retrieveJob(Connection conn,
SchedulingContext ctxt,
String jobName,
String groupName) |
JobDetail |
retrieveJob(SchedulingContext ctxt,
String jobName,
String groupName)
|
protected Trigger |
retrieveTrigger(Connection conn,
SchedulingContext ctxt,
String triggerName,
String groupName) |
protected Trigger |
retrieveTrigger(Connection conn,
String triggerName,
String groupName) |
Trigger |
retrieveTrigger(SchedulingContext ctxt,
String triggerName,
String groupName)
Retrieve the given
. |
protected void |
rollbackConnection(Connection conn)
Rollback the supplied connection.
|
void |
schedulerStarted()
Called by the QuartzScheduler to inform the
JobStore that
the scheduler has started. |
void |
setAcquireTriggersWithinLock(boolean acquireTriggersWithinLock)
Whether or not the query and update to acquire a Trigger for firing
should be performed after obtaining an explicit DB lock.
|
void |
setClusterCheckinInterval(long l)
Set the frequency (in milliseconds) at which this instance "checks-in"
with the other instances of the cluster.
|
void |
setDataSource(String dsName)
Set the name of the
DataSource that should be used for
performing database functions. |
void |
setDbRetryInterval(long dbRetryInterval) |
void |
setDontSetAutoCommitFalse(boolean b)
Don't call set autocommit(false) on connections obtained from the
DataSource.
|
void |
setDoubleCheckLockMisfireHandler(boolean doubleCheckLockMisfireHandler)
Set whether to check to see if there are Triggers that have misfired
before actually acquiring the lock to recover them.
|
void |
setDriverDelegateClass(String delegateClassName)
Set the JDBC driver delegate class.
|
void |
setInstanceId(String instanceId)
Set the instance Id of the Scheduler (must be unique within a cluster).
|
void |
setInstanceName(String instanceName)
Set the instance name of the Scheduler (must be unique within this server instance).
|
void |
setIsClustered(boolean isClustered)
Set whether this instance is part of a cluster.
|
void |
setLockHandler(Semaphore lockHandler) |
void |
setLockOnInsert(boolean lockOnInsert)
Whether or not to obtain locks when inserting new jobs/triggers.
|
void |
setMakeThreadsDaemons(boolean makeThreadsDaemons)
Set whether the threads spawned by this JobStore should be
marked as daemon.
|
void |
setMaxMisfiresToHandleAtATime(int maxToRecoverAtATime)
Set the maximum number of misfired triggers that the misfire handling
thread will try to recover at one time (within one transaction).
|
void |
setMisfireThreshold(long misfireThreshold)
The the number of milliseconds by which a trigger must have missed its
next-fire-time, in order for it to be considered "misfired" and thus
have its misfire instruction applied.
|
void |
setSelectWithLockSQL(String string)
set the SQL statement to use to select and lock a row in the "locks"
table.
|
void |
setTablePrefix(String prefix)
Set the prefix that should be pre-pended to all table names.
|
void |
setThreadsInheritInitializersClassLoadContext(boolean threadsInheritInitializersClassLoadContext)
Set whether to set the class load context of spawned threads to that
of the initializing thread.
|
void |
setTxIsolationLevelSerializable(boolean b)
Set the transaction isolation level of DB connections to sequential.
|
void |
setUseDBLocks(boolean useDBLocks)
Set whether this instance should use database-based thread
synchronization.
|
void |
setUseProperties(String useProp)
Set whether String-only properties will be handled in JobDataMaps.
|
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. |
protected void |
signalSchedulingChange(long candidateNewNextFireTime) |
protected void |
storeCalendar(Connection conn,
SchedulingContext ctxt,
String calName,
Calendar calendar,
boolean replaceExisting,
boolean updateTriggers) |
void |
storeCalendar(SchedulingContext ctxt,
String calName,
Calendar calendar,
boolean replaceExisting,
boolean updateTriggers)
Store the given
. |
protected void |
storeJob(Connection conn,
SchedulingContext ctxt,
JobDetail newJob,
boolean replaceExisting)
Insert or update a job.
|
void |
storeJob(SchedulingContext ctxt,
JobDetail newJob,
boolean replaceExisting)
Store the given
. |
void |
storeJobAndTrigger(SchedulingContext ctxt,
JobDetail newJob,
Trigger newTrigger)
|
protected void |
storeTrigger(Connection conn,
SchedulingContext ctxt,
Trigger newTrigger,
JobDetail job,
boolean replaceExisting,
String state,
boolean forceState,
boolean recovering)
Insert or update a trigger.
|
void |
storeTrigger(SchedulingContext ctxt,
Trigger newTrigger,
boolean replaceExisting)
Store the given
. |
boolean |
supportsPersistence() |
protected void |
triggeredJobComplete(Connection conn,
SchedulingContext ctxt,
Trigger trigger,
JobDetail jobDetail,
int triggerInstCode) |
void |
triggeredJobComplete(SchedulingContext ctxt,
Trigger trigger,
JobDetail jobDetail,
int triggerInstCode)
Inform the
JobStore that the scheduler has completed the
firing of the given Trigger (and the execution its
associated Job), and that the
in the given JobDetail should be updated if the Job
is stateful. |
protected boolean |
triggerExists(Connection conn,
String triggerName,
String groupName)
Check existence of a given trigger.
|
protected TriggerFiredBundle |
triggerFired(Connection conn,
SchedulingContext ctxt,
Trigger trigger) |
TriggerFiredBundle |
triggerFired(SchedulingContext ctxt,
Trigger trigger)
Inform the
JobStore that the scheduler is now firing the
given Trigger (executing its associated Job),
that it had previously acquired (reserved). |
protected boolean |
updateMisfiredTrigger(Connection conn,
SchedulingContext ctxt,
String triggerName,
String groupName,
String newStateIfNotComplete,
boolean forceState) |
protected static final String LOCK_TRIGGER_ACCESS
protected static final String LOCK_JOB_ACCESS
protected static final String LOCK_CALENDAR_ACCESS
protected static final String LOCK_STATE_ACCESS
protected static final String LOCK_MISFIRE_ACCESS
protected String dsName
protected String tablePrefix
protected boolean useProperties
protected String instanceId
protected String instanceName
protected String delegateClassName
protected Class delegateClass
protected HashMap calendarCache
protected int maxToRecoverAtATime
protected boolean firstCheckIn
protected long lastCheckin
public void setDataSource(String dsName)
Set the name of the DataSource that should be used for
performing database functions.
public String getDataSource()
Get the name of the DataSource that should be used for
performing database functions.
public void setTablePrefix(String prefix)
Set the prefix that should be pre-pended to all table names.
public String getTablePrefix()
Get the prefix that should be pre-pended to all table names.
public void setUseProperties(String useProp)
Set whether String-only properties will be handled in JobDataMaps.
public boolean canUseProperties()
Get whether String-only properties will be handled in JobDataMaps.
public void setInstanceId(String instanceId)
Set the instance Id of the Scheduler (must be unique within a cluster).
setInstanceId in interface JobStorepublic String getInstanceId()
Get the instance Id of the Scheduler (must be unique within a cluster).
public void setInstanceName(String instanceName)
setInstanceName in interface JobStorepublic String getInstanceName()
public void setIsClustered(boolean isClustered)
Set whether this instance is part of a cluster.
public boolean isClustered()
Get whether this instance is part of a cluster.
public long getClusterCheckinInterval()
Get the frequency (in milliseconds) at which this instance "checks-in" with the other instances of the cluster. -- Affects the rate of detecting failed instances.
public void setClusterCheckinInterval(long l)
Set the frequency (in milliseconds) at which this instance "checks-in" with the other instances of the cluster. -- Affects the rate of detecting failed instances.
public int getMaxMisfiresToHandleAtATime()
Get the maximum number of misfired triggers that the misfire handling thread will try to recover at one time (within one transaction). The default is 20.
public void setMaxMisfiresToHandleAtATime(int maxToRecoverAtATime)
Set the maximum number of misfired triggers that the misfire handling thread will try to recover at one time (within one transaction). The default is 20.
public long getDbRetryInterval()
public void setDbRetryInterval(long dbRetryInterval)
dbRetryInterval - The dbRetryInterval to set.public void setUseDBLocks(boolean useDBLocks)
Set whether this instance should use database-based thread synchronization.
public boolean getUseDBLocks()
Get whether this instance should use database-based thread synchronization.
public boolean isLockOnInsert()
public void setLockOnInsert(boolean lockOnInsert)
true, which is safest - some db's (such as
MS SQLServer) seem to require this to avoid deadlocks under high load,
while others seem to do fine without.
Setting this property to false will provide a
significant performance increase during the addition of new jobs
and triggers.
lockOnInsert - public long getMisfireThreshold()
public void setMisfireThreshold(long misfireThreshold)
misfireThreshold - public boolean isDontSetAutoCommitFalse()
public void setDontSetAutoCommitFalse(boolean b)
b - public boolean isTxIsolationLevelSerializable()
public void setTxIsolationLevelSerializable(boolean b)
b - public boolean isAcquireTriggersWithinLock()
public void setAcquireTriggersWithinLock(boolean acquireTriggersWithinLock)
public void setDriverDelegateClass(String delegateClassName) throws InvalidConfigurationException
Set the JDBC driver delegate class.
delegateClassName - the delegate class nameInvalidConfigurationExceptionpublic String getDriverDelegateClass()
Get the JDBC driver delegate class name.
public String getSelectWithLockSQL()
public void setSelectWithLockSQL(String string)
set the SQL statement to use to select and lock a row in the "locks" table.
StdRowLockSemaphoreprotected ClassLoadHelper getClassLoadHelper()
public boolean getMakeThreadsDaemons()
MisfireHandler
and the ClusterManager.Thread.setDaemon(boolean)public void setMakeThreadsDaemons(boolean makeThreadsDaemons)
MisfireHandler
and the ClusterManager.Thread.setDaemon(boolean)public boolean isThreadsInheritInitializersClassLoadContext()
public void setThreadsInheritInitializersClassLoadContext(boolean threadsInheritInitializersClassLoadContext)
public boolean getDoubleCheckLockMisfireHandler()
public void setDoubleCheckLockMisfireHandler(boolean doubleCheckLockMisfireHandler)
protected org.apache.commons.logging.Log getLog()
public void initialize(ClassLoadHelper loadHelper, SchedulerSignaler signaler) throws SchedulerConfigException
Called by the QuartzScheduler before the JobStore is
used, in order to give it a chance to initialize.
initialize in interface JobStoreSchedulerConfigExceptionpublic void schedulerStarted()
throws SchedulerException
JobStore
Called by the QuartzScheduler to inform the JobStore that
the scheduler has started.
schedulerStarted in interface JobStoreSchedulerExceptionJobStore.schedulerStarted()public 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.
public boolean supportsPersistence()
supportsPersistence in interface JobStoreprotected abstract Connection getNonManagedTXConnection() throws JobPersistenceException
JobPersistenceExceptionprotected Connection getAttributeRestoringConnection(Connection conn)
Connection in a Proxy such that attributes
that might be set will be restored before the connection is closed
(and potentially restored to a pool).protected Connection getConnection() throws JobPersistenceException
JobPersistenceExceptionprotected void releaseLock(Connection conn, String lockName, boolean doIt)
protected void cleanVolatileTriggerAndJobs()
throws JobPersistenceException
JobPersistenceException - If jobs could not be recovered.protected void cleanVolatileTriggerAndJobs(Connection conn) throws JobPersistenceException
Removes all volatile data.
JobPersistenceException - if jobs could not be recoveredprotected void recoverJobs()
throws JobPersistenceException
JobPersistenceException - if jobs could not be recoveredprotected void recoverJobs(Connection conn) throws JobPersistenceException
Will recover any failed or misfired jobs and clean up the data store as appropriate.
JobPersistenceException - if jobs could not be recoveredprotected long getMisfireTime()
protected JobStoreSupport.RecoverMisfiredJobsResult recoverMisfiredJobs(Connection conn, boolean recovering) throws JobPersistenceException, SQLException
JobPersistenceExceptionSQLExceptionprotected boolean updateMisfiredTrigger(Connection conn, SchedulingContext ctxt, String triggerName, String groupName, String newStateIfNotComplete, boolean forceState) throws JobPersistenceException
JobPersistenceExceptionpublic void storeJobAndTrigger(SchedulingContext ctxt, JobDetail newJob, Trigger newTrigger) throws ObjectAlreadyExistsException, JobPersistenceException
storeJobAndTrigger 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 storeJob(SchedulingContext ctxt, JobDetail newJob, boolean replaceExisting) throws ObjectAlreadyExistsException, JobPersistenceException
Store the given .
JobDetail
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.JobPersistenceExceptionprotected void storeJob(Connection conn, SchedulingContext ctxt, JobDetail newJob, boolean replaceExisting) throws ObjectAlreadyExistsException, JobPersistenceException
Insert or update a job.
protected boolean jobExists(Connection conn, String jobName, String groupName) throws JobPersistenceException
Check existence of a given job.
JobPersistenceExceptionpublic void storeTrigger(SchedulingContext ctxt, Trigger newTrigger, boolean replaceExisting) throws ObjectAlreadyExistsException, JobPersistenceException
Store the given .
Trigger
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.pauseTriggerGroup(SchedulingContext, String)protected void storeTrigger(Connection conn, SchedulingContext ctxt, Trigger newTrigger, JobDetail job, boolean replaceExisting, String state, boolean forceState, boolean recovering) throws ObjectAlreadyExistsException, JobPersistenceException
Insert or update a trigger.
protected boolean triggerExists(Connection conn, String triggerName, String groupName) throws JobPersistenceException
Check existence of a given trigger.
JobPersistenceExceptionpublic boolean removeJob(SchedulingContext ctxt, String jobName, String groupName) throws JobPersistenceException
Remove (delete) the with the given
name, and any Job s that reference
it.
Trigger
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 JobStorejobName - The name of the Job to be removed.groupName - The group name of the Job to be removed.true if a Job with the given name &
group was found and removed from the store.JobPersistenceExceptionprotected boolean removeJob(Connection conn, SchedulingContext ctxt, String jobName, String groupName, boolean activeDeleteSafe) throws JobPersistenceException
JobPersistenceExceptionpublic JobDetail retrieveJob(SchedulingContext ctxt, String jobName, String groupName) throws JobPersistenceException
retrieveJob in interface JobStorejobName - The name of the Job to be retrieved.groupName - The group name of the Job to be retrieved.Job, or null if there is no match.JobPersistenceExceptionprotected JobDetail retrieveJob(Connection conn, SchedulingContext ctxt, String jobName, String groupName) throws JobPersistenceException
JobPersistenceExceptionpublic boolean removeTrigger(SchedulingContext ctxt, String triggerName, String groupName) throws JobPersistenceException
Remove (delete) the with the
given name.
Trigger
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 JobStoretriggerName - The name of the Trigger to be removed.groupName - The group name of the Trigger to be removed.true if a Trigger with the given
name & group was found and removed from the store.JobPersistenceExceptionprotected boolean removeTrigger(Connection conn, SchedulingContext ctxt, String triggerName, String groupName) throws JobPersistenceException
JobPersistenceExceptionpublic boolean replaceTrigger(SchedulingContext ctxt, String triggerName, String groupName, Trigger newTrigger) throws JobPersistenceException
JobStore
Remove (delete) the with the
given name, and store the new given one - which must be associated
with the same job.
Trigger
replaceTrigger in interface JobStoretriggerName - The name of the Trigger to be removed.groupName - The group name of the Trigger to be removed.newTrigger - The new Trigger to be stored.true if a Trigger with the given
name & group was found and removed from the store.JobPersistenceExceptionJobStore.replaceTrigger(org.quartz.core.SchedulingContext, java.lang.String, java.lang.String, org.quartz.Trigger)protected boolean replaceTrigger(Connection conn, SchedulingContext ctxt, String triggerName, String groupName, Trigger newTrigger) throws JobPersistenceException
JobPersistenceExceptionpublic Trigger retrieveTrigger(SchedulingContext ctxt, String triggerName, String groupName) throws JobPersistenceException
Retrieve the given .
Trigger
retrieveTrigger in interface JobStoretriggerName - The name of the Trigger to be retrieved.groupName - The group name of the Trigger to be retrieved.Trigger, or null if there is no
match.JobPersistenceExceptionprotected Trigger retrieveTrigger(Connection conn, SchedulingContext ctxt, String triggerName, String groupName) throws JobPersistenceException
JobPersistenceExceptionprotected Trigger retrieveTrigger(Connection conn, String triggerName, String groupName) throws JobPersistenceException
JobPersistenceExceptionpublic int getTriggerState(SchedulingContext ctxt, String triggerName, String groupName) throws JobPersistenceException
Get the current state of the identified .
Trigger
getTriggerState in interface JobStoreJobPersistenceExceptionTrigger.STATE_NORMAL,
Trigger.STATE_PAUSED,
Trigger.STATE_COMPLETE,
Trigger.STATE_ERROR,
Trigger.STATE_NONEpublic int getTriggerState(Connection conn, SchedulingContext ctxt, String triggerName, String groupName) throws JobPersistenceException
JobPersistenceExceptionpublic void storeCalendar(SchedulingContext ctxt, String calName, Calendar calendar, boolean replaceExisting, boolean updateTriggers) throws ObjectAlreadyExistsException, JobPersistenceException
Store the given .
Calendar
storeCalendar in interface JobStorecalName - The name of the calendar.calendar - 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.JobPersistenceExceptionprotected void storeCalendar(Connection conn, SchedulingContext ctxt, String calName, Calendar calendar, boolean replaceExisting, boolean updateTriggers) throws ObjectAlreadyExistsException, JobPersistenceException
protected boolean calendarExists(Connection conn, String calName) throws JobPersistenceException
JobPersistenceExceptionpublic boolean removeCalendar(SchedulingContext ctxt, String calName) throws JobPersistenceException
Remove (delete) the with the
given name.
Calendar
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.JobPersistenceExceptionprotected boolean removeCalendar(Connection conn, SchedulingContext ctxt, String calName) throws JobPersistenceException
JobPersistenceExceptionpublic Calendar retrieveCalendar(SchedulingContext ctxt, String calName) throws JobPersistenceException
Retrieve the given .
Trigger
retrieveCalendar in interface JobStorecalName - The name of the Calendar to be retrieved.Calendar, or null if there is no
match.JobPersistenceExceptionprotected Calendar retrieveCalendar(Connection conn, SchedulingContext ctxt, String calName) throws JobPersistenceException
JobPersistenceExceptionpublic int getNumberOfJobs(SchedulingContext ctxt) throws JobPersistenceException
Get the number of s that are
stored in the JobJobStore.
getNumberOfJobs in interface JobStoreJobPersistenceExceptionprotected int getNumberOfJobs(Connection conn, SchedulingContext ctxt) throws JobPersistenceException
JobPersistenceExceptionpublic int getNumberOfTriggers(SchedulingContext ctxt) throws JobPersistenceException
Get the number of s that are
stored in the TriggerJobsStore.
getNumberOfTriggers in interface JobStoreJobPersistenceExceptionprotected int getNumberOfTriggers(Connection conn, SchedulingContext ctxt) throws JobPersistenceException
JobPersistenceExceptionpublic int getNumberOfCalendars(SchedulingContext ctxt) throws JobPersistenceException
Get the number of s that are
stored in the CalendarJobsStore.
getNumberOfCalendars in interface JobStoreJobPersistenceExceptionprotected int getNumberOfCalendars(Connection conn, SchedulingContext ctxt) throws JobPersistenceException
JobPersistenceExceptionpublic String[] getJobNames(SchedulingContext ctxt, String groupName) throws JobPersistenceException
Get the names of all of the s that
have the given group name.
Job
If there are no jobs in the given group name, the result should be a
zero-length array (not null).
getJobNames in interface JobStoreJobPersistenceExceptionprotected String[] getJobNames(Connection conn, SchedulingContext ctxt, String groupName) throws JobPersistenceException
JobPersistenceExceptionpublic String[] getTriggerNames(SchedulingContext ctxt, String groupName) throws JobPersistenceException
Get the names of all of the s
that have the given group name.
Trigger
If there are no triggers in the given group name, the result should be a
zero-length array (not null).
getTriggerNames in interface JobStoreJobPersistenceExceptionprotected String[] getTriggerNames(Connection conn, SchedulingContext ctxt, String groupName) throws JobPersistenceException
JobPersistenceExceptionpublic String[] getJobGroupNames(SchedulingContext ctxt) throws JobPersistenceException
Get the names of all of the
groups.
Job
If there are no known group names, the result should be a zero-length
array (not null).
getJobGroupNames in interface JobStoreJobPersistenceExceptionprotected String[] getJobGroupNames(Connection conn, SchedulingContext ctxt) throws JobPersistenceException
JobPersistenceExceptionpublic String[] getTriggerGroupNames(SchedulingContext ctxt) throws JobPersistenceException
Get the names of all of the
groups.
Trigger
If there are no known group names, the result should be a zero-length
array (not null).
getTriggerGroupNames in interface JobStoreJobPersistenceExceptionprotected String[] getTriggerGroupNames(Connection conn, SchedulingContext ctxt) throws JobPersistenceException
JobPersistenceExceptionpublic String[] getCalendarNames(SchedulingContext ctxt) throws JobPersistenceException
Get the names of all of the s
in the CalendarJobStore.
If there are no Calendars in the given group name, the result should be
a zero-length array (not null).
getCalendarNames in interface JobStoreJobPersistenceExceptionprotected String[] getCalendarNames(Connection conn, SchedulingContext ctxt) throws JobPersistenceException
JobPersistenceExceptionpublic Trigger[] getTriggersForJob(SchedulingContext ctxt, String jobName, String groupName) 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.
getTriggersForJob in interface JobStoreJobPersistenceExceptionprotected Trigger[] getTriggersForJob(Connection conn, SchedulingContext ctxt, String jobName, String groupName) throws JobPersistenceException
JobPersistenceExceptionpublic void pauseTrigger(SchedulingContext ctxt, String triggerName, String groupName) throws JobPersistenceException
Pause the with the given name.
Trigger
pauseTrigger in interface JobStoreJobPersistenceExceptionresumeTrigger(SchedulingContext, String, String)public void pauseTrigger(Connection conn, SchedulingContext ctxt, String triggerName, String groupName) throws JobPersistenceException
Pause the with the given name.
Trigger
public void pauseJob(SchedulingContext ctxt, String jobName, String groupName) throws JobPersistenceException
Pause the with the given name - by
pausing all of its current JobTriggers.
pauseJob in interface JobStoreJobPersistenceExceptionresumeJob(SchedulingContext, String, String)public void pauseJobGroup(SchedulingContext ctxt, String groupName) throws JobPersistenceException
Pause all of the in the given
group - by pausing all of their JobsTriggers.
pauseJobGroup in interface JobStoreJobPersistenceExceptionresumeJobGroup(SchedulingContext, String)protected String checkBlockedState(Connection conn, SchedulingContext ctxt, String jobName, String jobGroupName, String currentState) throws JobPersistenceException
JobPersistenceExceptionpublic void resumeTrigger(SchedulingContext ctxt, String triggerName, String groupName) throws JobPersistenceException
Resume (un-pause) the with the
given name.
Trigger
If the Trigger missed one or more fire-times, then the
Trigger's misfire instruction will be applied.
resumeTrigger in interface JobStoreJobPersistenceExceptionpauseTrigger(SchedulingContext, String, String)public void resumeTrigger(Connection conn, SchedulingContext ctxt, String triggerName, String groupName) throws JobPersistenceException
Resume (un-pause) the with the
given name.
Trigger
If the Trigger missed one or more fire-times, then the
Trigger's misfire instruction will be applied.
public void resumeJob(SchedulingContext ctxt, String jobName, String groupName) throws JobPersistenceException
Resume (un-pause) the with the
given name.
Job
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 JobStoreJobPersistenceExceptionpauseJob(SchedulingContext, String, String)public void resumeJobGroup(SchedulingContext ctxt, String groupName) throws JobPersistenceException
Resume (un-pause) all of the in
the given group.
Jobs
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.
resumeJobGroup in interface JobStoreJobPersistenceExceptionpauseJobGroup(SchedulingContext, String)public void pauseTriggerGroup(SchedulingContext ctxt, String groupName) throws JobPersistenceException
Pause all of the in the
given group.
Triggers
pauseTriggerGroup in interface JobStoreJobPersistenceExceptionresumeTriggerGroup(SchedulingContext, String)public void pauseTriggerGroup(Connection conn, SchedulingContext ctxt, String groupName) throws JobPersistenceException
Pause all of the in the
given group.
Triggers
public Set getPausedTriggerGroups(SchedulingContext ctxt) throws JobPersistenceException
getPausedTriggerGroups in interface JobStoreJobPersistenceExceptionpublic Set getPausedTriggerGroups(Connection conn, SchedulingContext ctxt) throws JobPersistenceException
Pause all of the in the
given group.
Triggers
public void resumeTriggerGroup(SchedulingContext ctxt, String groupName) throws JobPersistenceException
Resume (un-pause) all of the
in the given group.
Triggers
If any Trigger missed one or more fire-times, then the
Trigger's misfire instruction will be applied.
resumeTriggerGroup in interface JobStoreJobPersistenceExceptionpauseTriggerGroup(SchedulingContext, String)public void resumeTriggerGroup(Connection conn, SchedulingContext ctxt, String groupName) throws JobPersistenceException
Resume (un-pause) all of the
in the given group.
Triggers
If any Trigger missed one or more fire-times, then the
Trigger's misfire instruction will be applied.
public void pauseAll(SchedulingContext ctxt) throws JobPersistenceException
Pause all triggers - equivalent of calling pauseTriggerGroup(group)
on every group.
When resumeAll() is called (to un-pause), trigger misfire
instructions WILL be applied.
pauseAll in interface JobStoreJobPersistenceExceptionresumeAll(SchedulingContext),
pauseTriggerGroup(SchedulingContext, String)public void pauseAll(Connection conn, SchedulingContext ctxt) throws JobPersistenceException
Pause all triggers - equivalent of calling pauseTriggerGroup(group)
on every group.
When resumeAll() is called (to un-pause), trigger misfire
instructions WILL be applied.
public void resumeAll(SchedulingContext ctxt) throws JobPersistenceException
Resume (un-pause) all triggers - equivalent of calling resumeTriggerGroup(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 JobStoreJobPersistenceExceptionpauseAll(SchedulingContext)public void resumeAll(Connection conn, SchedulingContext ctxt) throws JobPersistenceException
Resume (un-pause) all triggers - equivalent of calling resumeTriggerGroup(group)
on every group.
If any Trigger missed one or more fire-times, then the
Trigger's misfire instruction will be applied.
JobPersistenceExceptionpauseAll(SchedulingContext)protected String getFiredTriggerRecordId()
public Trigger acquireNextTrigger(SchedulingContext ctxt, long noLaterThan) throws JobPersistenceException
Get a handle to the next N triggers to be fired, and mark them as 'reserved' by the calling scheduler.
acquireNextTrigger 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.JobPersistenceExceptionreleaseAcquiredTrigger(SchedulingContext, Trigger)protected Trigger acquireNextTrigger(Connection conn, SchedulingContext ctxt, long noLaterThan) throws JobPersistenceException
JobPersistenceExceptionpublic void releaseAcquiredTrigger(SchedulingContext ctxt, Trigger trigger) throws JobPersistenceException
Inform the JobStore that the scheduler no longer plans to
fire the given Trigger, that it had previously acquired
(reserved).
releaseAcquiredTrigger in interface JobStoreJobPersistenceExceptionprotected void releaseAcquiredTrigger(Connection conn, SchedulingContext ctxt, Trigger trigger) throws JobPersistenceException
JobPersistenceExceptionpublic TriggerFiredBundle triggerFired(SchedulingContext ctxt, Trigger trigger) throws JobPersistenceException
Inform the JobStore that the scheduler is now firing the
given Trigger (executing its associated Job),
that it had previously acquired (reserved).
triggerFired in interface JobStoreJobPersistenceExceptionprotected TriggerFiredBundle triggerFired(Connection conn, SchedulingContext ctxt, Trigger trigger) throws JobPersistenceException
JobPersistenceExceptionpublic void triggeredJobComplete(SchedulingContext ctxt, Trigger trigger, JobDetail jobDetail, int triggerInstCode) throws JobPersistenceException
Inform the JobStore that the scheduler has completed the
firing of the given Trigger (and the execution its
associated Job), and that the
in the given JobDataMapJobDetail should be updated if the Job
is stateful.
triggeredJobComplete in interface JobStoreJobPersistenceExceptionprotected void triggeredJobComplete(Connection conn, SchedulingContext ctxt, Trigger trigger, JobDetail jobDetail, int triggerInstCode) throws JobPersistenceException
JobPersistenceExceptionprotected DriverDelegate getDelegate() throws NoSuchDelegateException
Get the driver delegate for DB operations.
NoSuchDelegateExceptionprotected Semaphore getLockHandler()
public void setLockHandler(Semaphore lockHandler)
protected JobStoreSupport.RecoverMisfiredJobsResult doRecoverMisfires() throws JobPersistenceException
JobPersistenceExceptionprotected void signalSchedulingChange(long candidateNewNextFireTime)
protected boolean doCheckin()
throws JobPersistenceException
JobPersistenceExceptionprotected List findFailedInstances(Connection conn) throws JobPersistenceException
JobPersistenceExceptionprotected long calcFailedIfAfter(SchedulerStateRecord rec)
protected List clusterCheckIn(Connection conn) throws JobPersistenceException
JobPersistenceExceptionprotected void clusterRecover(Connection conn, List failedInstances) throws JobPersistenceException
JobPersistenceExceptionprotected void logWarnIfNonZero(int val,
String warning)
protected void cleanupConnection(Connection conn)
Cleanup the given database connection. This means restoring any modified auto commit or transaction isolation connection attributes, and then closing the underlying connection.
This is separate from closeConnection() because the Spring integration relies on being able to overload closeConnection() and expects the same connection back that it originally returned from the datasource.
closeConnection(Connection)protected void closeConnection(Connection conn)
Connection.
Ignores a null Connection.
Any exception thrown trying to close the Connection is
logged and ignored.
conn - The Connection to close (Optional).protected void rollbackConnection(Connection conn)
Logs any SQLException it gets trying to rollback, but will not propogate the exception lest it mask the exception that caused the caller to need to rollback in the first place.
conn - (Optional)protected void commitConnection(Connection conn) throws JobPersistenceException
conn - (Optional)JobPersistenceException - thrown if a SQLException occurs when the
connection is committedpublic Object executeWithoutLock(JobStoreSupport.TransactionCallback txCallback) throws JobPersistenceException
This method just forwards to executeInLock() with a null lockName.
JobPersistenceExceptionexecuteInLock(String, TransactionCallback)protected void executeInLock(String lockName, JobStoreSupport.VoidTransactionCallback txCallback) throws JobPersistenceException
lockName - The name of the lock to aquire, for example
"TRIGGER_ACCESS". If null, then no lock is aquired, but the
lockCallback is still executed in a transaction.JobPersistenceExceptionexecuteInLock(String, TransactionCallback)protected abstract Object executeInLock(String lockName, JobStoreSupport.TransactionCallback txCallback) throws JobPersistenceException
lockName - The name of the lock to aquire, for example
"TRIGGER_ACCESS". If null, then no lock is aquired, but the
lockCallback is still executed in a transaction.JobPersistenceExceptionprotected void executeInNonManagedTXLock(String lockName, JobStoreSupport.VoidTransactionCallback txCallback) throws JobPersistenceException
lockName - The name of the lock to aquire, for example
"TRIGGER_ACCESS". If null, then no lock is aquired, but the
lockCallback is still executed in a non-managed transaction.JobPersistenceExceptionexecuteInNonManagedTXLock(String, TransactionCallback)protected Object executeInNonManagedTXLock(String lockName, JobStoreSupport.TransactionCallback txCallback) throws JobPersistenceException
lockName - The name of the lock to aquire, for example
"TRIGGER_ACCESS". If null, then no lock is aquired, but the
lockCallback is still executed in a non-managed transaction.JobPersistenceExceptionCopyright © 2014. All rights reserved.