Class JobStoreSupport
- java.lang.Object
-
- org.quartz.impl.jdbcjobstore.JobStoreSupport
-
- Direct Known Subclasses:
JobStoreCMT,JobStoreTX
public abstract class JobStoreSupport extends java.lang.Object implements JobStore, Constants
Contains base functionality for JDBC-based JobStore implementations.
- Author:
- Jeffrey Wescott, James House
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classJobStoreSupport.RecoverMisfiredJobsResultHelper class for returning the composite result of trying to recover misfired jobs.protected static interfaceJobStoreSupport.TransactionCallback<T>Implement this interface to provide the code to execute within the a transaction template.protected static interfaceJobStoreSupport.TransactionValidator<T>protected classJobStoreSupport.VoidTransactionCallbackImplement this interface to provide the code to execute within the a transaction template that has no return value.
-
Field Summary
Fields Modifier and Type Field Description protected java.util.HashMap<java.lang.String,Calendar>calendarCacheprotected java.lang.Class<? extends DriverDelegate>delegateClassprotected java.lang.StringdelegateClassNameprotected java.lang.StringdelegateInitStringprotected java.lang.StringdsNameprotected booleanfirstCheckInprotected java.lang.StringinstanceIdprotected java.lang.StringinstanceNameprotected longlastCheckinprotected static java.lang.StringLOCK_STATE_ACCESSprotected static java.lang.StringLOCK_TRIGGER_ACCESSprotected intmaxToRecoverAtATimeprotected java.lang.ThreadLocal<java.lang.Long>sigChangeForTxCompletionprotected java.lang.StringtablePrefixprotected booleanuseProperties-
Fields inherited from interface org.quartz.impl.jdbcjobstore.Constants
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_NONCONCURRENT, COL_IS_UPDATE_DATA, COL_IS_VOLATILE, COL_JOB_CLASS, COL_JOB_DATAMAP, COL_JOB_GROUP, 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_SCHED_TIME, COL_SCHEDULER_NAME, COL_START_TIME, COL_TIME_ZONE_ID, COL_TIMES_TRIGGERED, COL_TRIGGER_GROUP, 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_LOCKS, TABLE_PAUSED_TRIGGERS, TABLE_SCHEDULER_STATE, TABLE_SIMPLE_TRIGGERS, TABLE_TRIGGERS, TTYPE_BLOB, TTYPE_CAL_INT, TTYPE_CRON, TTYPE_DAILY_TIME_INT, TTYPE_SIMPLE
-
-
Constructor Summary
Constructors Constructor Description JobStoreSupport()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected java.util.List<OperableTrigger>acquireNextTrigger(java.sql.Connection conn, long noLaterThan, int maxCount, long timeWindow)java.util.List<OperableTrigger>acquireNextTriggers(long noLaterThan, int maxCount, long timeWindow)Get a handle to the next N triggers to be fired, and mark them as 'reserved' by the calling scheduler.protected longcalcFailedIfAfter(SchedulerStateRecord rec)protected booleancalendarExists(java.sql.Connection conn, java.lang.String calName)booleancanUseProperties()Get whether String-only properties will be handled in JobDataMaps.protected java.lang.StringcheckBlockedState(java.sql.Connection conn, JobKey jobKey, java.lang.String currentState)Determines if a Trigger for the given job should be blocked.protected booleancheckExists(java.sql.Connection conn, JobKey jobKey)protected booleancheckExists(java.sql.Connection conn, TriggerKey triggerKey)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.protected voidcleanupConnection(java.sql.Connection conn)Cleanup the given database connection.voidclearAllSchedulingData()protected voidclearAllSchedulingData(java.sql.Connection conn)protected java.lang.LongclearAndGetSignalSchedulingChangeOnTxCompletion()protected voidcloseConnection(java.sql.Connection conn)Closes the suppliedConnection.protected java.util.List<SchedulerStateRecord>clusterCheckIn(java.sql.Connection conn)protected voidclusterRecover(java.sql.Connection conn, java.util.List<SchedulerStateRecord> failedInstances)protected voidcommitConnection(java.sql.Connection conn)Commit the supplied connectionprotected booleandoCheckin()protected JobStoreSupport.RecoverMisfiredJobsResultdoRecoverMisfires()protected abstract <T> TexecuteInLock(java.lang.String lockName, JobStoreSupport.TransactionCallback<T> txCallback)Execute the given callback having acquired the given lock.protected <T> TexecuteInNonManagedTXLock(java.lang.String lockName, JobStoreSupport.TransactionCallback<T> txCallback, JobStoreSupport.TransactionValidator<T> txValidator)Execute the given callback having optionally acquired the given lock.<T> TexecuteWithoutLock(JobStoreSupport.TransactionCallback<T> txCallback)Execute the given callback in a transaction.protected java.util.List<SchedulerStateRecord>findFailedInstances(java.sql.Connection conn)Get a list of all scheduler instances in the cluster that may have failed.longgetAcquireRetryDelay(int failureCount)Get the amount of time (in ms) to wait when accessing this job store repeatedly fails.protected java.sql.ConnectiongetAttributeRestoringConnection(java.sql.Connection conn)Wrap the givenConnectionin a Proxy such that attributes that might be set will be restored before the connection is closed (and potentially restored to a pool).java.util.List<java.lang.String>getCalendarNames()Get the names of all of thes in theCalendarJobStore.protected java.util.List<java.lang.String>getCalendarNames(java.sql.Connection conn)protected ClassLoadHelpergetClassLoadHelper()longgetClusterCheckinInterval()Get the frequency (in milliseconds) at which this instance "checks-in" with the other instances of the cluster.protected java.sql.ConnectiongetConnection()java.lang.StringgetDataSource()Get the name of theDataSourcethat should be used for performing database functions.longgetDbRetryInterval()protected DriverDelegategetDelegate()Get the driver delegate for DB operations.booleangetDoubleCheckLockMisfireHandler()Get whether to check to see if there are Triggers that have misfired before actually acquiring the lock to recover them.java.lang.StringgetDriverDelegateClass()Get the JDBC driver delegate class name.java.lang.StringgetDriverDelegateInitString()Get the JDBC driver delegate's initialization string.longgetEstimatedTimeToReleaseAndAcquireTrigger()How long (in milliseconds) theJobStoreimplementation estimates that it will take to release a trigger and acquire a new one.protected java.lang.StringgetFiredTriggerRecordId()java.lang.StringgetInstanceId()Get the instance Id of the Scheduler (must be unique within a cluster).java.lang.StringgetInstanceName()Get the instance name of the Scheduler (must be unique within this server instance).java.util.List<java.lang.String>getJobGroupNames()Get the names of all of thegroups.Jobprotected java.util.List<java.lang.String>getJobGroupNames(java.sql.Connection conn)java.util.Set<JobKey>getJobKeys(GroupMatcher<JobKey> matcher)Get the names of all of thes that matcher the given groupMatcher.Jobprotected java.util.Set<JobKey>getJobNames(java.sql.Connection conn, GroupMatcher<JobKey> matcher)protected SemaphoregetLockHandler()protected org.slf4j.LoggergetLog()booleangetMakeThreadsDaemons()Get whether the threads spawned by this JobStore should be marked as daemon.intgetMaxMisfiresToHandleAtATime()Get the maximum number of misfired triggers that the misfire handling thread will try to recover at one time (within one transaction).longgetMisfireThreshold()protected longgetMisfireTime()protected abstract java.sql.ConnectiongetNonManagedTXConnection()intgetNumberOfCalendars()Get the number ofs that are stored in theCalendarJobsStore.protected intgetNumberOfCalendars(java.sql.Connection conn)intgetNumberOfJobs()Get the number ofs that are stored in theJobJobStore.protected intgetNumberOfJobs(java.sql.Connection conn)intgetNumberOfTriggers()Get the number ofs that are stored in theTriggerJobsStore.protected intgetNumberOfTriggers(java.sql.Connection conn)java.util.Set<java.lang.String>getPausedTriggerGroups()java.util.Set<java.lang.String>getPausedTriggerGroups(java.sql.Connection conn)Pause all of thein the given group.Triggersjava.lang.StringgetSelectWithLockSQL()java.lang.StringgetTablePrefix()Get the prefix that should be pre-pended to all table names.ThreadExecutorgetThreadExecutor()java.util.List<java.lang.String>getTriggerGroupNames()Get the names of all of thegroups.Triggerprotected java.util.List<java.lang.String>getTriggerGroupNames(java.sql.Connection conn)java.util.Set<TriggerKey>getTriggerKeys(GroupMatcher<TriggerKey> matcher)Get the names of all of thes that match the given group Matcher.Triggerprotected java.util.Set<TriggerKey>getTriggerNames(java.sql.Connection conn, GroupMatcher<TriggerKey> matcher)protected java.util.List<OperableTrigger>getTriggersForJob(java.sql.Connection conn, JobKey key)java.util.List<OperableTrigger>getTriggersForJob(JobKey jobKey)Get all of the Triggers that are associated to the given Job.Trigger.TriggerStategetTriggerState(java.sql.Connection conn, TriggerKey key)Trigger.TriggerStategetTriggerState(TriggerKey triggerKey)Get the current state of the identified.TriggerbooleangetUseDBLocks()Get whether this instance should use database-based thread synchronization.voidinitialize(ClassLoadHelper loadHelper, SchedulerSignaler signaler)Called by the QuartzScheduler before theJobStoreis used, in order to give it a chance to initialize.booleanisAcquireTriggersWithinLock()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).booleanisClustered()Get whether this instance is part of a cluster.booleanisDontSetAutoCommitFalse()booleanisLockOnInsert()booleanisThreadsInheritInitializersClassLoadContext()Get whether to set the class load context of spawned threads to that of the initializing thread.booleanisTxIsolationLevelSerializable()protected booleanjobExists(java.sql.Connection conn, JobKey jobKey)Check existence of a given job.protected voidlogWarnIfNonZero(int val, java.lang.String warning)voidpauseAll()Pause all triggers - equivalent of callingpauseTriggerGroup(group)on every group.voidpauseAll(java.sql.Connection conn)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.Set<java.lang.String>pauseJobs(GroupMatcher<JobKey> matcher)Pause all of thematching the given groupMatcher - by pausing all of theirJobsTriggers.voidpauseTrigger(java.sql.Connection conn, TriggerKey triggerKey)Pause thewith the given name.TriggervoidpauseTrigger(TriggerKey triggerKey)Pause thewith the given name.Triggerjava.util.Set<java.lang.String>pauseTriggerGroup(java.sql.Connection conn, GroupMatcher<TriggerKey> matcher)Pause all of thematching the given groupMatcher.Triggersjava.util.Set<java.lang.String>pauseTriggers(GroupMatcher<TriggerKey> matcher)Pause all of thematching the given groupMatcher.Triggersprotected voidrecoverJobs()Recover any failed or misfired jobs and clean up the data store as appropriate.protected voidrecoverJobs(java.sql.Connection conn)Will recover any failed or misfired jobs and clean up the data store as appropriate.protected JobStoreSupport.RecoverMisfiredJobsResultrecoverMisfiredJobs(java.sql.Connection conn, boolean recovering)protected voidreleaseAcquiredTrigger(java.sql.Connection conn, OperableTrigger trigger)voidreleaseAcquiredTrigger(OperableTrigger trigger)Inform theJobStorethat the scheduler no longer plans to fire the givenTrigger, that it had previously acquired (reserved).protected voidreleaseLock(java.lang.String lockName, boolean doIt)booleanremoveCalendar(java.lang.String calName)Remove (delete) thewith the given name.Calendarprotected booleanremoveCalendar(java.sql.Connection conn, java.lang.String calName)protected booleanremoveJob(java.sql.Connection conn, JobKey jobKey)booleanremoveJob(JobKey jobKey)booleanremoveJobs(java.util.List<JobKey> jobKeys)protected booleanremoveTrigger(java.sql.Connection conn, TriggerKey key)booleanremoveTrigger(TriggerKey triggerKey)Remove (delete) thewith the given name.TriggerbooleanremoveTriggers(java.util.List<TriggerKey> triggerKeys)protected booleanreplaceTrigger(java.sql.Connection conn, TriggerKey key, OperableTrigger newTrigger)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.voidresumeAll(java.sql.Connection conn)protectedvoidresumeJob(JobKey jobKey)Resume (un-pause) thewith the given name.Jobjava.util.Set<java.lang.String>resumeJobs(GroupMatcher<JobKey> matcher)Resume (un-pause) all of thein the given group.JobsvoidresumeTrigger(java.sql.Connection conn, TriggerKey key)Resume (un-pause) thewith the given name.TriggervoidresumeTrigger(TriggerKey triggerKey)Resume (un-pause) thewith the given name.Triggerjava.util.Set<java.lang.String>resumeTriggerGroup(java.sql.Connection conn, GroupMatcher<TriggerKey> matcher)Resume (un-pause) all of thematching the given groupMatcher.Triggersjava.util.Set<java.lang.String>resumeTriggers(GroupMatcher<TriggerKey> matcher)Resume (un-pause) all of thematching the given groupMatcher.TriggersCalendarretrieveCalendar(java.lang.String calName)Retrieve the given.Triggerprotected CalendarretrieveCalendar(java.sql.Connection conn, java.lang.String calName)protected JobDetailretrieveJob(java.sql.Connection conn, JobKey key)JobDetailretrieveJob(JobKey jobKey)protected OperableTriggerretrieveTrigger(java.sql.Connection conn, TriggerKey key)OperableTriggerretrieveTrigger(TriggerKey triggerKey)Retrieve the given.Triggerprotected <T> TretryExecuteInNonManagedTXLock(java.lang.String lockName, JobStoreSupport.TransactionCallback<T> txCallback)protected voidrollbackConnection(java.sql.Connection conn)Rollback the supplied connection.voidschedulerPaused()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.voidsetAcquireTriggersWithinLock(boolean acquireTriggersWithinLock)Whether or not the query and update to acquire a Trigger for firing should be performed after obtaining an explicit DB lock.voidsetClusterCheckinInterval(long l)Set the frequency (in milliseconds) at which this instance "checks-in" with the other instances of the cluster.voidsetDataSource(java.lang.String dsName)Set the name of theDataSourcethat should be used for performing database functions.voidsetDbRetryInterval(long dbRetryInterval)voidsetDontSetAutoCommitFalse(boolean b)Don't call set autocommit(false) on connections obtained from the DataSource.voidsetDoubleCheckLockMisfireHandler(boolean doubleCheckLockMisfireHandler)Set whether to check to see if there are Triggers that have misfired before actually acquiring the lock to recover them.voidsetDriverDelegateClass(java.lang.String delegateClassName)Set the JDBC driver delegate class.voidsetDriverDelegateInitString(java.lang.String delegateInitString)Set the JDBC driver delegate's initialization string.voidsetInstanceId(java.lang.String instanceId)Set the instance Id of the Scheduler (must be unique within a cluster).voidsetInstanceName(java.lang.String instanceName)Set the instance name of the Scheduler (must be unique within this server instance).voidsetIsClustered(boolean isClustered)Set whether this instance is part of a cluster.voidsetLockHandler(Semaphore lockHandler)voidsetLockOnInsert(boolean lockOnInsert)Whether or not to obtain locks when inserting new jobs/triggers.voidsetMakeThreadsDaemons(boolean makeThreadsDaemons)Set whether the threads spawned by this JobStore should be marked as daemon.voidsetMaxMisfiresToHandleAtATime(int maxToRecoverAtATime)Set the maximum number of misfired triggers that the misfire handling thread will try to recover at one time (within one transaction).voidsetMisfireThreshold(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.voidsetSelectWithLockSQL(java.lang.String string)set the SQL statement to use to select and lock a row in the "locks" table.voidsetTablePrefix(java.lang.String prefix)Set the prefix that should be pre-pended to all table names.voidsetThreadExecutor(ThreadExecutor threadExecutor)voidsetThreadPoolSize(int poolSize)Tells the JobStore the pool size used to execute jobsvoidsetThreadsInheritInitializersClassLoadContext(boolean threadsInheritInitializersClassLoadContext)Set whether to set the class load context of spawned threads to that of the initializing thread.voidsetTxIsolationLevelSerializable(boolean b)Set the transaction isolation level of DB connections to sequential.voidsetUseDBLocks(boolean useDBLocks)Set whether this instance should use database-based thread synchronization.voidsetUseProperties(java.lang.String useProp)Set whether String-only properties will be handled in JobDataMaps.voidshutdown()Called by the QuartzScheduler to inform theJobStorethat it should free up all of it's resources because the scheduler is shutting down.protected voidsignalSchedulingChangeImmediately(long candidateNewNextFireTime)protected voidsignalSchedulingChangeOnTxCompletion(long candidateNewNextFireTime)voidstoreCalendar(java.lang.String calName, Calendar calendar, boolean replaceExisting, boolean updateTriggers)Store the given.Calendarprotected voidstoreCalendar(java.sql.Connection conn, java.lang.String calName, Calendar calendar, boolean replaceExisting, boolean updateTriggers)protected voidstoreJob(java.sql.Connection conn, JobDetail newJob, boolean replaceExisting)Insert or update a job.voidstoreJob(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)protected voidstoreTrigger(java.sql.Connection conn, OperableTrigger newTrigger, JobDetail job, boolean replaceExisting, java.lang.String state, boolean forceState, boolean recovering)Insert or update a trigger.voidstoreTrigger(OperableTrigger newTrigger, boolean replaceExisting)Store the given.TriggerbooleansupportsPersistence()protected voidtriggeredJobComplete(java.sql.Connection conn, OperableTrigger trigger, JobDetail jobDetail, Trigger.CompletedExecutionInstruction triggerInstCode)voidtriggeredJobComplete(OperableTrigger trigger, JobDetail jobDetail, Trigger.CompletedExecutionInstruction triggerInstCode)Inform theJobStorethat the scheduler has completed the firing of the givenTrigger(and the execution its associatedJob), and that thein the givenJobDataMapJobDetailshould be updated if theJobis stateful.protected booleantriggerExists(java.sql.Connection conn, TriggerKey key)Check existence of a given trigger.protected TriggerFiredBundletriggerFired(java.sql.Connection conn, OperableTrigger trigger)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).protected booleanupdateMisfiredTrigger(java.sql.Connection conn, TriggerKey triggerKey, java.lang.String newStateIfNotComplete, boolean forceState)
-
-
-
Field Detail
-
LOCK_TRIGGER_ACCESS
protected static final java.lang.String LOCK_TRIGGER_ACCESS
- See Also:
- Constant Field Values
-
LOCK_STATE_ACCESS
protected static final java.lang.String LOCK_STATE_ACCESS
- See Also:
- Constant Field Values
-
dsName
protected java.lang.String dsName
-
tablePrefix
protected java.lang.String tablePrefix
-
useProperties
protected boolean useProperties
-
instanceId
protected java.lang.String instanceId
-
instanceName
protected java.lang.String instanceName
-
delegateClassName
protected java.lang.String delegateClassName
-
delegateInitString
protected java.lang.String delegateInitString
-
delegateClass
protected java.lang.Class<? extends DriverDelegate> delegateClass
-
calendarCache
protected final java.util.HashMap<java.lang.String,Calendar> calendarCache
-
maxToRecoverAtATime
protected int maxToRecoverAtATime
-
sigChangeForTxCompletion
protected final java.lang.ThreadLocal<java.lang.Long> sigChangeForTxCompletion
-
firstCheckIn
protected boolean firstCheckIn
-
lastCheckin
protected long lastCheckin
-
-
Method Detail
-
setDataSource
public void setDataSource(java.lang.String dsName)
Set the name of the
DataSourcethat should be used for performing database functions.
-
getDataSource
public java.lang.String getDataSource()
Get the name of the
DataSourcethat should be used for performing database functions.
-
setTablePrefix
public void setTablePrefix(java.lang.String prefix)
Set the prefix that should be pre-pended to all table names.
-
getTablePrefix
public java.lang.String getTablePrefix()
Get the prefix that should be pre-pended to all table names.
-
setUseProperties
public void setUseProperties(java.lang.String useProp)
Set whether String-only properties will be handled in JobDataMaps.
-
canUseProperties
public boolean canUseProperties()
Get whether String-only properties will be handled in JobDataMaps.
-
setInstanceId
public void setInstanceId(java.lang.String instanceId)
Set the instance Id of the Scheduler (must be unique within a cluster).
- Specified by:
setInstanceIdin interfaceJobStore
-
getInstanceId
public java.lang.String getInstanceId()
Get the instance Id of the Scheduler (must be unique within a cluster).
-
setInstanceName
public void setInstanceName(java.lang.String instanceName)
Set the instance name of the Scheduler (must be unique within this server instance).- Specified by:
setInstanceNamein interfaceJobStore
-
setThreadPoolSize
public void setThreadPoolSize(int poolSize)
Description copied from interface:JobStoreTells the JobStore the pool size used to execute jobs- Specified by:
setThreadPoolSizein interfaceJobStore- Parameters:
poolSize- amount of threads allocated for job execution
-
setThreadExecutor
public void setThreadExecutor(ThreadExecutor threadExecutor)
-
getThreadExecutor
public ThreadExecutor getThreadExecutor()
-
getInstanceName
public java.lang.String getInstanceName()
Get the instance name of the Scheduler (must be unique within this server instance).
-
getEstimatedTimeToReleaseAndAcquireTrigger
public long getEstimatedTimeToReleaseAndAcquireTrigger()
Description copied from interface:JobStoreHow long (in milliseconds) theJobStoreimplementation estimates that it will take to release a trigger and acquire a new one.- Specified by:
getEstimatedTimeToReleaseAndAcquireTriggerin interfaceJobStore
-
setIsClustered
public void setIsClustered(boolean isClustered)
Set whether this instance is part of a cluster.
-
isClustered
public boolean isClustered()
Get whether this instance is part of a cluster.
- Specified by:
isClusteredin interfaceJobStore
-
getClusterCheckinInterval
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.
-
setClusterCheckinInterval
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.
-
getMaxMisfiresToHandleAtATime
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.
-
setMaxMisfiresToHandleAtATime
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.
-
getDbRetryInterval
public long getDbRetryInterval()
- Returns:
- Returns the dbRetryInterval.
-
setDbRetryInterval
public void setDbRetryInterval(long dbRetryInterval)
- Parameters:
dbRetryInterval- The dbRetryInterval to set.
-
setUseDBLocks
public void setUseDBLocks(boolean useDBLocks)
Set whether this instance should use database-based thread synchronization.
-
getUseDBLocks
public boolean getUseDBLocks()
Get whether this instance should use database-based thread synchronization.
-
isLockOnInsert
public boolean isLockOnInsert()
-
setLockOnInsert
public void setLockOnInsert(boolean lockOnInsert)
Whether or not to obtain locks when inserting new jobs/triggers.Defaults to
true, which is safest. Some databases (such as MS SQLServer) seem to require this to avoid deadlocks under high load, while others seem to do fine without. Settings this to false means isolation guarantees between job scheduling and trigger acquisition are entirely enforced by the database. Depending on the database and it's configuration this may cause unusual scheduling behaviors.Setting this property to
falsewill provide a significant performance increase during the addition of new jobs and triggers.- Parameters:
lockOnInsert- whether locking should be used when inserting new jobs/triggers
-
getMisfireThreshold
public long getMisfireThreshold()
-
setMisfireThreshold
public 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.- Parameters:
misfireThreshold- the misfire threshold to use, in millis
-
isDontSetAutoCommitFalse
public boolean isDontSetAutoCommitFalse()
-
setDontSetAutoCommitFalse
public void setDontSetAutoCommitFalse(boolean b)
Don't call set autocommit(false) on connections obtained from the DataSource. This can be helpful in a few situations, such as if you have a driver that complains if it is called when it is already off.- Parameters:
b- whether or not autocommit should be set to false on db connections
-
isTxIsolationLevelSerializable
public boolean isTxIsolationLevelSerializable()
-
setTxIsolationLevelSerializable
public void setTxIsolationLevelSerializable(boolean b)
Set the transaction isolation level of DB connections to sequential.- Parameters:
b- whether isolation level should be set to sequential.
-
isAcquireTriggersWithinLock
public 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). This is the behavior prior to Quartz 1.6.3, but is considered unnecessary for most databases (due to the nature of the SQL update that is performed), and therefore a superfluous performance hit.
-
setAcquireTriggersWithinLock
public 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. This is the behavior prior to Quartz 1.6.3, but is considered unnecessary for most databases, and therefore a superfluous performance hit. However, if batch acquisition is used, it is important for this behavior to be used for all dbs.
-
setDriverDelegateClass
public void setDriverDelegateClass(java.lang.String delegateClassName) throws InvalidConfigurationExceptionSet the JDBC driver delegate class.
- Parameters:
delegateClassName- the delegate class name- Throws:
InvalidConfigurationException
-
getDriverDelegateClass
public java.lang.String getDriverDelegateClass()
Get the JDBC driver delegate class name.
- Returns:
- the delegate class name
-
setDriverDelegateInitString
public void setDriverDelegateInitString(java.lang.String delegateInitString) throws InvalidConfigurationExceptionSet the JDBC driver delegate's initialization string.
- Parameters:
delegateInitString- the delegate init string- Throws:
InvalidConfigurationException
-
getDriverDelegateInitString
public java.lang.String getDriverDelegateInitString()
Get the JDBC driver delegate's initialization string.
- Returns:
- the delegate init string
-
getSelectWithLockSQL
public java.lang.String getSelectWithLockSQL()
-
setSelectWithLockSQL
public void setSelectWithLockSQL(java.lang.String string)
set the SQL statement to use to select and lock a row in the "locks" table.
- See Also:
StdRowLockSemaphore
-
getClassLoadHelper
protected ClassLoadHelper getClassLoadHelper()
-
getMakeThreadsDaemons
public boolean getMakeThreadsDaemons()
Get whether the threads spawned by this JobStore should be marked as daemon. Possible threads include theMisfireHandlerand theClusterManager.- See Also:
Thread.setDaemon(boolean)
-
setMakeThreadsDaemons
public void setMakeThreadsDaemons(boolean makeThreadsDaemons)
Set whether the threads spawned by this JobStore should be marked as daemon. Possible threads include theMisfireHandlerand theClusterManager.- See Also:
Thread.setDaemon(boolean)
-
isThreadsInheritInitializersClassLoadContext
public boolean isThreadsInheritInitializersClassLoadContext()
Get whether to set the class load context of spawned threads to that of the initializing thread.
-
setThreadsInheritInitializersClassLoadContext
public void setThreadsInheritInitializersClassLoadContext(boolean threadsInheritInitializersClassLoadContext)
Set whether to set the class load context of spawned threads to that of the initializing thread.
-
getDoubleCheckLockMisfireHandler
public boolean getDoubleCheckLockMisfireHandler()
Get whether to check to see if there are Triggers that have misfired before actually acquiring the lock to recover them. This should be set to false if the majority of the time, there are misfired Triggers.
-
setDoubleCheckLockMisfireHandler
public 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. This should be set to false if the majority of the time, there are misfired Triggers.
-
getAcquireRetryDelay
public long getAcquireRetryDelay(int failureCount)
Description copied from interface:JobStoreGet the amount of time (in ms) to wait when accessing this job store repeatedly fails. Called by the executor thread(s) when calls toJobStore.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.- Specified by:
getAcquireRetryDelayin interfaceJobStore- Parameters:
failureCount- the number of successive failures seen so far- Returns:
- the time (in milliseconds) to wait before trying again
-
getLog
protected org.slf4j.Logger getLog()
-
initialize
public void initialize(ClassLoadHelper loadHelper, SchedulerSignaler signaler) throws SchedulerConfigException
Called by the QuartzScheduler before the
JobStoreis used, in order to give it a chance to initialize.- Specified by:
initializein interfaceJobStore- Throws:
SchedulerConfigException
-
schedulerStarted
public void schedulerStarted() throws SchedulerExceptionDescription copied from interface:JobStoreCalled by the QuartzScheduler to inform theJobStorethat the scheduler has started.- Specified by:
schedulerStartedin interfaceJobStore- Throws:
SchedulerException- See Also:
JobStore.schedulerStarted()
-
schedulerPaused
public void schedulerPaused()
Description copied from interface:JobStoreCalled by the QuartzScheduler to inform theJobStorethat the scheduler has been paused.- Specified by:
schedulerPausedin interfaceJobStore
-
schedulerResumed
public void schedulerResumed()
Description copied from interface:JobStoreCalled by the QuartzScheduler to inform theJobStorethat the scheduler has resumed after being paused.- Specified by:
schedulerResumedin interfaceJobStore
-
shutdown
public void shutdown()
Called by the QuartzScheduler to inform the
JobStorethat it should free up all of it's resources because the scheduler is shutting down.
-
supportsPersistence
public boolean supportsPersistence()
- Specified by:
supportsPersistencein interfaceJobStore
-
getNonManagedTXConnection
protected abstract java.sql.Connection getNonManagedTXConnection() throws JobPersistenceException- Throws:
JobPersistenceException
-
getAttributeRestoringConnection
protected java.sql.Connection getAttributeRestoringConnection(java.sql.Connection conn)
Wrap the givenConnectionin a Proxy such that attributes that might be set will be restored before the connection is closed (and potentially restored to a pool).
-
getConnection
protected java.sql.Connection getConnection() throws JobPersistenceException- Throws:
JobPersistenceException
-
releaseLock
protected void releaseLock(java.lang.String lockName, boolean doIt)
-
recoverJobs
protected void recoverJobs() throws JobPersistenceExceptionRecover any failed or misfired jobs and clean up the data store as appropriate.- Throws:
JobPersistenceException- if jobs could not be recovered
-
recoverJobs
protected void recoverJobs(java.sql.Connection conn) throws JobPersistenceExceptionWill recover any failed or misfired jobs and clean up the data store as appropriate.
- Throws:
JobPersistenceException- if jobs could not be recovered
-
getMisfireTime
protected long getMisfireTime()
-
recoverMisfiredJobs
protected JobStoreSupport.RecoverMisfiredJobsResult recoverMisfiredJobs(java.sql.Connection conn, boolean recovering) throws JobPersistenceException, java.sql.SQLException
- Throws:
JobPersistenceExceptionjava.sql.SQLException
-
updateMisfiredTrigger
protected boolean updateMisfiredTrigger(java.sql.Connection conn, TriggerKey triggerKey, java.lang.String newStateIfNotComplete, boolean forceState) throws JobPersistenceException- Throws:
JobPersistenceException
-
storeJobAndTrigger
public void storeJobAndTrigger(JobDetail newJob, OperableTrigger newTrigger) throws JobPersistenceException
- Specified by:
storeJobAndTriggerin interfaceJobStore- Parameters:
newJob- TheJobDetailto be stored.newTrigger- TheTriggerto be stored.- Throws:
ObjectAlreadyExistsException- if aJobwith the same name/group already exists.ObjectAlreadyExistsException- if aJobwith the same name/group already exists.JobPersistenceException
-
storeJob
public void storeJob(JobDetail newJob, boolean replaceExisting) throws JobPersistenceException
Store the given
.JobDetail- Specified by:
storeJobin interfaceJobStore- 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.ObjectAlreadyExistsException- if aJobwith the same name/group already exists, and replaceExisting is set to false.JobPersistenceException
-
storeJob
protected void storeJob(java.sql.Connection conn, JobDetail newJob, boolean replaceExisting) throws JobPersistenceExceptionInsert or update a job.
- Throws:
JobPersistenceException
-
jobExists
protected boolean jobExists(java.sql.Connection conn, JobKey jobKey) throws JobPersistenceExceptionCheck existence of a given job.
- Throws:
JobPersistenceException
-
storeTrigger
public void storeTrigger(OperableTrigger newTrigger, boolean replaceExisting) throws JobPersistenceException
Store the given
.Trigger- Specified by:
storeTriggerin interfaceJobStore- 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.ObjectAlreadyExistsException- if aTriggerwith the same name/group already exists, and replaceExisting is set to false.JobPersistenceException- See Also:
JobStore.pauseTriggers(org.quartz.impl.matchers.GroupMatcher)
-
storeTrigger
protected void storeTrigger(java.sql.Connection conn, OperableTrigger newTrigger, JobDetail job, boolean replaceExisting, java.lang.String state, boolean forceState, boolean recovering) throws JobPersistenceExceptionInsert or update a trigger.
- Throws:
JobPersistenceException
-
triggerExists
protected boolean triggerExists(java.sql.Connection conn, TriggerKey key) throws JobPersistenceExceptionCheck existence of a given trigger.
- Throws:
JobPersistenceException
-
removeJob
public boolean removeJob(JobKey jobKey) throws JobPersistenceException
Remove (delete) the
with the given name, 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.- Specified by:
removeJobin interfaceJobStore- Returns:
trueif aJobwith the given name and group was found and removed from the store.- Throws:
JobPersistenceException
-
removeJob
protected boolean removeJob(java.sql.Connection conn, JobKey jobKey) throws JobPersistenceException- Throws:
JobPersistenceException
-
removeJobs
public boolean removeJobs(java.util.List<JobKey> jobKeys) throws JobPersistenceException
- Specified by:
removeJobsin interfaceJobStore- Throws:
JobPersistenceException
-
removeTriggers
public boolean removeTriggers(java.util.List<TriggerKey> triggerKeys) throws JobPersistenceException
- Specified by:
removeTriggersin interfaceJobStore- Throws:
JobPersistenceException
-
storeJobsAndTriggers
public void storeJobsAndTriggers(java.util.Map<JobDetail,java.util.Set<? extends Trigger>> triggersAndJobs, boolean replace) throws JobPersistenceException
- Specified by:
storeJobsAndTriggersin interfaceJobStore- Throws:
JobPersistenceException
-
retrieveJob
public JobDetail retrieveJob(JobKey jobKey) throws JobPersistenceException
- Specified by:
retrieveJobin interfaceJobStore- Returns:
- The desired
Job, or null if there is no match. - Throws:
JobPersistenceException
-
retrieveJob
protected JobDetail retrieveJob(java.sql.Connection conn, JobKey key) throws JobPersistenceException
- Throws:
JobPersistenceException
-
removeTrigger
public boolean removeTrigger(TriggerKey triggerKey) throws JobPersistenceException
Remove (delete) the
with the given name.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.- Specified by:
removeTriggerin interfaceJobStore- Returns:
trueif aTriggerwith the given name and group was found and removed from the store.- Throws:
JobPersistenceException
-
removeTrigger
protected boolean removeTrigger(java.sql.Connection conn, TriggerKey key) throws JobPersistenceException- Throws:
JobPersistenceException
-
replaceTrigger
public boolean replaceTrigger(TriggerKey triggerKey, OperableTrigger newTrigger) throws JobPersistenceException
Description copied from interface:JobStoreRemove (delete) thewith the given key, and store the new given one - which must be associated with the same job.Trigger- Specified by:
replaceTriggerin interfaceJobStorenewTrigger- The newTriggerto be stored.- Returns:
trueif aTriggerwith the given name and group was found and removed from the store.- Throws:
JobPersistenceException- See Also:
JobStore.replaceTrigger(TriggerKey, OperableTrigger)
-
replaceTrigger
protected boolean replaceTrigger(java.sql.Connection conn, TriggerKey key, OperableTrigger newTrigger) throws JobPersistenceException- Throws:
JobPersistenceException
-
retrieveTrigger
public OperableTrigger retrieveTrigger(TriggerKey triggerKey) throws JobPersistenceException
Retrieve the given
.Trigger- Specified by:
retrieveTriggerin interfaceJobStore- Returns:
- The desired
Trigger, or null if there is no match. - Throws:
JobPersistenceException
-
retrieveTrigger
protected OperableTrigger retrieveTrigger(java.sql.Connection conn, TriggerKey key) throws JobPersistenceException
- Throws:
JobPersistenceException
-
getTriggerState
public Trigger.TriggerState getTriggerState(TriggerKey triggerKey) throws JobPersistenceException
Get the current state of the identified
.Trigger- Specified by:
getTriggerStatein interfaceJobStore- Throws:
JobPersistenceException- See Also:
Trigger.TriggerState.NORMAL,Trigger.TriggerState.PAUSED,Trigger.TriggerState.COMPLETE,Trigger.TriggerState.ERROR,Trigger.TriggerState.NONE
-
getTriggerState
public Trigger.TriggerState getTriggerState(java.sql.Connection conn, TriggerKey key) throws JobPersistenceException
- Throws:
JobPersistenceException
-
resetTriggerFromErrorState
public 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.
- Specified by:
resetTriggerFromErrorStatein interfaceJobStore- Throws:
JobPersistenceException
-
storeCalendar
public void storeCalendar(java.lang.String calName, Calendar calendar, boolean replaceExisting, boolean updateTriggers) throws JobPersistenceExceptionStore the given
.Calendar- Specified by:
storeCalendarin interfaceJobStore- Parameters:
calName- The name of the calendar.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
-
storeCalendar
protected void storeCalendar(java.sql.Connection conn, java.lang.String calName, Calendar calendar, boolean replaceExisting, boolean updateTriggers) throws JobPersistenceException- Throws:
JobPersistenceException
-
calendarExists
protected boolean calendarExists(java.sql.Connection conn, java.lang.String calName) throws JobPersistenceException- Throws:
JobPersistenceException
-
removeCalendar
public boolean removeCalendar(java.lang.String calName) throws JobPersistenceExceptionRemove (delete) the
with the given name.CalendarIf removal of the
*Calendarwould result inTriggers pointing to nonexistent calendars, then aJobPersistenceExceptionwill be thrown.- Specified by:
removeCalendarin interfaceJobStore- Parameters:
calName- The name of theCalendarto be removed.- Returns:
trueif aCalendarwith the given name was found and removed from the store.- Throws:
JobPersistenceException
-
removeCalendar
protected boolean removeCalendar(java.sql.Connection conn, java.lang.String calName) throws JobPersistenceException- Throws:
JobPersistenceException
-
retrieveCalendar
public Calendar retrieveCalendar(java.lang.String calName) throws JobPersistenceException
Retrieve the given
.Trigger- Specified by:
retrieveCalendarin interfaceJobStore- Parameters:
calName- The name of theCalendarto be retrieved.- Returns:
- The desired
Calendar, or null if there is no match. - Throws:
JobPersistenceException
-
retrieveCalendar
protected Calendar retrieveCalendar(java.sql.Connection conn, java.lang.String calName) throws JobPersistenceException
- Throws:
JobPersistenceException
-
getNumberOfJobs
public int getNumberOfJobs() throws JobPersistenceExceptionGet the number of
s that are stored in theJobJobStore.- Specified by:
getNumberOfJobsin interfaceJobStore- Throws:
JobPersistenceException
-
getNumberOfJobs
protected int getNumberOfJobs(java.sql.Connection conn) throws JobPersistenceException- Throws:
JobPersistenceException
-
getNumberOfTriggers
public int getNumberOfTriggers() throws JobPersistenceExceptionGet the number of
s that are stored in theTriggerJobsStore.- Specified by:
getNumberOfTriggersin interfaceJobStore- Throws:
JobPersistenceException
-
getNumberOfTriggers
protected int getNumberOfTriggers(java.sql.Connection conn) throws JobPersistenceException- Throws:
JobPersistenceException
-
getNumberOfCalendars
public int getNumberOfCalendars() throws JobPersistenceExceptionGet the number of
s that are stored in theCalendarJobsStore.- Specified by:
getNumberOfCalendarsin interfaceJobStore- Throws:
JobPersistenceException
-
getNumberOfCalendars
protected int getNumberOfCalendars(java.sql.Connection conn) throws JobPersistenceException- Throws:
JobPersistenceException
-
getJobKeys
public java.util.Set<JobKey> getJobKeys(GroupMatcher<JobKey> matcher) throws JobPersistenceException
Get the names of all of the
s that matcher the given groupMatcher.JobIf there are no jobs in the given group name, the result should be an empty Set
- Specified by:
getJobKeysin interfaceJobStore- Throws:
JobPersistenceException
-
getJobNames
protected java.util.Set<JobKey> getJobNames(java.sql.Connection conn, GroupMatcher<JobKey> matcher) throws JobPersistenceException
- Throws:
JobPersistenceException
-
checkExists
public boolean checkExists(JobKey jobKey) throws JobPersistenceException
Determine whether aJobwith the given identifier already exists within the scheduler.- Specified by:
checkExistsin interfaceJobStore- Parameters:
jobKey- the identifier to check for- Returns:
- true if a Job exists with the given identifier
- Throws:
JobPersistenceException
-
checkExists
protected boolean checkExists(java.sql.Connection conn, JobKey jobKey) throws JobPersistenceException- Throws:
JobPersistenceException
-
checkExists
public boolean checkExists(TriggerKey triggerKey) throws JobPersistenceException
Determine whether aTriggerwith the given identifier already exists within the scheduler.- Specified by:
checkExistsin interfaceJobStore- Parameters:
triggerKey- the identifier to check for- Returns:
- true if a Trigger exists with the given identifier
- Throws:
JobPersistenceException
-
checkExists
protected boolean checkExists(java.sql.Connection conn, TriggerKey triggerKey) throws JobPersistenceException- Throws:
JobPersistenceException
-
clearAllSchedulingData
public void clearAllSchedulingData() throws JobPersistenceException- Specified by:
clearAllSchedulingDatain interfaceJobStore- Throws:
JobPersistenceException
-
clearAllSchedulingData
protected void clearAllSchedulingData(java.sql.Connection conn) throws JobPersistenceException- Throws:
JobPersistenceException
-
getTriggerKeys
public java.util.Set<TriggerKey> getTriggerKeys(GroupMatcher<TriggerKey> matcher) throws JobPersistenceException
Get the names of all of the
s that match the given group Matcher.TriggerIf there are no triggers in the given group name, the result should be a an empty Set (not
null).- Specified by:
getTriggerKeysin interfaceJobStore- Throws:
JobPersistenceException
-
getTriggerNames
protected java.util.Set<TriggerKey> getTriggerNames(java.sql.Connection conn, GroupMatcher<TriggerKey> matcher) throws JobPersistenceException
- Throws:
JobPersistenceException
-
getJobGroupNames
public java.util.List<java.lang.String> getJobGroupNames() throws JobPersistenceExceptionGet the names of all of the
groups.JobIf there are no known group names, the result should be a zero-length array (not
null).- Specified by:
getJobGroupNamesin interfaceJobStore- Throws:
JobPersistenceException
-
getJobGroupNames
protected java.util.List<java.lang.String> getJobGroupNames(java.sql.Connection conn) throws JobPersistenceException- Throws:
JobPersistenceException
-
getTriggerGroupNames
public java.util.List<java.lang.String> getTriggerGroupNames() throws JobPersistenceExceptionGet the names of all of the
groups.TriggerIf there are no known group names, the result should be a zero-length array (not
null).- Specified by:
getTriggerGroupNamesin interfaceJobStore- Throws:
JobPersistenceException
-
getTriggerGroupNames
protected java.util.List<java.lang.String> getTriggerGroupNames(java.sql.Connection conn) throws JobPersistenceException- Throws:
JobPersistenceException
-
getCalendarNames
public java.util.List<java.lang.String> getCalendarNames() throws JobPersistenceExceptionGet the names of all of the
s in theCalendarJobStore.If there are no Calendars in the given group name, the result should be a zero-length array (not
null).- Specified by:
getCalendarNamesin interfaceJobStore- Throws:
JobPersistenceException
-
getCalendarNames
protected java.util.List<java.lang.String> getCalendarNames(java.sql.Connection conn) throws JobPersistenceException- Throws:
JobPersistenceException
-
getTriggersForJob
public 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.
- Specified by:
getTriggersForJobin interfaceJobStore- Throws:
JobPersistenceException
-
getTriggersForJob
protected java.util.List<OperableTrigger> getTriggersForJob(java.sql.Connection conn, JobKey key) throws JobPersistenceException
- Throws:
JobPersistenceException
-
pauseTrigger
public void pauseTrigger(TriggerKey triggerKey) throws JobPersistenceException
Pause the
with the given name.Trigger- Specified by:
pauseTriggerin interfaceJobStore- Throws:
JobPersistenceException- See Also:
resumeTrigger(TriggerKey)
-
pauseTrigger
public void pauseTrigger(java.sql.Connection conn, TriggerKey triggerKey) throws JobPersistenceExceptionPause the
with the given name.Trigger- Throws:
JobPersistenceException- See Also:
resumeTrigger(Connection, TriggerKey)
-
pauseJob
public void pauseJob(JobKey jobKey) throws JobPersistenceException
Pause the
with the given name - by pausing all of its currentJobTriggers.- Specified by:
pauseJobin interfaceJobStore- Throws:
JobPersistenceException- See Also:
resumeJob(JobKey)
-
pauseJobs
public java.util.Set<java.lang.String> pauseJobs(GroupMatcher<JobKey> matcher) throws JobPersistenceException
Pause all of the
matching the given groupMatcher - by pausing all of theirJobsTriggers.- Specified by:
pauseJobsin interfaceJobStore- Throws:
JobPersistenceException- See Also:
resumeJobs(org.quartz.impl.matchers.GroupMatcher)
-
checkBlockedState
protected java.lang.String checkBlockedState(java.sql.Connection conn, JobKey jobKey, java.lang.String currentState) throws JobPersistenceExceptionDetermines if a Trigger for the given job should be blocked. State can only transition to STATE_PAUSED_BLOCKED/BLOCKED from PAUSED/STATE_WAITING respectively.- Returns:
- STATE_PAUSED_BLOCKED, BLOCKED, or the currentState.
- Throws:
JobPersistenceException
-
resumeTrigger
public void resumeTrigger(TriggerKey triggerKey) throws JobPersistenceException
Resume (un-pause) the
with the given name.TriggerIf the
Triggermissed one or more fire-times, then theTrigger's misfire instruction will be applied.- Specified by:
resumeTriggerin interfaceJobStore- Throws:
JobPersistenceException- See Also:
pauseTrigger(TriggerKey)
-
resumeTrigger
public void resumeTrigger(java.sql.Connection conn, TriggerKey key) throws JobPersistenceExceptionResume (un-pause) the
with the given name.TriggerIf the
Triggermissed one or more fire-times, then theTrigger's misfire instruction will be applied.- Throws:
JobPersistenceException- See Also:
pauseTrigger(Connection, TriggerKey)
-
resumeJob
public void resumeJob(JobKey jobKey) throws JobPersistenceException
Resume (un-pause) the
with the given name.JobIf any of the
Job'sTriggers missed one or more fire-times, then theTrigger's misfire instruction will be applied.- Specified by:
resumeJobin interfaceJobStore- Throws:
JobPersistenceException- See Also:
pauseJob(JobKey)
-
resumeJobs
public java.util.Set<java.lang.String> resumeJobs(GroupMatcher<JobKey> matcher) throws JobPersistenceException
Resume (un-pause) all of the
in the given group.JobsIf any of the
Jobs hadTriggers that missed one or more fire-times, then theTrigger's misfire instruction will be applied.- Specified by:
resumeJobsin interfaceJobStore- Throws:
JobPersistenceException- See Also:
pauseJobs(org.quartz.impl.matchers.GroupMatcher)
-
pauseTriggers
public java.util.Set<java.lang.String> pauseTriggers(GroupMatcher<TriggerKey> matcher) throws JobPersistenceException
Pause all of the
matching the given groupMatcher.Triggers- Specified by:
pauseTriggersin interfaceJobStore- Throws:
JobPersistenceException- See Also:
resumeTriggerGroup(java.sql.Connection, org.quartz.impl.matchers.GroupMatcher)
-
pauseTriggerGroup
public java.util.Set<java.lang.String> pauseTriggerGroup(java.sql.Connection conn, GroupMatcher<TriggerKey> matcher) throws JobPersistenceExceptionPause all of the
matching the given groupMatcher.Triggers
-
getPausedTriggerGroups
public java.util.Set<java.lang.String> getPausedTriggerGroups() throws JobPersistenceException- Specified by:
getPausedTriggerGroupsin interfaceJobStore- Throws:
JobPersistenceException
-
getPausedTriggerGroups
public java.util.Set<java.lang.String> getPausedTriggerGroups(java.sql.Connection conn) throws JobPersistenceExceptionPause all of the
in the given group.Triggers- Throws:
JobPersistenceException- See Also:
resumeTriggers(org.quartz.impl.matchers.GroupMatcher)
-
resumeTriggers
public java.util.Set<java.lang.String> resumeTriggers(GroupMatcher<TriggerKey> matcher) throws JobPersistenceException
Resume (un-pause) all of the
matching the given groupMatcher.TriggersIf any
Triggermissed one or more fire-times, then theTrigger's misfire instruction will be applied.- Specified by:
resumeTriggersin interfaceJobStore- Throws:
JobPersistenceException- See Also:
pauseTriggers(org.quartz.impl.matchers.GroupMatcher)
-
resumeTriggerGroup
public java.util.Set<java.lang.String> resumeTriggerGroup(java.sql.Connection conn, GroupMatcher<TriggerKey> matcher) throws JobPersistenceExceptionResume (un-pause) all of the
matching the given groupMatcher.TriggersIf any
Triggermissed one or more fire-times, then theTrigger's misfire instruction will be applied.- Throws:
JobPersistenceException- See Also:
pauseTriggers(org.quartz.impl.matchers.GroupMatcher)
-
pauseAll
public void pauseAll() throws JobPersistenceExceptionPause all triggers - equivalent of calling
pauseTriggerGroup(group)on every group.When
resumeAll()is called (to un-pause), trigger misfire instructions WILL be applied.- Specified by:
pauseAllin interfaceJobStore- Throws:
JobPersistenceException- See Also:
resumeAll(),pauseTriggerGroup(java.sql.Connection, org.quartz.impl.matchers.GroupMatcher)
-
pauseAll
public void pauseAll(java.sql.Connection conn) throws JobPersistenceExceptionPause all triggers - equivalent of calling
pauseTriggerGroup(group)on every group.When
resumeAll()is called (to un-pause), trigger misfire instructions WILL be applied.
-
resumeAll
public void resumeAll() throws JobPersistenceExceptionResume (un-pause) all triggers - equivalent of calling
resumeTriggerGroup(group)on every group.If any
Triggermissed one or more fire-times, then theTrigger's misfire instruction will be applied.- Specified by:
resumeAllin interfaceJobStore- Throws:
JobPersistenceException- See Also:
pauseAll()
-
resumeAll
public void resumeAll(java.sql.Connection conn) throws JobPersistenceExceptionprotectedResume (un-pause) all triggers - equivalent of calling
resumeTriggerGroup(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(Connection)
-
getFiredTriggerRecordId
protected java.lang.String getFiredTriggerRecordId()
-
acquireNextTriggers
public java.util.List<OperableTrigger> acquireNextTriggers(long noLaterThan, int maxCount, long timeWindow) throws JobPersistenceException
Get a handle to the next N triggers to be fired, and mark them as 'reserved' by the calling scheduler.
- Specified by:
acquireNextTriggersin interfaceJobStore- 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)
-
acquireNextTrigger
protected java.util.List<OperableTrigger> acquireNextTrigger(java.sql.Connection conn, long noLaterThan, int maxCount, long timeWindow) throws JobPersistenceException
- Throws:
JobPersistenceException
-
releaseAcquiredTrigger
public void releaseAcquiredTrigger(OperableTrigger trigger)
Inform the
JobStorethat the scheduler no longer plans to fire the givenTrigger, that it had previously acquired (reserved).- Specified by:
releaseAcquiredTriggerin interfaceJobStore
-
releaseAcquiredTrigger
protected void releaseAcquiredTrigger(java.sql.Connection conn, OperableTrigger trigger) throws JobPersistenceException- Throws:
JobPersistenceException
-
triggersFired
public java.util.List<TriggerFiredResult> triggersFired(java.util.List<OperableTrigger> triggers) throws JobPersistenceException
Inform the
JobStorethat the scheduler is now firing the givenTrigger(executing its associatedJob), that it had previously acquired (reserved).- Specified by:
triggersFiredin interfaceJobStore- Returns:
- null if the trigger or its job or calendar no longer exist, or if the trigger was not successfully put into the 'executing' state.
- Throws:
JobPersistenceException
-
triggerFired
protected TriggerFiredBundle triggerFired(java.sql.Connection conn, OperableTrigger trigger) throws JobPersistenceException
- Throws:
JobPersistenceException
-
triggeredJobComplete
public void triggeredJobComplete(OperableTrigger trigger, JobDetail jobDetail, Trigger.CompletedExecutionInstruction triggerInstCode)
Inform the
JobStorethat the scheduler has completed the firing of the givenTrigger(and the execution its associatedJob), and that thein the givenJobDataMapJobDetailshould be updated if theJobis stateful.- Specified by:
triggeredJobCompletein interfaceJobStore
-
triggeredJobComplete
protected void triggeredJobComplete(java.sql.Connection conn, OperableTrigger trigger, JobDetail jobDetail, Trigger.CompletedExecutionInstruction triggerInstCode) throws JobPersistenceException- Throws:
JobPersistenceException
-
getDelegate
protected DriverDelegate getDelegate() throws NoSuchDelegateException
Get the driver delegate for DB operations.
- Throws:
NoSuchDelegateException
-
getLockHandler
protected Semaphore getLockHandler()
-
setLockHandler
public void setLockHandler(Semaphore lockHandler)
-
doRecoverMisfires
protected JobStoreSupport.RecoverMisfiredJobsResult doRecoverMisfires() throws JobPersistenceException
- Throws:
JobPersistenceException
-
signalSchedulingChangeOnTxCompletion
protected void signalSchedulingChangeOnTxCompletion(long candidateNewNextFireTime)
-
clearAndGetSignalSchedulingChangeOnTxCompletion
protected java.lang.Long clearAndGetSignalSchedulingChangeOnTxCompletion()
-
signalSchedulingChangeImmediately
protected void signalSchedulingChangeImmediately(long candidateNewNextFireTime)
-
doCheckin
protected boolean doCheckin() throws JobPersistenceException- Throws:
JobPersistenceException
-
findFailedInstances
protected java.util.List<SchedulerStateRecord> findFailedInstances(java.sql.Connection conn) throws JobPersistenceException
Get a list of all scheduler instances in the cluster that may have failed. This includes this scheduler if it is checking in for the first time.- Throws:
JobPersistenceException
-
calcFailedIfAfter
protected long calcFailedIfAfter(SchedulerStateRecord rec)
-
clusterCheckIn
protected java.util.List<SchedulerStateRecord> clusterCheckIn(java.sql.Connection conn) throws JobPersistenceException
- Throws:
JobPersistenceException
-
clusterRecover
protected void clusterRecover(java.sql.Connection conn, java.util.List<SchedulerStateRecord> failedInstances) throws JobPersistenceException- Throws:
JobPersistenceException
-
logWarnIfNonZero
protected void logWarnIfNonZero(int val, java.lang.String warning)
-
cleanupConnection
protected void cleanupConnection(java.sql.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.
- See Also:
closeConnection(Connection)
-
closeConnection
protected void closeConnection(java.sql.Connection conn)
Closes the suppliedConnection.Ignores a
null Connection. Any exception thrown trying to close theConnectionis logged and ignored.- Parameters:
conn- TheConnectionto close (Optional).
-
rollbackConnection
protected void rollbackConnection(java.sql.Connection conn)
Rollback the supplied connection.Logs any SQLException it gets trying to rollback, but will not propagate the exception lest it mask the exception that caused the caller to need to rollback in the first place.
- Parameters:
conn- (Optional)
-
commitConnection
protected void commitConnection(java.sql.Connection conn) throws JobPersistenceExceptionCommit the supplied connection- Parameters:
conn- (Optional)- Throws:
JobPersistenceException- thrown if a SQLException occurs when the connection is committed
-
executeWithoutLock
public <T> T executeWithoutLock(JobStoreSupport.TransactionCallback<T> txCallback) throws JobPersistenceException
Execute the given callback in a transaction. Depending on the JobStore, the surrounding transaction may be assumed to be already present (managed).This method just forwards to executeInLock() with a null lockName.
- Throws:
JobPersistenceException- See Also:
executeInLock(String, TransactionCallback)
-
executeInLock
protected abstract <T> T executeInLock(java.lang.String lockName, JobStoreSupport.TransactionCallback<T> txCallback) throws JobPersistenceExceptionExecute the given callback having acquired the given lock. Depending on the JobStore, the surrounding transaction may be assumed to be already present (managed).- Parameters:
lockName- The name of the lock to acquire, for example "TRIGGER_ACCESS". If null, then no lock is acquired, but the lockCallback is still executed in a transaction.- Throws:
JobPersistenceException
-
retryExecuteInNonManagedTXLock
protected <T> T retryExecuteInNonManagedTXLock(java.lang.String lockName, JobStoreSupport.TransactionCallback<T> txCallback)
-
executeInNonManagedTXLock
protected <T> T executeInNonManagedTXLock(java.lang.String lockName, JobStoreSupport.TransactionCallback<T> txCallback, JobStoreSupport.TransactionValidator<T> txValidator) throws JobPersistenceExceptionExecute the given callback having optionally acquired the given lock. This uses the non-managed transaction connection.- Parameters:
lockName- The name of the lock to acquire, for example "TRIGGER_ACCESS". If null, then no lock is acquired, but the lockCallback is still executed in a non-managed transaction.- Throws:
JobPersistenceException
-
-