Class MongoDBJobStore

  • All Implemented Interfaces:
    Constants, org.quartz.spi.JobStore
    Direct Known Subclasses:
    DynamicMongoDBJobStore

    public class MongoDBJobStore
    extends java.lang.Object
    implements org.quartz.spi.JobStore, Constants
    • Field Detail

      • PROPERTIES_FILE_NAME

        public static final java.lang.String PROPERTIES_FILE_NAME
        See Also:
        Constant Field Values
    • Constructor Detail

      • MongoDBJobStore

        public MongoDBJobStore()
      • MongoDBJobStore

        public MongoDBJobStore​(MongoConnector mongoConnector)
      • MongoDBJobStore

        public MongoDBJobStore​(com.mongodb.client.MongoDatabase mongoDatabase)
      • MongoDBJobStore

        public MongoDBJobStore​(com.mongodb.client.MongoClient mongo)
      • MongoDBJobStore

        public MongoDBJobStore​(java.lang.String mongoUri,
                               java.lang.String username,
                               java.lang.String password)
    • Method Detail

      • getClassLoaderHelper

        protected org.quartz.spi.ClassLoadHelper getClassLoaderHelper​(org.quartz.spi.ClassLoadHelper original)
        Override to change class loading mechanism, to e.g. dynamic
        Parameters:
        original - default provided by Quartz
        Returns:
        loader to use for loading of Quartz Jobs' classes
      • initialize

        public void initialize​(org.quartz.spi.ClassLoadHelper loadHelper,
                               org.quartz.spi.SchedulerSignaler signaler)
                        throws org.quartz.SchedulerConfigException
        Specified by:
        initialize in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.SchedulerConfigException
      • schedulerStarted

        public void schedulerStarted()
                              throws org.quartz.SchedulerException
        Specified by:
        schedulerStarted in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.SchedulerException
      • schedulerPaused

        public void schedulerPaused()
        Specified by:
        schedulerPaused in interface org.quartz.spi.JobStore
      • schedulerResumed

        public void schedulerResumed()
        Specified by:
        schedulerResumed in interface org.quartz.spi.JobStore
      • shutdown

        public void shutdown()
        Specified by:
        shutdown in interface org.quartz.spi.JobStore
      • supportsPersistence

        public boolean supportsPersistence()
        Specified by:
        supportsPersistence in interface org.quartz.spi.JobStore
      • getEstimatedTimeToReleaseAndAcquireTrigger

        public long getEstimatedTimeToReleaseAndAcquireTrigger()
        Specified by:
        getEstimatedTimeToReleaseAndAcquireTrigger in interface org.quartz.spi.JobStore
      • getAcquireRetryDelay

        public long getAcquireRetryDelay​(int failureCount)
        Specified by:
        getAcquireRetryDelay in interface org.quartz.spi.JobStore
      • setIsClustered

        public void setIsClustered​(boolean isClustered)
        Set whether this instance is part of a cluster.
      • isClustered

        public boolean isClustered()
        Specified by:
        isClustered in interface org.quartz.spi.JobStore
      • setClusterCheckinInterval

        public void setClusterCheckinInterval​(long clusterCheckinInterval)
        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.

      • isJobDataAsBase64

        public boolean isJobDataAsBase64()
      • setJobDataAsBase64

        public void setJobDataAsBase64​(boolean jobDataAsBase64)
      • getCheckInErrorHandler

        public java.lang.String getCheckInErrorHandler()
      • setCheckInErrorHandler

        public void setCheckInErrorHandler​(java.lang.String checkInErrorHandler)
      • storeJobAndTrigger

        public void storeJobAndTrigger​(org.quartz.JobDetail newJob,
                                       org.quartz.spi.OperableTrigger newTrigger)
                                throws org.quartz.JobPersistenceException
        Job and Trigger storage Methods
        Specified by:
        storeJobAndTrigger in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.JobPersistenceException
      • storeJob

        public void storeJob​(org.quartz.JobDetail newJob,
                             boolean replaceExisting)
                      throws org.quartz.JobPersistenceException
        Specified by:
        storeJob in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.JobPersistenceException
      • storeJobsAndTriggers

        public void storeJobsAndTriggers​(java.util.Map<org.quartz.JobDetail,​java.util.Set<? extends org.quartz.Trigger>> triggersAndJobs,
                                         boolean replace)
                                  throws org.quartz.JobPersistenceException
        Specified by:
        storeJobsAndTriggers in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.JobPersistenceException
      • removeJob

        public boolean removeJob​(org.quartz.JobKey jobKey)
                          throws org.quartz.JobPersistenceException
        Specified by:
        removeJob in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.JobPersistenceException
      • removeJobs

        public boolean removeJobs​(java.util.List<org.quartz.JobKey> jobKeys)
                           throws org.quartz.JobPersistenceException
        Specified by:
        removeJobs in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.JobPersistenceException
      • retrieveJob

        public org.quartz.JobDetail retrieveJob​(org.quartz.JobKey jobKey)
                                         throws org.quartz.JobPersistenceException
        Specified by:
        retrieveJob in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.JobPersistenceException
      • storeTrigger

        public void storeTrigger​(org.quartz.spi.OperableTrigger newTrigger,
                                 boolean replaceExisting)
                          throws org.quartz.JobPersistenceException
        Specified by:
        storeTrigger in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.JobPersistenceException
      • removeTrigger

        public boolean removeTrigger​(org.quartz.TriggerKey triggerKey)
                              throws org.quartz.JobPersistenceException
        Specified by:
        removeTrigger in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.JobPersistenceException
      • removeTriggers

        public boolean removeTriggers​(java.util.List<org.quartz.TriggerKey> triggerKeys)
                               throws org.quartz.JobPersistenceException
        Specified by:
        removeTriggers in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.JobPersistenceException
      • replaceTrigger

        public boolean replaceTrigger​(org.quartz.TriggerKey triggerKey,
                                      org.quartz.spi.OperableTrigger newTrigger)
                               throws org.quartz.JobPersistenceException
        Specified by:
        replaceTrigger in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.JobPersistenceException
      • retrieveTrigger

        public org.quartz.spi.OperableTrigger retrieveTrigger​(org.quartz.TriggerKey triggerKey)
                                                       throws org.quartz.JobPersistenceException
        Specified by:
        retrieveTrigger in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.JobPersistenceException
      • checkExists

        public boolean checkExists​(org.quartz.JobKey jobKey)
                            throws org.quartz.JobPersistenceException
        Specified by:
        checkExists in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.JobPersistenceException
      • checkExists

        public boolean checkExists​(org.quartz.TriggerKey triggerKey)
                            throws org.quartz.JobPersistenceException
        Specified by:
        checkExists in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.JobPersistenceException
      • clearAllSchedulingData

        public void clearAllSchedulingData()
                                    throws org.quartz.JobPersistenceException
        Specified by:
        clearAllSchedulingData in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.JobPersistenceException
      • storeCalendar

        public void storeCalendar​(java.lang.String name,
                                  org.quartz.Calendar calendar,
                                  boolean replaceExisting,
                                  boolean updateTriggers)
                           throws org.quartz.ObjectAlreadyExistsException,
                                  org.quartz.JobPersistenceException
        Specified by:
        storeCalendar in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.ObjectAlreadyExistsException
        org.quartz.JobPersistenceException
      • removeCalendar

        public boolean removeCalendar​(java.lang.String calName)
                               throws org.quartz.JobPersistenceException
        Specified by:
        removeCalendar in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.JobPersistenceException
      • retrieveCalendar

        public org.quartz.Calendar retrieveCalendar​(java.lang.String calName)
                                             throws org.quartz.JobPersistenceException
        Specified by:
        retrieveCalendar in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.JobPersistenceException
      • getNumberOfJobs

        public int getNumberOfJobs()
                            throws org.quartz.JobPersistenceException
        Specified by:
        getNumberOfJobs in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.JobPersistenceException
      • getNumberOfTriggers

        public int getNumberOfTriggers()
                                throws org.quartz.JobPersistenceException
        Specified by:
        getNumberOfTriggers in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.JobPersistenceException
      • getNumberOfCalendars

        public int getNumberOfCalendars()
                                 throws org.quartz.JobPersistenceException
        Specified by:
        getNumberOfCalendars in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.JobPersistenceException
      • getJobKeys

        public java.util.Set<org.quartz.JobKey> getJobKeys​(org.quartz.impl.matchers.GroupMatcher<org.quartz.JobKey> matcher)
                                                    throws org.quartz.JobPersistenceException
        Specified by:
        getJobKeys in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.JobPersistenceException
      • getTriggerKeys

        public java.util.Set<org.quartz.TriggerKey> getTriggerKeys​(org.quartz.impl.matchers.GroupMatcher<org.quartz.TriggerKey> matcher)
                                                            throws org.quartz.JobPersistenceException
        Specified by:
        getTriggerKeys in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.JobPersistenceException
      • getJobGroupNames

        public java.util.List<java.lang.String> getJobGroupNames()
                                                          throws org.quartz.JobPersistenceException
        Specified by:
        getJobGroupNames in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.JobPersistenceException
      • getTriggerGroupNames

        public java.util.List<java.lang.String> getTriggerGroupNames()
                                                              throws org.quartz.JobPersistenceException
        Specified by:
        getTriggerGroupNames in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.JobPersistenceException
      • getCalendarNames

        public java.util.List<java.lang.String> getCalendarNames()
                                                          throws org.quartz.JobPersistenceException
        Specified by:
        getCalendarNames in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.JobPersistenceException
      • getTriggersForJob

        public java.util.List<org.quartz.spi.OperableTrigger> getTriggersForJob​(org.quartz.JobKey jobKey)
                                                                         throws org.quartz.JobPersistenceException
        Specified by:
        getTriggersForJob in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.JobPersistenceException
      • getTriggerState

        public org.quartz.Trigger.TriggerState getTriggerState​(org.quartz.TriggerKey triggerKey)
                                                        throws org.quartz.JobPersistenceException
        Specified by:
        getTriggerState in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.JobPersistenceException
      • pauseTrigger

        public void pauseTrigger​(org.quartz.TriggerKey triggerKey)
                          throws org.quartz.JobPersistenceException
        Specified by:
        pauseTrigger in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.JobPersistenceException
      • pauseTriggers

        public java.util.Collection<java.lang.String> pauseTriggers​(org.quartz.impl.matchers.GroupMatcher<org.quartz.TriggerKey> matcher)
                                                             throws org.quartz.JobPersistenceException
        Specified by:
        pauseTriggers in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.JobPersistenceException
      • resumeTrigger

        public void resumeTrigger​(org.quartz.TriggerKey triggerKey)
                           throws org.quartz.JobPersistenceException
        Specified by:
        resumeTrigger in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.JobPersistenceException
      • resumeTriggers

        public java.util.Collection<java.lang.String> resumeTriggers​(org.quartz.impl.matchers.GroupMatcher<org.quartz.TriggerKey> matcher)
                                                              throws org.quartz.JobPersistenceException
        Specified by:
        resumeTriggers in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.JobPersistenceException
      • getPausedTriggerGroups

        public java.util.Set<java.lang.String> getPausedTriggerGroups()
                                                               throws org.quartz.JobPersistenceException
        Specified by:
        getPausedTriggerGroups in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.JobPersistenceException
      • getPausedJobGroups

        public java.util.Set<java.lang.String> getPausedJobGroups()
                                                           throws org.quartz.JobPersistenceException
        Throws:
        org.quartz.JobPersistenceException
      • pauseAll

        public void pauseAll()
                      throws org.quartz.JobPersistenceException
        Specified by:
        pauseAll in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.JobPersistenceException
      • resumeAll

        public void resumeAll()
                       throws org.quartz.JobPersistenceException
        Specified by:
        resumeAll in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.JobPersistenceException
      • pauseJob

        public void pauseJob​(org.quartz.JobKey jobKey)
                      throws org.quartz.JobPersistenceException
        Specified by:
        pauseJob in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.JobPersistenceException
      • pauseJobs

        public java.util.Collection<java.lang.String> pauseJobs​(org.quartz.impl.matchers.GroupMatcher<org.quartz.JobKey> groupMatcher)
                                                         throws org.quartz.JobPersistenceException
        Specified by:
        pauseJobs in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.JobPersistenceException
      • resumeJob

        public void resumeJob​(org.quartz.JobKey jobKey)
                       throws org.quartz.JobPersistenceException
        Specified by:
        resumeJob in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.JobPersistenceException
      • resumeJobs

        public java.util.Collection<java.lang.String> resumeJobs​(org.quartz.impl.matchers.GroupMatcher<org.quartz.JobKey> groupMatcher)
                                                          throws org.quartz.JobPersistenceException
        Specified by:
        resumeJobs in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.JobPersistenceException
      • acquireNextTriggers

        public java.util.List<org.quartz.spi.OperableTrigger> acquireNextTriggers​(long noLaterThan,
                                                                                  int maxCount,
                                                                                  long timeWindow)
                                                                           throws org.quartz.JobPersistenceException
        Specified by:
        acquireNextTriggers in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.JobPersistenceException
      • releaseAcquiredTrigger

        public void releaseAcquiredTrigger​(org.quartz.spi.OperableTrigger trigger)
        Specified by:
        releaseAcquiredTrigger in interface org.quartz.spi.JobStore
      • resetTriggerFromErrorState

        public void resetTriggerFromErrorState​(org.quartz.TriggerKey triggerKey)
        Specified by:
        resetTriggerFromErrorState in interface org.quartz.spi.JobStore
      • triggersFired

        public java.util.List<org.quartz.spi.TriggerFiredResult> triggersFired​(java.util.List<org.quartz.spi.OperableTrigger> triggers)
                                                                        throws org.quartz.JobPersistenceException
        Specified by:
        triggersFired in interface org.quartz.spi.JobStore
        Throws:
        org.quartz.JobPersistenceException
      • triggeredJobComplete

        public void triggeredJobComplete​(org.quartz.spi.OperableTrigger trigger,
                                         org.quartz.JobDetail job,
                                         org.quartz.Trigger.CompletedExecutionInstruction triggerInstCode)
        Specified by:
        triggeredJobComplete in interface org.quartz.spi.JobStore
      • setInstanceId

        public void setInstanceId​(java.lang.String instanceId)
        Specified by:
        setInstanceId in interface org.quartz.spi.JobStore
      • setInstanceName

        public void setInstanceName​(java.lang.String schedName)
        Specified by:
        setInstanceName in interface org.quartz.spi.JobStore
      • setThreadPoolSize

        public void setThreadPoolSize​(int poolSize)
        Specified by:
        setThreadPoolSize in interface org.quartz.spi.JobStore
      • setAddresses

        public void setAddresses​(java.lang.String addresses)
      • getJobCollection

        public com.mongodb.client.MongoCollection<org.bson.Document> getJobCollection()
      • getTriggerCollection

        public com.mongodb.client.MongoCollection<org.bson.Document> getTriggerCollection()
      • getCalendarCollection

        public com.mongodb.client.MongoCollection<org.bson.Document> getCalendarCollection()
      • getLocksCollection

        public com.mongodb.client.MongoCollection<org.bson.Document> getLocksCollection()
      • getDbName

        public java.lang.String getDbName()
      • setDbName

        public void setDbName​(java.lang.String dbName)
      • setCollectionPrefix

        public void setCollectionPrefix​(java.lang.String prefix)
      • setMongoUri

        public void setMongoUri​(java.lang.String mongoUri)
      • setUsername

        public void setUsername​(java.lang.String username)
      • setPassword

        public void setPassword​(java.lang.String password)
      • setMisfireThreshold

        public void setMisfireThreshold​(long misfireThreshold)
      • setTriggerTimeoutMillis

        public void setTriggerTimeoutMillis​(long triggerTimeoutMillis)
      • setJobTimeoutMillis

        public void setJobTimeoutMillis​(long jobTimeoutMillis)
      • setMongoOptionMaxConnections

        public void setMongoOptionMaxConnections​(int maxConnections)
      • setMongoOptionConnectTimeoutMillis

        public void setMongoOptionConnectTimeoutMillis​(int maxConnectWaitTime)
      • setMongoOptionReadTimeoutMillis

        public void setMongoOptionReadTimeoutMillis​(int readTimeoutMillis)
      • setMongoOptionSocketKeepAlive

        public void setMongoOptionSocketKeepAlive​(boolean socketKeepAlive)
      • setMongoOptionEnableSSL

        public void setMongoOptionEnableSSL​(boolean enableSSL)
      • setMongoOptionSslInvalidHostNameAllowed

        public void setMongoOptionSslInvalidHostNameAllowed​(boolean sslInvalidHostNameAllowed)
      • setMongoOptionTrustStorePath

        public void setMongoOptionTrustStorePath​(java.lang.String trustStorePath)
      • setMongoOptionTrustStorePassword

        public void setMongoOptionTrustStorePassword​(java.lang.String trustStorePassword)
      • setMongoOptionTrustStoreType

        public void setMongoOptionTrustStoreType​(java.lang.String trustStoreType)
      • setMongoOptionKeyStorePath

        public void setMongoOptionKeyStorePath​(java.lang.String keyStorePath)
      • setMongoOptionKeyStorePassword

        public void setMongoOptionKeyStorePassword​(java.lang.String keyStorePassword)
      • setMongoOptionKeyStoreType

        public void setMongoOptionKeyStoreType​(java.lang.String keyStoreType)
      • setMongoOptionWriteConcernW

        public void setMongoOptionWriteConcernW​(java.lang.String mongoOptionWriteConcernW)
      • setMongoOptionWriteConcernTimeoutMillis

        public void setMongoOptionWriteConcernTimeoutMillis​(int writeConcernTimeoutMillis)
      • getAuthDbName

        public java.lang.String getAuthDbName()
      • setAuthDbName

        public void setAuthDbName​(java.lang.String authDbName)