org.quartz.impl.jdbcjobstore
Class JobStoreSupport

java.lang.Object
  extended by org.quartz.impl.jdbcjobstore.JobStoreSupport
All Implemented Interfaces:
Constants, JobStore
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
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.
 
Field Summary
protected  java.util.HashMap calendarCache
           
protected  java.lang.Class delegateClass
           
protected  java.lang.String delegateClassName
           
protected  java.lang.String dsName
           
protected  boolean firstCheckIn
           
protected  java.lang.String instanceId
           
protected  java.lang.String instanceName
           
protected  long lastCheckin
           
protected static java.lang.String LOCK_CALENDAR_ACCESS
           
protected static java.lang.String LOCK_JOB_ACCESS
           
protected static java.lang.String LOCK_MISFIRE_ACCESS
           
protected static java.lang.String LOCK_STATE_ACCESS
           
protected static java.lang.String LOCK_TRIGGER_ACCESS
           
protected  int maxToRecoverAtATime
           
protected  java.lang.ThreadLocal<java.lang.Long> sigChangeForTxCompletion
           
protected  java.lang.String tablePrefix
           
protected  boolean useProperties
           
 
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_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 Summary
JobStoreSupport()
           
 
Method Summary
protected  Trigger acquireNextTrigger(java.sql.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(java.sql.Connection conn, java.lang.String calName)
           
 boolean canUseProperties()
           Get whether String-only properties will be handled in JobDataMaps.
protected  java.lang.String checkBlockedState(java.sql.Connection conn, SchedulingContext ctxt, java.lang.String jobName, java.lang.String jobGroupName, java.lang.String currentState)
          Determines if a Trigger for the given job should be blocked.
protected  void cleanupConnection(java.sql.Connection conn)
           Cleanup the given database connection.
protected  void cleanVolatileTriggerAndJobs()
          Removes all volatile data.
protected  void cleanVolatileTriggerAndJobs(java.sql.Connection conn)
           Removes all volatile data.
protected  java.lang.Long clearAndGetSignalSchedulingChangeOnTxCompletion()
           
protected  void closeConnection(java.sql.Connection conn)
          Closes the supplied Connection.
protected  java.util.List clusterCheckIn(java.sql.Connection conn)
           
protected  void clusterRecover(java.sql.Connection conn, java.util.List failedInstances)
           
protected  void commitConnection(java.sql.Connection conn)
          Commit the supplied connection
protected  boolean doCheckin()
           
protected  JobStoreSupport.RecoverMisfiredJobsResult doRecoverMisfires()
           
protected abstract  java.lang.Object executeInLock(java.lang.String lockName, JobStoreSupport.TransactionCallback txCallback)
          Execute the given callback having aquired the given lock.
protected  void executeInLock(java.lang.String lockName, JobStoreSupport.VoidTransactionCallback txCallback)
          Execute the given callback having aquired the given lock.
protected  java.lang.Object executeInNonManagedTXLock(java.lang.String lockName, JobStoreSupport.TransactionCallback txCallback)
          Execute the given callback having optionally aquired the given lock.
protected  void executeInNonManagedTXLock(java.lang.String lockName, JobStoreSupport.VoidTransactionCallback txCallback)
          Execute the given callback having optionally aquired the given lock.
 java.lang.Object executeWithoutLock(JobStoreSupport.TransactionCallback txCallback)
          Execute the given callback in a transaction.
protected  java.util.List findFailedInstances(java.sql.Connection conn)
          Get a list of all scheduler instances in the cluster that may have failed.
protected  java.sql.Connection getAttributeRestoringConnection(java.sql.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  java.lang.String[] getCalendarNames(java.sql.Connection conn, SchedulingContext ctxt)
           
 java.lang.String[] getCalendarNames(SchedulingContext ctxt)
           Get the names of all of the Calendar 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  java.sql.Connection getConnection()
           
 java.lang.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.
 java.lang.String getDriverDelegateClass()
           Get the JDBC driver delegate class name.
 long getEstimatedTimeToReleaseAndAcquireTrigger()
          How long (in milliseconds) the JobStore implementation estimates that it will take to release a trigger and acquire a new one.
protected  java.lang.String getFiredTriggerRecordId()
           
 java.lang.String getInstanceId()
           Get the instance Id of the Scheduler (must be unique within a cluster).
 java.lang.String getInstanceName()
          Get the instance name of the Scheduler (must be unique within this server instance).
protected  java.lang.String[] getJobGroupNames(java.sql.Connection conn, SchedulingContext ctxt)
           
 java.lang.String[] getJobGroupNames(SchedulingContext ctxt)
           Get the names of all of the Job groups.
protected  java.lang.String[] getJobNames(java.sql.Connection conn, SchedulingContext ctxt, java.lang.String groupName)
           
 java.lang.String[] getJobNames(SchedulingContext ctxt, java.lang.String groupName)
           Get the names of all of the Job s that have the given group name.
protected  Semaphore getLockHandler()
           
protected  org.slf4j.Logger 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  java.sql.Connection getNonManagedTXConnection()
           
protected  int getNumberOfCalendars(java.sql.Connection conn, SchedulingContext ctxt)
           
 int getNumberOfCalendars(SchedulingContext ctxt)
           Get the number of Calendar s that are stored in the JobsStore.
protected  int getNumberOfJobs(java.sql.Connection conn, SchedulingContext ctxt)
           
 int getNumberOfJobs(SchedulingContext ctxt)
           Get the number of Job s that are stored in the JobStore.
protected  int getNumberOfTriggers(java.sql.Connection conn, SchedulingContext ctxt)
           
 int getNumberOfTriggers(SchedulingContext ctxt)
           Get the number of Trigger s that are stored in the JobsStore.
 java.util.Set getPausedTriggerGroups(java.sql.Connection conn, SchedulingContext ctxt)
           Pause all of the Triggers in the given group.
 java.util.Set getPausedTriggerGroups(SchedulingContext ctxt)
           
 java.lang.String getSelectWithLockSQL()
           
 java.lang.String getTablePrefix()
           Get the prefix that should be pre-pended to all table names.
 ThreadExecutor getThreadExecutor()
           
protected  java.lang.String[] getTriggerGroupNames(java.sql.Connection conn, SchedulingContext ctxt)
           
 java.lang.String[] getTriggerGroupNames(SchedulingContext ctxt)
           Get the names of all of the Trigger groups.
protected  java.lang.String[] getTriggerNames(java.sql.Connection conn, SchedulingContext ctxt, java.lang.String groupName)
           
 java.lang.String[] getTriggerNames(SchedulingContext ctxt, java.lang.String groupName)
           Get the names of all of the Trigger s that have the given group name.
protected  Trigger[] getTriggersForJob(java.sql.Connection conn, SchedulingContext ctxt, java.lang.String jobName, java.lang.String groupName)
           
 Trigger[] getTriggersForJob(SchedulingContext ctxt, java.lang.String jobName, java.lang.String groupName)
           Get all of the Triggers that are associated to the given Job.
 int getTriggerState(java.sql.Connection conn, SchedulingContext ctxt, java.lang.String triggerName, java.lang.String groupName)
           
 int getTriggerState(SchedulingContext ctxt, java.lang.String triggerName, java.lang.String groupName)
           Get the current state of the identified Trigger.
 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(java.sql.Connection conn, java.lang.String jobName, java.lang.String groupName)
           Check existence of a given job.
protected  void logWarnIfNonZero(int val, java.lang.String warning)
           
 void pauseAll(java.sql.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, java.lang.String jobName, java.lang.String groupName)
           Pause the Job with the given name - by pausing all of its current Triggers.
 void pauseJobGroup(SchedulingContext ctxt, java.lang.String groupName)
           Pause all of the Jobs in the given group - by pausing all of their Triggers.
 void pauseTrigger(java.sql.Connection conn, SchedulingContext ctxt, java.lang.String triggerName, java.lang.String groupName)
           Pause the Trigger with the given name.
 void pauseTrigger(SchedulingContext ctxt, java.lang.String triggerName, java.lang.String groupName)
           Pause the Trigger with the given name.
 void pauseTriggerGroup(java.sql.Connection conn, SchedulingContext ctxt, java.lang.String groupName)
           Pause all of the Triggers in the given group.
 void pauseTriggerGroup(SchedulingContext ctxt, java.lang.String groupName)
           Pause all of the Triggers in the given group.
protected  void recoverJobs()
          Recover any failed or misfired jobs and clean up the data store as appropriate.
protected  void recoverJobs(java.sql.Connection conn)
           Will recover any failed or misfired jobs and clean up the data store as appropriate.
protected  JobStoreSupport.RecoverMisfiredJobsResult recoverMisfiredJobs(java.sql.Connection conn, boolean recovering)
           
protected  void releaseAcquiredTrigger(java.sql.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(java.sql.Connection conn, java.lang.String lockName, boolean doIt)
           
protected  boolean removeCalendar(java.sql.Connection conn, SchedulingContext ctxt, java.lang.String calName)
           
 boolean removeCalendar(SchedulingContext ctxt, java.lang.String calName)
           Remove (delete) the Calendar with the given name.
protected  boolean removeJob(java.sql.Connection conn, SchedulingContext ctxt, java.lang.String jobName, java.lang.String groupName, boolean activeDeleteSafe)
           
 boolean removeJob(SchedulingContext ctxt, java.lang.String jobName, java.lang.String groupName)
           Remove (delete) the Job with the given name, and any Trigger s that reference it.
protected  boolean removeTrigger(java.sql.Connection conn, SchedulingContext ctxt, java.lang.String triggerName, java.lang.String groupName)
           
 boolean removeTrigger(SchedulingContext ctxt, java.lang.String triggerName, java.lang.String groupName)
           Remove (delete) the Trigger with the given name.
protected  boolean replaceTrigger(java.sql.Connection conn, SchedulingContext ctxt, java.lang.String triggerName, java.lang.String groupName, Trigger newTrigger)
           
 boolean replaceTrigger(SchedulingContext ctxt, java.lang.String triggerName, java.lang.String groupName, Trigger newTrigger)
           Remove (delete) the Trigger with the given name, and store the new given one - which must be associated with the same job.
 void resumeAll(java.sql.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, java.lang.String jobName, java.lang.String groupName)
           Resume (un-pause) the Job with the given name.
 void resumeJobGroup(SchedulingContext ctxt, java.lang.String groupName)
           Resume (un-pause) all of the Jobs in the given group.
 void resumeTrigger(java.sql.Connection conn, SchedulingContext ctxt, java.lang.String triggerName, java.lang.String groupName)
           Resume (un-pause) the Trigger with the given name.
 void resumeTrigger(SchedulingContext ctxt, java.lang.String triggerName, java.lang.String groupName)
           Resume (un-pause) the Trigger with the given name.
 void resumeTriggerGroup(java.sql.Connection conn, SchedulingContext ctxt, java.lang.String groupName)
           Resume (un-pause) all of the Triggers in the given group.
 void resumeTriggerGroup(SchedulingContext ctxt, java.lang.String groupName)
           Resume (un-pause) all of the Triggers in the given group.
protected  Calendar retrieveCalendar(java.sql.Connection conn, SchedulingContext ctxt, java.lang.String calName)
           
 Calendar retrieveCalendar(SchedulingContext ctxt, java.lang.String calName)
           Retrieve the given Trigger.
protected  JobDetail retrieveJob(java.sql.Connection conn, SchedulingContext ctxt, java.lang.String jobName, java.lang.String groupName)
           
 JobDetail retrieveJob(SchedulingContext ctxt, java.lang.String jobName, java.lang.String groupName)
           Retrieve the JobDetail for the given Job.
protected  Trigger retrieveTrigger(java.sql.Connection conn, SchedulingContext ctxt, java.lang.String triggerName, java.lang.String groupName)
           
protected  Trigger retrieveTrigger(java.sql.Connection conn, java.lang.String triggerName, java.lang.String groupName)
           
 Trigger retrieveTrigger(SchedulingContext ctxt, java.lang.String triggerName, java.lang.String groupName)
           Retrieve the given Trigger.
protected  void rollbackConnection(java.sql.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(java.lang.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(java.lang.String delegateClassName)
           Set the JDBC driver delegate class.
 void setInstanceId(java.lang.String instanceId)
           Set the instance Id of the Scheduler (must be unique within a cluster).
 void setInstanceName(java.lang.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(java.lang.String string)
           set the SQL statement to use to select and lock a row in the "locks" table.
 void setTablePrefix(java.lang.String prefix)
           Set the prefix that should be pre-pended to all table names.
 void setThreadExecutor(ThreadExecutor threadExecutor)
           
 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(java.lang.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 signalSchedulingChangeImmediately(long candidateNewNextFireTime)
           
protected  void signalSchedulingChangeOnTxCompletion(long candidateNewNextFireTime)
           
protected  void storeCalendar(java.sql.Connection conn, SchedulingContext ctxt, java.lang.String calName, Calendar calendar, boolean replaceExisting, boolean updateTriggers)
           
 void storeCalendar(SchedulingContext ctxt, java.lang.String calName, Calendar calendar, boolean replaceExisting, boolean updateTriggers)
           Store the given Calendar.
protected  void storeJob(java.sql.Connection conn, SchedulingContext ctxt, JobDetail newJob, boolean replaceExisting)
           Insert or update a job.
 void storeJob(SchedulingContext ctxt, JobDetail newJob, boolean replaceExisting)
           Store the given JobDetail.
 void storeJobAndTrigger(SchedulingContext ctxt, JobDetail newJob, Trigger newTrigger)
           Store the given JobDetail and Trigger.
protected  void storeTrigger(java.sql.Connection conn, SchedulingContext ctxt, Trigger newTrigger, JobDetail job, boolean replaceExisting, java.lang.String state, boolean forceState, boolean recovering)
           Insert or update a trigger.
 void storeTrigger(SchedulingContext ctxt, Trigger newTrigger, boolean replaceExisting)
           Store the given Trigger.
 boolean supportsPersistence()
           
protected  void triggeredJobComplete(java.sql.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 JobDataMap in the given JobDetail should be updated if the Job is stateful.
protected  boolean triggerExists(java.sql.Connection conn, java.lang.String triggerName, java.lang.String groupName)
           Check existence of a given trigger.
protected  TriggerFiredBundle triggerFired(java.sql.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(java.sql.Connection conn, SchedulingContext ctxt, java.lang.String triggerName, java.lang.String groupName, java.lang.String newStateIfNotComplete, boolean forceState)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCK_TRIGGER_ACCESS

protected static final java.lang.String LOCK_TRIGGER_ACCESS
See Also:
Constant Field Values

LOCK_JOB_ACCESS

protected static final java.lang.String LOCK_JOB_ACCESS
See Also:
Constant Field Values

LOCK_CALENDAR_ACCESS

protected static final java.lang.String LOCK_CALENDAR_ACCESS
See Also:
Constant Field Values

LOCK_STATE_ACCESS

protected static final java.lang.String LOCK_STATE_ACCESS
See Also:
Constant Field Values

LOCK_MISFIRE_ACCESS

protected static final java.lang.String LOCK_MISFIRE_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

delegateClass

protected java.lang.Class delegateClass

calendarCache

protected java.util.HashMap calendarCache

maxToRecoverAtATime

protected int maxToRecoverAtATime

sigChangeForTxCompletion

protected java.lang.ThreadLocal<java.lang.Long> sigChangeForTxCompletion

firstCheckIn

protected boolean firstCheckIn

lastCheckin

protected long lastCheckin
Constructor Detail

JobStoreSupport

public JobStoreSupport()
Method Detail

setDataSource

public void setDataSource(java.lang.String dsName)

Set the name of the DataSource that should be used for performing database functions.


getDataSource

public java.lang.String getDataSource()

Get the name of the DataSource that 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:
setInstanceId in interface JobStore

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:
setInstanceName in interface JobStore

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: JobStore
How long (in milliseconds) the JobStore implementation estimates that it will take to release a trigger and acquire a new one.

Specified by:
getEstimatedTimeToReleaseAndAcquireTrigger in interface JobStore

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:
isClustered in interface JobStore

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 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.

Parameters:
lockOnInsert -

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 -

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 helpfull in a few situations, such as if you have a driver that complains if it is called when it is already off.

Parameters:
b -

isTxIsolationLevelSerializable

public boolean isTxIsolationLevelSerializable()

setTxIsolationLevelSerializable

public void setTxIsolationLevelSerializable(boolean b)
Set the transaction isolation level of DB connections to sequential.

Parameters:
b -

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.


setThreadExecutor

public void setThreadExecutor(ThreadExecutor threadExecutor)

getThreadExecutor

public ThreadExecutor getThreadExecutor()

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.


setDriverDelegateClass

public void setDriverDelegateClass(java.lang.String delegateClassName)
                            throws InvalidConfigurationException

Set 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

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 the MisfireHandler and the ClusterManager.

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 the MisfireHandler and the ClusterManager.

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 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 are misfired Triggers.


getLog

protected org.slf4j.Logger getLog()

initialize

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.

Specified by:
initialize in interface JobStore
Throws:
SchedulerConfigException

schedulerStarted

public void schedulerStarted()
                      throws SchedulerException
Description copied from interface: JobStore

Called by the QuartzScheduler to inform the JobStore that the scheduler has started.

Specified by:
schedulerStarted in interface JobStore
Throws:
SchedulerException
See Also:
JobStore.schedulerStarted()

shutdown

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.

Specified by:
shutdown in interface JobStore

supportsPersistence

public boolean supportsPersistence()
Specified by:
supportsPersistence in interface JobStore

getNonManagedTXConnection

protected abstract java.sql.Connection getNonManagedTXConnection()
                                                          throws JobPersistenceException
Throws:
JobPersistenceException

getAttributeRestoringConnection

protected java.sql.Connection getAttributeRestoringConnection(java.sql.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).


getConnection

protected java.sql.Connection getConnection()
                                     throws JobPersistenceException
Throws:
JobPersistenceException

releaseLock

protected void releaseLock(java.sql.Connection conn,
                           java.lang.String lockName,
                           boolean doIt)

cleanVolatileTriggerAndJobs

protected void cleanVolatileTriggerAndJobs()
                                    throws JobPersistenceException
Removes all volatile data.

Throws:
JobPersistenceException - If jobs could not be recovered.

cleanVolatileTriggerAndJobs

protected void cleanVolatileTriggerAndJobs(java.sql.Connection conn)
                                    throws JobPersistenceException

Removes all volatile data.

Throws:
JobPersistenceException - if jobs could not be recovered

recoverJobs

protected void recoverJobs()
                    throws JobPersistenceException
Recover 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 JobPersistenceException

Will 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:
JobPersistenceException
java.sql.SQLException

updateMisfiredTrigger

protected boolean updateMisfiredTrigger(java.sql.Connection conn,
                                        SchedulingContext ctxt,
                                        java.lang.String triggerName,
                                        java.lang.String groupName,
                                        java.lang.String newStateIfNotComplete,
                                        boolean forceState)
                                 throws JobPersistenceException
Throws:
JobPersistenceException

storeJobAndTrigger

public void storeJobAndTrigger(SchedulingContext ctxt,
                               JobDetail newJob,
                               Trigger newTrigger)
                        throws ObjectAlreadyExistsException,
                               JobPersistenceException

Store the given JobDetail and Trigger.

Specified by:
storeJobAndTrigger in interface JobStore
Parameters:
newJob - The JobDetail to be stored.
newTrigger - The Trigger to be stored.
Throws:
ObjectAlreadyExistsException - if a Job with the same name/group already exists.
JobPersistenceException

storeJob

public void storeJob(SchedulingContext ctxt,
                     JobDetail newJob,
                     boolean replaceExisting)
              throws ObjectAlreadyExistsException,
                     JobPersistenceException

Store the given JobDetail.

Specified by:
storeJob in interface JobStore
Parameters:
newJob - The JobDetail to be stored.
replaceExisting - If true, any Job existing in the JobStore with the same name & group should be over-written.
Throws:
ObjectAlreadyExistsException - if a Job with the same name/group already exists, and replaceExisting is set to false.
JobPersistenceException

storeJob

protected void storeJob(java.sql.Connection conn,
                        SchedulingContext ctxt,
                        JobDetail newJob,
                        boolean replaceExisting)
                 throws ObjectAlreadyExistsException,
                        JobPersistenceException

Insert or update a job.

Throws:
ObjectAlreadyExistsException
JobPersistenceException

jobExists

protected boolean jobExists(java.sql.Connection conn,
                            java.lang.String jobName,
                            java.lang.String groupName)
                     throws JobPersistenceException

Check existence of a given job.

Throws:
JobPersistenceException

storeTrigger

public void storeTrigger(SchedulingContext ctxt,
                         Trigger newTrigger,
                         boolean replaceExisting)
                  throws ObjectAlreadyExistsException,
                         JobPersistenceException

Store the given Trigger.

Specified by:
storeTrigger in interface JobStore
Parameters:
newTrigger - The Trigger to be stored.
replaceExisting - If true, any Trigger existing in the JobStore with the same name & group should be over-written.
Throws:
ObjectAlreadyExistsException - if a Trigger with the same name/group already exists, and replaceExisting is set to false.
JobPersistenceException
See Also:
JobStore.pauseTriggerGroup(SchedulingContext, String)

storeTrigger

protected void storeTrigger(java.sql.Connection conn,
                            SchedulingContext ctxt,
                            Trigger newTrigger,
                            JobDetail job,
                            boolean replaceExisting,
                            java.lang.String state,
                            boolean forceState,
                            boolean recovering)
                     throws ObjectAlreadyExistsException,
                            JobPersistenceException

Insert or update a trigger.

Throws:
ObjectAlreadyExistsException
JobPersistenceException

triggerExists

protected boolean triggerExists(java.sql.Connection conn,
                                java.lang.String triggerName,
                                java.lang.String groupName)
                         throws JobPersistenceException

Check existence of a given trigger.

Throws:
JobPersistenceException

removeJob

public boolean removeJob(SchedulingContext ctxt,
                         java.lang.String jobName,
                         java.lang.String groupName)
                  throws JobPersistenceException

Remove (delete) the Job with the given name, and any Trigger s that reference it.

If removal of the Job results in an empty group, the group should be removed from the JobStore's list of known group names.

Specified by:
removeJob in interface JobStore
Parameters:
jobName - The name of the Job to be removed.
groupName - The group name of the Job to be removed.
Returns:
true if a Job with the given name & group was found and removed from the store.
Throws:
JobPersistenceException

removeJob

protected boolean removeJob(java.sql.Connection conn,
                            SchedulingContext ctxt,
                            java.lang.String jobName,
                            java.lang.String groupName,
                            boolean activeDeleteSafe)
                     throws JobPersistenceException
Throws:
JobPersistenceException

retrieveJob

public JobDetail retrieveJob(SchedulingContext ctxt,
                             java.lang.String jobName,
                             java.lang.String groupName)
                      throws JobPersistenceException

Retrieve the JobDetail for the given Job.

Specified by:
retrieveJob in interface JobStore
Parameters:
jobName - The name of the Job to be retrieved.
groupName - The group name of the Job to be retrieved.
Returns:
The desired Job, or null if there is no match.
Throws:
JobPersistenceException

retrieveJob

protected JobDetail retrieveJob(java.sql.Connection conn,
                                SchedulingContext ctxt,
                                java.lang.String jobName,
                                java.lang.String groupName)
                         throws JobPersistenceException
Throws:
JobPersistenceException

removeTrigger

public boolean removeTrigger(SchedulingContext ctxt,
                             java.lang.String triggerName,
                             java.lang.String groupName)
                      throws JobPersistenceException

Remove (delete) the Trigger with the given name.

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.

Specified by:
removeTrigger in interface JobStore
Parameters:
triggerName - The name of the Trigger to be removed.
groupName - The group name of the Trigger to be removed.
Returns:
true if a Trigger with the given name & group was found and removed from the store.
Throws:
JobPersistenceException

removeTrigger

protected boolean removeTrigger(java.sql.Connection conn,
                                SchedulingContext ctxt,
                                java.lang.String triggerName,
                                java.lang.String groupName)
                         throws JobPersistenceException
Throws:
JobPersistenceException

replaceTrigger

public boolean replaceTrigger(SchedulingContext ctxt,
                              java.lang.String triggerName,
                              java.lang.String groupName,
                              Trigger newTrigger)
                       throws JobPersistenceException
Description copied from interface: JobStore

Remove (delete) the Trigger with the given name, and store the new given one - which must be associated with the same job.

Specified by:
replaceTrigger in interface JobStore
triggerName - 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.
Returns:
true if a Trigger with the given name & group was found and removed from the store.
Throws:
JobPersistenceException
See Also:
JobStore.replaceTrigger(org.quartz.core.SchedulingContext, java.lang.String, java.lang.String, org.quartz.Trigger)

replaceTrigger

protected boolean replaceTrigger(java.sql.Connection conn,
                                 SchedulingContext ctxt,
                                 java.lang.String triggerName,
                                 java.lang.String groupName,
                                 Trigger newTrigger)
                          throws JobPersistenceException
Throws:
JobPersistenceException

retrieveTrigger

public Trigger retrieveTrigger(SchedulingContext ctxt,
                               java.lang.String triggerName,
                               java.lang.String groupName)
                        throws JobPersistenceException

Retrieve the given Trigger.

Specified by:
retrieveTrigger in interface JobStore
Parameters:
triggerName - The name of the Trigger to be retrieved.
groupName - The group name of the Trigger to be retrieved.
Returns:
The desired Trigger, or null if there is no match.
Throws:
JobPersistenceException

retrieveTrigger

protected Trigger retrieveTrigger(java.sql.Connection conn,
                                  SchedulingContext ctxt,
                                  java.lang.String triggerName,
                                  java.lang.String groupName)
                           throws JobPersistenceException
Throws:
JobPersistenceException

retrieveTrigger

protected Trigger retrieveTrigger(java.sql.Connection conn,
                                  java.lang.String triggerName,
                                  java.lang.String groupName)
                           throws JobPersistenceException
Throws:
JobPersistenceException

getTriggerState

public int getTriggerState(SchedulingContext ctxt,
                           java.lang.String triggerName,
                           java.lang.String groupName)
                    throws JobPersistenceException

Get the current state of the identified Trigger.

Specified by:
getTriggerState in interface JobStore
Throws:
JobPersistenceException
See Also:
Trigger.STATE_NORMAL, Trigger.STATE_PAUSED, Trigger.STATE_COMPLETE, Trigger.STATE_ERROR, Trigger.STATE_NONE

getTriggerState

public int getTriggerState(java.sql.Connection conn,
                           SchedulingContext ctxt,
                           java.lang.String triggerName,
                           java.lang.String groupName)
                    throws JobPersistenceException
Throws:
JobPersistenceException

storeCalendar

public void storeCalendar(SchedulingContext ctxt,
                          java.lang.String calName,
                          Calendar calendar,
                          boolean replaceExisting,
                          boolean updateTriggers)
                   throws ObjectAlreadyExistsException,
                          JobPersistenceException

Store the given Calendar.

Specified by:
storeCalendar in interface JobStore
Parameters:
calName - 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.
Throws:
ObjectAlreadyExistsException - if a Calendar with the same name already exists, and replaceExisting is set to false.
JobPersistenceException

storeCalendar

protected void storeCalendar(java.sql.Connection conn,
                             SchedulingContext ctxt,
                             java.lang.String calName,
                             Calendar calendar,
                             boolean replaceExisting,
                             boolean updateTriggers)
                      throws ObjectAlreadyExistsException,
                             JobPersistenceException
Throws:
ObjectAlreadyExistsException
JobPersistenceException

calendarExists

protected boolean calendarExists(java.sql.Connection conn,
                                 java.lang.String calName)
                          throws JobPersistenceException
Throws:
JobPersistenceException

removeCalendar

public boolean removeCalendar(SchedulingContext ctxt,
                              java.lang.String calName)
                       throws JobPersistenceException

Remove (delete) the Calendar with the given name.

If removal of the Calendar would result in Triggers pointing to non-existent calendars, then a JobPersistenceException will be thrown.

*

Specified by:
removeCalendar in interface JobStore
Parameters:
calName - The name of the Calendar to be removed.
Returns:
true if a Calendar with the given name was found and removed from the store.
Throws:
JobPersistenceException

removeCalendar

protected boolean removeCalendar(java.sql.Connection conn,
                                 SchedulingContext ctxt,
                                 java.lang.String calName)
                          throws JobPersistenceException
Throws:
JobPersistenceException

retrieveCalendar

public Calendar retrieveCalendar(SchedulingContext ctxt,
                                 java.lang.String calName)
                          throws JobPersistenceException

Retrieve the given Trigger.

Specified by:
retrieveCalendar in interface JobStore
Parameters:
calName - The name of the Calendar to be retrieved.
Returns:
The desired Calendar, or null if there is no match.
Throws:
JobPersistenceException

retrieveCalendar

protected Calendar retrieveCalendar(java.sql.Connection conn,
                                    SchedulingContext ctxt,
                                    java.lang.String calName)
                             throws JobPersistenceException
Throws:
JobPersistenceException

getNumberOfJobs

public int getNumberOfJobs(SchedulingContext ctxt)
                    throws JobPersistenceException

Get the number of Job s that are stored in the JobStore.

Specified by:
getNumberOfJobs in interface JobStore
Throws:
JobPersistenceException

getNumberOfJobs

protected int getNumberOfJobs(java.sql.Connection conn,
                              SchedulingContext ctxt)
                       throws JobPersistenceException
Throws:
JobPersistenceException

getNumberOfTriggers

public int getNumberOfTriggers(SchedulingContext ctxt)
                        throws JobPersistenceException

Get the number of Trigger s that are stored in the JobsStore.

Specified by:
getNumberOfTriggers in interface JobStore
Throws:
JobPersistenceException

getNumberOfTriggers

protected int getNumberOfTriggers(java.sql.Connection conn,
                                  SchedulingContext ctxt)
                           throws JobPersistenceException
Throws:
JobPersistenceException

getNumberOfCalendars

public int getNumberOfCalendars(SchedulingContext ctxt)
                         throws JobPersistenceException

Get the number of Calendar s that are stored in the JobsStore.

Specified by:
getNumberOfCalendars in interface JobStore
Throws:
JobPersistenceException

getNumberOfCalendars

protected int getNumberOfCalendars(java.sql.Connection conn,
                                   SchedulingContext ctxt)
                            throws JobPersistenceException
Throws:
JobPersistenceException

getJobNames

public java.lang.String[] getJobNames(SchedulingContext ctxt,
                                      java.lang.String groupName)
                               throws JobPersistenceException

Get the names of all of the Job s that have the given group name.

If there are no jobs in the given group name, the result should be a zero-length array (not null).

Specified by:
getJobNames in interface JobStore
Throws:
JobPersistenceException

getJobNames

protected java.lang.String[] getJobNames(java.sql.Connection conn,
                                         SchedulingContext ctxt,
                                         java.lang.String groupName)
                                  throws JobPersistenceException
Throws:
JobPersistenceException

getTriggerNames

public java.lang.String[] getTriggerNames(SchedulingContext ctxt,
                                          java.lang.String groupName)
                                   throws JobPersistenceException

Get the names of all of the Trigger s that have the given group name.

If there are no triggers in the given group name, the result should be a zero-length array (not null).

Specified by:
getTriggerNames in interface JobStore
Throws:
JobPersistenceException

getTriggerNames

protected java.lang.String[] getTriggerNames(java.sql.Connection conn,
                                             SchedulingContext ctxt,
                                             java.lang.String groupName)
                                      throws JobPersistenceException
Throws:
JobPersistenceException

getJobGroupNames

public java.lang.String[] getJobGroupNames(SchedulingContext ctxt)
                                    throws JobPersistenceException

Get the names of all of the Job groups.

If there are no known group names, the result should be a zero-length array (not null).

Specified by:
getJobGroupNames in interface JobStore
Throws:
JobPersistenceException

getJobGroupNames

protected java.lang.String[] getJobGroupNames(java.sql.Connection conn,
                                              SchedulingContext ctxt)
                                       throws JobPersistenceException
Throws:
JobPersistenceException

getTriggerGroupNames

public java.lang.String[] getTriggerGroupNames(SchedulingContext ctxt)
                                        throws JobPersistenceException

Get the names of all of the Trigger groups.

If there are no known group names, the result should be a zero-length array (not null).

Specified by:
getTriggerGroupNames in interface JobStore
Throws:
JobPersistenceException

getTriggerGroupNames

protected java.lang.String[] getTriggerGroupNames(java.sql.Connection conn,
                                                  SchedulingContext ctxt)
                                           throws JobPersistenceException
Throws:
JobPersistenceException

getCalendarNames

public java.lang.String[] getCalendarNames(SchedulingContext ctxt)
                                    throws JobPersistenceException

Get the names of all of the Calendar s in the JobStore.

If there are no Calendars in the given group name, the result should be a zero-length array (not null).

Specified by:
getCalendarNames in interface JobStore
Throws:
JobPersistenceException

getCalendarNames

protected java.lang.String[] getCalendarNames(java.sql.Connection conn,
                                              SchedulingContext ctxt)
                                       throws JobPersistenceException
Throws:
JobPersistenceException

getTriggersForJob

public Trigger[] getTriggersForJob(SchedulingContext ctxt,
                                   java.lang.String jobName,
                                   java.lang.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.

Specified by:
getTriggersForJob in interface JobStore
Throws:
JobPersistenceException

getTriggersForJob

protected Trigger[] getTriggersForJob(java.sql.Connection conn,
                                      SchedulingContext ctxt,
                                      java.lang.String jobName,
                                      java.lang.String groupName)
                               throws JobPersistenceException
Throws:
JobPersistenceException

pauseTrigger

public void pauseTrigger(SchedulingContext ctxt,
                         java.lang.String triggerName,
                         java.lang.String groupName)
                  throws JobPersistenceException

Pause the Trigger with the given name.

Specified by:
pauseTrigger in interface JobStore
Throws:
JobPersistenceException
See Also:
resumeTrigger(SchedulingContext, String, String)

pauseTrigger

public void pauseTrigger(java.sql.Connection conn,
                         SchedulingContext ctxt,
                         java.lang.String triggerName,
                         java.lang.String groupName)
                  throws JobPersistenceException

Pause the Trigger with the given name.

Throws:
JobPersistenceException
See Also:
resumeTrigger(Connection, SchedulingContext, String, String)

pauseJob

public void pauseJob(SchedulingContext ctxt,
                     java.lang.String jobName,
                     java.lang.String groupName)
              throws JobPersistenceException

Pause the Job with the given name - by pausing all of its current Triggers.

Specified by:
pauseJob in interface JobStore
Throws:
JobPersistenceException
See Also:
resumeJob(SchedulingContext, String, String)

pauseJobGroup

public void pauseJobGroup(SchedulingContext ctxt,
                          java.lang.String groupName)
                   throws JobPersistenceException

Pause all of the Jobs in the given group - by pausing all of their Triggers.

Specified by:
pauseJobGroup in interface JobStore
Throws:
JobPersistenceException
See Also:
resumeJobGroup(SchedulingContext, String)

checkBlockedState

protected java.lang.String checkBlockedState(java.sql.Connection conn,
                                             SchedulingContext ctxt,
                                             java.lang.String jobName,
                                             java.lang.String jobGroupName,
                                             java.lang.String currentState)
                                      throws JobPersistenceException
Determines if a Trigger for the given job should be blocked. State can only transition to STATE_PAUSED_BLOCKED/STATE_BLOCKED from STATE_PAUSED/STATE_WAITING respectively.

Returns:
STATE_PAUSED_BLOCKED, STATE_BLOCKED, or the currentState.
Throws:
JobPersistenceException

resumeTrigger

public void resumeTrigger(SchedulingContext ctxt,
                          java.lang.String triggerName,
                          java.lang.String groupName)
                   throws JobPersistenceException

Resume (un-pause) the Trigger with the given name.

If the Trigger missed one or more fire-times, then the Trigger's misfire instruction will be applied.

Specified by:
resumeTrigger in interface JobStore
Throws:
JobPersistenceException
See Also:
pauseTrigger(SchedulingContext, String, String)

resumeTrigger

public void resumeTrigger(java.sql.Connection conn,
                          SchedulingContext ctxt,
                          java.lang.String triggerName,
                          java.lang.String groupName)
                   throws JobPersistenceException

Resume (un-pause) the Trigger with the given name.

If the Trigger missed one or more fire-times, then the Trigger's misfire instruction will be applied.

Throws:
JobPersistenceException
See Also:
pauseTrigger(Connection, SchedulingContext, String, String)

resumeJob

public void resumeJob(SchedulingContext ctxt,
                      java.lang.String jobName,
                      java.lang.String groupName)
               throws JobPersistenceException

Resume (un-pause) the Job with the given name.

If any of the Job'sTrigger s missed one or more fire-times, then the Trigger's misfire instruction will be applied.

Specified by:
resumeJob in interface JobStore
Throws:
JobPersistenceException
See Also:
pauseJob(SchedulingContext, String, String)

resumeJobGroup

public void resumeJobGroup(SchedulingContext ctxt,
                           java.lang.String groupName)
                    throws JobPersistenceException

Resume (un-pause) all of the Jobs in the given group.

If any of the Job s had Trigger s that missed one or more fire-times, then the Trigger's misfire instruction will be applied.

Specified by:
resumeJobGroup in interface JobStore
Throws:
JobPersistenceException
See Also:
pauseJobGroup(SchedulingContext, String)

pauseTriggerGroup

public void pauseTriggerGroup(SchedulingContext ctxt,
                              java.lang.String groupName)
                       throws JobPersistenceException

Pause all of the Triggers in the given group.

Specified by:
pauseTriggerGroup in interface JobStore
Throws:
JobPersistenceException
See Also:
resumeTriggerGroup(SchedulingContext, String)

pauseTriggerGroup

public void pauseTriggerGroup(java.sql.Connection conn,
                              SchedulingContext ctxt,
                              java.lang.String groupName)
                       throws JobPersistenceException

Pause all of the Triggers in the given group.

Throws:
JobPersistenceException
See Also:
resumeTriggerGroup(Connection, SchedulingContext, String)

getPausedTriggerGroups

public java.util.Set getPausedTriggerGroups(SchedulingContext ctxt)
                                     throws JobPersistenceException
Specified by:
getPausedTriggerGroups in interface JobStore
Throws:
JobPersistenceException

getPausedTriggerGroups

public java.util.Set getPausedTriggerGroups(java.sql.Connection conn,
                                            SchedulingContext ctxt)
                                     throws JobPersistenceException

Pause all of the Triggers in the given group.

Throws:
JobPersistenceException
See Also:
resumeTriggerGroup(Connection, SchedulingContext, String)

resumeTriggerGroup

public void resumeTriggerGroup(SchedulingContext ctxt,
                               java.lang.String groupName)
                        throws JobPersistenceException

Resume (un-pause) all of the Triggers in the given group.

If any Trigger missed one or more fire-times, then the Trigger's misfire instruction will be applied.

Specified by:
resumeTriggerGroup in interface JobStore
Throws:
JobPersistenceException
See Also:
pauseTriggerGroup(SchedulingContext, String)

resumeTriggerGroup

public void resumeTriggerGroup(java.sql.Connection conn,
                               SchedulingContext ctxt,
                               java.lang.String groupName)
                        throws JobPersistenceException

Resume (un-pause) all of the Triggers in the given group.

If any Trigger missed one or more fire-times, then the Trigger's misfire instruction will be applied.

Throws:
JobPersistenceException
See Also:
pauseTriggerGroup(Connection, SchedulingContext, String)

pauseAll

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.

Specified by:
pauseAll in interface JobStore
Throws:
JobPersistenceException
See Also:
resumeAll(SchedulingContext), pauseTriggerGroup(SchedulingContext, String)

pauseAll

public void pauseAll(java.sql.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.

Throws:
JobPersistenceException
See Also:
resumeAll(SchedulingContext), pauseTriggerGroup(SchedulingContext, String)

resumeAll

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.

Specified by:
resumeAll in interface JobStore
Throws:
JobPersistenceException
See Also:
pauseAll(SchedulingContext)

resumeAll

public void resumeAll(java.sql.Connection conn,
                      SchedulingContext ctxt)
               throws JobPersistenceException
protected

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.

Throws:
JobPersistenceException
See Also:
pauseAll(SchedulingContext)

getFiredTriggerRecordId

protected java.lang.String getFiredTriggerRecordId()

acquireNextTrigger

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.

Specified by:
acquireNextTrigger in interface JobStore
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(SchedulingContext, Trigger)

acquireNextTrigger

protected Trigger acquireNextTrigger(java.sql.Connection conn,
                                     SchedulingContext ctxt,
                                     long noLaterThan)
                              throws JobPersistenceException
Throws:
JobPersistenceException

releaseAcquiredTrigger

public 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).

Specified by:
releaseAcquiredTrigger in interface JobStore
Throws:
JobPersistenceException

releaseAcquiredTrigger

protected void releaseAcquiredTrigger(java.sql.Connection conn,
                                      SchedulingContext ctxt,
                                      Trigger trigger)
                               throws JobPersistenceException
Throws:
JobPersistenceException

triggerFired

public 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).

Specified by:
triggerFired in interface JobStore
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,
                                          SchedulingContext ctxt,
                                          Trigger trigger)
                                   throws JobPersistenceException
Throws:
JobPersistenceException

triggeredJobComplete

public 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 JobDataMap in the given JobDetail should be updated if the Job is stateful.

Specified by:
triggeredJobComplete in interface JobStore
Throws:
JobPersistenceException

triggeredJobComplete

protected void triggeredJobComplete(java.sql.Connection conn,
                                    SchedulingContext ctxt,
                                    Trigger trigger,
                                    JobDetail jobDetail,
                                    int 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 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 clusterCheckIn(java.sql.Connection conn)
                                 throws JobPersistenceException
Throws:
JobPersistenceException

clusterRecover

protected void clusterRecover(java.sql.Connection conn,
                              java.util.List 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 supplied Connection.

Ignores a null Connection. Any exception thrown trying to close the Connection is logged and ignored.

Parameters:
conn - The Connection to 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 propogate 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 JobPersistenceException
Commit the supplied connection

Parameters:
conn - (Optional)
Throws:
JobPersistenceException - thrown if a SQLException occurs when the connection is committed

executeWithoutLock

public java.lang.Object executeWithoutLock(JobStoreSupport.TransactionCallback 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 void executeInLock(java.lang.String lockName,
                             JobStoreSupport.VoidTransactionCallback txCallback)
                      throws JobPersistenceException
Execute the given callback having aquired the given lock. Depending on the JobStore, the surrounding transaction may be assumed to be already present (managed). This version is just a handy wrapper around executeInLock that doesn't require a return value.

Parameters:
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.
Throws:
JobPersistenceException
See Also:
executeInLock(String, TransactionCallback)

executeInLock

protected abstract java.lang.Object executeInLock(java.lang.String lockName,
                                                  JobStoreSupport.TransactionCallback txCallback)
                                           throws JobPersistenceException
Execute the given callback having aquired 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 aquire, for example "TRIGGER_ACCESS". If null, then no lock is aquired, but the lockCallback is still executed in a transaction.
Throws:
JobPersistenceException

executeInNonManagedTXLock

protected void executeInNonManagedTXLock(java.lang.String lockName,
                                         JobStoreSupport.VoidTransactionCallback txCallback)
                                  throws JobPersistenceException
Execute the given callback having optionally aquired the given lock. This uses the non-managed transaction connection. This version is just a handy wrapper around executeInNonManagedTXLock that doesn't require a return value.

Parameters:
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.
Throws:
JobPersistenceException
See Also:
executeInNonManagedTXLock(String, TransactionCallback)

executeInNonManagedTXLock

protected java.lang.Object executeInNonManagedTXLock(java.lang.String lockName,
                                                     JobStoreSupport.TransactionCallback txCallback)
                                              throws JobPersistenceException
Execute the given callback having optionally aquired the given lock. This uses the non-managed transaction connection.

Parameters:
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.
Throws:
JobPersistenceException


Copyright 2001-2019, Terracotta, Inc.