Class BaseJobStore

  • All Implemented Interfaces:
    com.helger.quartz.spi.IJobStore

    public class BaseJobStore
    extends Object
    implements com.helger.quartz.spi.IJobStore
    IJobStore implementation based on RAMJobStore
    Author:
    Philip Helger
    • Constructor Summary

      Constructors 
      Constructor Description
      BaseJobStore()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.helger.commons.collection.impl.ICommonsList<com.helger.quartz.spi.IOperableTrigger> acquireNextTriggers​(long noLaterThan, int maxCount, long timeWindow)  
      protected boolean applyMisfire​(com.helger.schedule.jobstore.TriggerWrapper tw)  
      boolean checkExists​(com.helger.quartz.JobKey jobKey)  
      boolean checkExists​(com.helger.quartz.TriggerKey aTriggerKey)  
      void clearAllSchedulingData()
      Clear (delete!)
      com.helger.commons.collection.impl.ICommonsList<String> getCalendarNames()  
      long getEstimatedTimeToReleaseAndAcquireTrigger()  
      protected String getFiredTriggerRecordId()  
      com.helger.commons.collection.impl.ICommonsList<String> getJobGroupNames()  
      com.helger.commons.collection.impl.ICommonsSet<com.helger.quartz.JobKey> getJobKeys​(com.helger.quartz.impl.matchers.GroupMatcher<com.helger.quartz.JobKey> matcher)  
      long getMisfireThreshold()  
      int getNumberOfCalendars()  
      int getNumberOfJobs()  
      int getNumberOfTriggers()  
      com.helger.commons.collection.impl.ICommonsSet<String> getPausedTriggerGroups()  
      com.helger.commons.collection.impl.ICommonsList<String> getTriggerGroupNames()  
      com.helger.commons.collection.impl.ICommonsSet<com.helger.quartz.TriggerKey> getTriggerKeys​(com.helger.quartz.impl.matchers.GroupMatcher<com.helger.quartz.TriggerKey> matcher)  
      com.helger.commons.collection.impl.ICommonsList<com.helger.quartz.spi.IOperableTrigger> getTriggersForJob​(com.helger.quartz.JobKey aJobKey)  
      com.helger.quartz.ITrigger.ETriggerState getTriggerState​(com.helger.quartz.TriggerKey triggerKey)  
      protected com.helger.commons.collection.impl.ICommonsList<com.helger.schedule.jobstore.TriggerWrapper> getTriggerWrappersForCalendar​(String calName)  
      protected com.helger.commons.collection.impl.ICommonsList<com.helger.schedule.jobstore.TriggerWrapper> getTriggerWrappersForJob​(com.helger.quartz.JobKey aJobKey)  
      void initialize​(com.helger.quartz.spi.IClassLoadHelper loadHelper, com.helger.quartz.spi.ISchedulerSignaler aSignaler)  
      boolean isClustered()  
      void pauseAll()  
      void pauseJob​(com.helger.quartz.JobKey jobKey)
      Pause the IJobDetail with the given name - by pausing all of its current Triggers.
      com.helger.commons.collection.impl.ICommonsList<String> pauseJobs​(com.helger.quartz.impl.matchers.GroupMatcher<com.helger.quartz.JobKey> matcher)
      Pause all of the IJobDetails in the given group - by pausing all of their Triggers.
      void pauseTrigger​(com.helger.quartz.TriggerKey triggerKey)
      Pause the ITrigger with the given name.
      com.helger.commons.collection.impl.ICommonsList<String> pauseTriggers​(com.helger.quartz.impl.matchers.GroupMatcher<com.helger.quartz.TriggerKey> matcher)  
      protected String peekTriggers()  
      void releaseAcquiredTrigger​(com.helger.quartz.spi.IOperableTrigger trigger)
      Inform the JobStore that the scheduler no longer plans to fire the given Trigger, that it had previously acquired (reserved).
      boolean removeCalendar​(String calName)  
      boolean removeJob​(com.helger.quartz.JobKey jobKey)  
      boolean removeJobs​(List<com.helger.quartz.JobKey> jobKeys)  
      boolean removeTrigger​(com.helger.quartz.TriggerKey triggerKey)
      Remove (delete) the ITrigger with the given name.
      boolean removeTriggers​(List<com.helger.quartz.TriggerKey> triggerKeys)  
      boolean replaceTrigger​(com.helger.quartz.TriggerKey aTriggerKey, com.helger.quartz.spi.IOperableTrigger aNewTrigger)  
      void resumeAll()
      Resume (un-pause) all triggers - equivalent of calling resumeTriggerGroup(group) on every group.
      void resumeJob​(com.helger.quartz.JobKey jobKey)  
      com.helger.commons.collection.impl.ICommonsCollection<String> resumeJobs​(com.helger.quartz.impl.matchers.GroupMatcher<com.helger.quartz.JobKey> matcher)  
      void resumeTrigger​(com.helger.quartz.TriggerKey triggerKey)
      Resume (un-pause) the ITrigger with the given key.
      com.helger.commons.collection.impl.ICommonsList<String> resumeTriggers​(com.helger.quartz.impl.matchers.GroupMatcher<com.helger.quartz.TriggerKey> matcher)  
      com.helger.quartz.ICalendar retrieveCalendar​(String calName)  
      com.helger.quartz.IJobDetail retrieveJob​(com.helger.quartz.JobKey jobKey)
      Retrieve the IJobDetail for the given IJob.
      com.helger.quartz.spi.IOperableTrigger retrieveTrigger​(com.helger.quartz.TriggerKey triggerKey)
      Retrieve the given ITrigger.
      void schedulerPaused()  
      void schedulerResumed()  
      void schedulerStarted()  
      protected void setAllTriggersOfJobToState​(com.helger.quartz.JobKey jobKey, int state)  
      void setInstanceId​(String schedInstId)  
      void setInstanceName​(String schedName)  
      void setMisfireThreshold​(long nMisfireThreshold)
      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 setThreadPoolSize​(int poolSize)  
      void shutdown()  
      void storeCalendar​(String name, com.helger.quartz.ICalendar aCalendar, boolean bReplaceExisting, boolean bUpdateTriggers)  
      void storeJob​(com.helger.quartz.IJobDetail aNewJob, boolean bReplaceExisting)  
      void storeJobAndTrigger​(com.helger.quartz.IJobDetail aNewJob, com.helger.quartz.spi.IOperableTrigger aNewTrigger)  
      void storeJobsAndTriggers​(Map<com.helger.quartz.IJobDetail,​Set<? extends com.helger.quartz.ITrigger>> aTriggersAndJobs, boolean bReplace)  
      void storeTrigger​(com.helger.quartz.spi.IOperableTrigger aNewTrigger, boolean bReplaceExisting)  
      boolean supportsPersistence()  
      void triggeredJobComplete​(com.helger.quartz.spi.IOperableTrigger trigger, com.helger.quartz.IJobDetail jobDetail, com.helger.quartz.ITrigger.ECompletedExecutionInstruction triggerInstCode)  
      com.helger.commons.collection.impl.ICommonsList<com.helger.quartz.spi.TriggerFiredResult> triggersFired​(List<com.helger.quartz.spi.IOperableTrigger> firedTriggers)
      Inform the JobStore that the scheduler is now firing the given Trigger (executing its associated Job), that it had previously acquired (reserved).
    • Constructor Detail

      • BaseJobStore

        public BaseJobStore()
    • Method Detail

      • initialize

        public void initialize​(com.helger.quartz.spi.IClassLoadHelper loadHelper,
                               com.helger.quartz.spi.ISchedulerSignaler aSignaler)
        Specified by:
        initialize in interface com.helger.quartz.spi.IJobStore
      • schedulerStarted

        public void schedulerStarted()
        Specified by:
        schedulerStarted in interface com.helger.quartz.spi.IJobStore
      • schedulerPaused

        public void schedulerPaused()
        Specified by:
        schedulerPaused in interface com.helger.quartz.spi.IJobStore
      • schedulerResumed

        public void schedulerResumed()
        Specified by:
        schedulerResumed in interface com.helger.quartz.spi.IJobStore
      • getMisfireThreshold

        @Nonnegative
        public long getMisfireThreshold()
      • setMisfireThreshold

        public void setMisfireThreshold​(@Nonnegative
                                        long nMisfireThreshold)
        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:
        nMisfireThreshold - the new misfire threshold
      • shutdown

        public void shutdown()
        Specified by:
        shutdown in interface com.helger.quartz.spi.IJobStore
      • supportsPersistence

        public boolean supportsPersistence()
        Specified by:
        supportsPersistence in interface com.helger.quartz.spi.IJobStore
      • clearAllSchedulingData

        public void clearAllSchedulingData()
                                    throws com.helger.quartz.JobPersistenceException
        Clear (delete!) all scheduling data - all IJobs, ITriggers ICalendars.
        Specified by:
        clearAllSchedulingData in interface com.helger.quartz.spi.IJobStore
        Throws:
        com.helger.quartz.JobPersistenceException - in case a nested call throws this
      • storeJobAndTrigger

        public void storeJobAndTrigger​(com.helger.quartz.IJobDetail aNewJob,
                                       com.helger.quartz.spi.IOperableTrigger aNewTrigger)
                                throws com.helger.quartz.JobPersistenceException
        Specified by:
        storeJobAndTrigger in interface com.helger.quartz.spi.IJobStore
        Throws:
        com.helger.quartz.JobPersistenceException
      • storeJob

        public void storeJob​(com.helger.quartz.IJobDetail aNewJob,
                             boolean bReplaceExisting)
                      throws com.helger.quartz.ObjectAlreadyExistsException
        Specified by:
        storeJob in interface com.helger.quartz.spi.IJobStore
        Throws:
        com.helger.quartz.ObjectAlreadyExistsException
      • removeJob

        public boolean removeJob​(com.helger.quartz.JobKey jobKey)
        Specified by:
        removeJob in interface com.helger.quartz.spi.IJobStore
      • removeJobs

        public boolean removeJobs​(@Nonnull
                                  List<com.helger.quartz.JobKey> jobKeys)
                           throws com.helger.quartz.JobPersistenceException
        Specified by:
        removeJobs in interface com.helger.quartz.spi.IJobStore
        Throws:
        com.helger.quartz.JobPersistenceException
      • removeTriggers

        public boolean removeTriggers​(@Nonnull
                                      List<com.helger.quartz.TriggerKey> triggerKeys)
                               throws com.helger.quartz.JobPersistenceException
        Specified by:
        removeTriggers in interface com.helger.quartz.spi.IJobStore
        Throws:
        com.helger.quartz.JobPersistenceException
      • storeJobsAndTriggers

        public void storeJobsAndTriggers​(Map<com.helger.quartz.IJobDetail,​Set<? extends com.helger.quartz.ITrigger>> aTriggersAndJobs,
                                         boolean bReplace)
                                  throws com.helger.quartz.JobPersistenceException
        Specified by:
        storeJobsAndTriggers in interface com.helger.quartz.spi.IJobStore
        Throws:
        com.helger.quartz.JobPersistenceException
      • storeTrigger

        public void storeTrigger​(@Nonnull
                                 com.helger.quartz.spi.IOperableTrigger aNewTrigger,
                                 boolean bReplaceExisting)
                          throws com.helger.quartz.JobPersistenceException
        Specified by:
        storeTrigger in interface com.helger.quartz.spi.IJobStore
        Throws:
        com.helger.quartz.JobPersistenceException
      • removeTrigger

        public boolean removeTrigger​(@Nonnull
                                     com.helger.quartz.TriggerKey triggerKey)

        Remove (delete) the ITrigger with the given name.

        Specified by:
        removeTrigger in interface com.helger.quartz.spi.IJobStore
        Returns:
        true if a Trigger with the given name and group was found and removed from the store.
      • replaceTrigger

        public boolean replaceTrigger​(com.helger.quartz.TriggerKey aTriggerKey,
                                      com.helger.quartz.spi.IOperableTrigger aNewTrigger)
                               throws com.helger.quartz.JobPersistenceException
        Specified by:
        replaceTrigger in interface com.helger.quartz.spi.IJobStore
        Throws:
        com.helger.quartz.JobPersistenceException
        See Also:
        IJobStore.replaceTrigger(TriggerKey triggerKey, IOperableTrigger newTrigger)
      • retrieveJob

        public com.helger.quartz.IJobDetail retrieveJob​(com.helger.quartz.JobKey jobKey)

        Retrieve the IJobDetail for the given IJob.

        Specified by:
        retrieveJob in interface com.helger.quartz.spi.IJobStore
        Returns:
        The desired Job, or null if there is no match.
      • retrieveTrigger

        public com.helger.quartz.spi.IOperableTrigger retrieveTrigger​(com.helger.quartz.TriggerKey triggerKey)

        Retrieve the given ITrigger.

        Specified by:
        retrieveTrigger in interface com.helger.quartz.spi.IJobStore
        Returns:
        The desired Trigger, or null if there is no match.
      • checkExists

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

        public boolean checkExists​(com.helger.quartz.TriggerKey aTriggerKey)
                            throws com.helger.quartz.JobPersistenceException
        Specified by:
        checkExists in interface com.helger.quartz.spi.IJobStore
        Throws:
        com.helger.quartz.JobPersistenceException
      • getTriggerState

        @Nonnull
        public com.helger.quartz.ITrigger.ETriggerState getTriggerState​(com.helger.quartz.TriggerKey triggerKey)
                                                                 throws com.helger.quartz.JobPersistenceException
        Specified by:
        getTriggerState in interface com.helger.quartz.spi.IJobStore
        Throws:
        com.helger.quartz.JobPersistenceException
      • storeCalendar

        public void storeCalendar​(String name,
                                  com.helger.quartz.ICalendar aCalendar,
                                  boolean bReplaceExisting,
                                  boolean bUpdateTriggers)
                           throws com.helger.quartz.ObjectAlreadyExistsException
        Specified by:
        storeCalendar in interface com.helger.quartz.spi.IJobStore
        Throws:
        com.helger.quartz.ObjectAlreadyExistsException
      • removeCalendar

        public boolean removeCalendar​(String calName)
                               throws com.helger.quartz.JobPersistenceException
        Specified by:
        removeCalendar in interface com.helger.quartz.spi.IJobStore
        Throws:
        com.helger.quartz.JobPersistenceException
      • retrieveCalendar

        public com.helger.quartz.ICalendar retrieveCalendar​(String calName)
        Specified by:
        retrieveCalendar in interface com.helger.quartz.spi.IJobStore
      • getNumberOfJobs

        public int getNumberOfJobs()
        Specified by:
        getNumberOfJobs in interface com.helger.quartz.spi.IJobStore
      • getNumberOfTriggers

        public int getNumberOfTriggers()
        Specified by:
        getNumberOfTriggers in interface com.helger.quartz.spi.IJobStore
      • getNumberOfCalendars

        public int getNumberOfCalendars()
        Specified by:
        getNumberOfCalendars in interface com.helger.quartz.spi.IJobStore
      • getJobKeys

        public com.helger.commons.collection.impl.ICommonsSet<com.helger.quartz.JobKey> getJobKeys​(com.helger.quartz.impl.matchers.GroupMatcher<com.helger.quartz.JobKey> matcher)
        Specified by:
        getJobKeys in interface com.helger.quartz.spi.IJobStore
      • getCalendarNames

        @Nonnull
        @ReturnsMutableCopy
        public com.helger.commons.collection.impl.ICommonsList<String> getCalendarNames()
        Specified by:
        getCalendarNames in interface com.helger.quartz.spi.IJobStore
      • getTriggerKeys

        public com.helger.commons.collection.impl.ICommonsSet<com.helger.quartz.TriggerKey> getTriggerKeys​(com.helger.quartz.impl.matchers.GroupMatcher<com.helger.quartz.TriggerKey> matcher)
        Specified by:
        getTriggerKeys in interface com.helger.quartz.spi.IJobStore
      • getJobGroupNames

        public com.helger.commons.collection.impl.ICommonsList<String> getJobGroupNames()
        Specified by:
        getJobGroupNames in interface com.helger.quartz.spi.IJobStore
      • getTriggerGroupNames

        public com.helger.commons.collection.impl.ICommonsList<String> getTriggerGroupNames()
        Specified by:
        getTriggerGroupNames in interface com.helger.quartz.spi.IJobStore
      • getTriggersForJob

        @Nonnull
        @ReturnsMutableCopy
        public com.helger.commons.collection.impl.ICommonsList<com.helger.quartz.spi.IOperableTrigger> getTriggersForJob​(com.helger.quartz.JobKey aJobKey)
        Specified by:
        getTriggersForJob in interface com.helger.quartz.spi.IJobStore
      • getTriggerWrappersForJob

        @Nonnull
        @ReturnsMutableCopy
        protected com.helger.commons.collection.impl.ICommonsList<com.helger.schedule.jobstore.TriggerWrapper> getTriggerWrappersForJob​(com.helger.quartz.JobKey aJobKey)
      • getTriggerWrappersForCalendar

        @Nonnull
        @ReturnsMutableCopy
        protected com.helger.commons.collection.impl.ICommonsList<com.helger.schedule.jobstore.TriggerWrapper> getTriggerWrappersForCalendar​(String calName)
      • pauseTrigger

        public void pauseTrigger​(com.helger.quartz.TriggerKey triggerKey)

        Pause the ITrigger with the given name.

        Specified by:
        pauseTrigger in interface com.helger.quartz.spi.IJobStore
      • pauseTriggers

        public com.helger.commons.collection.impl.ICommonsList<String> pauseTriggers​(com.helger.quartz.impl.matchers.GroupMatcher<com.helger.quartz.TriggerKey> matcher)
        Specified by:
        pauseTriggers in interface com.helger.quartz.spi.IJobStore
      • pauseJob

        public void pauseJob​(com.helger.quartz.JobKey jobKey)

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

        Specified by:
        pauseJob in interface com.helger.quartz.spi.IJobStore
      • pauseJobs

        public com.helger.commons.collection.impl.ICommonsList<String> pauseJobs​(com.helger.quartz.impl.matchers.GroupMatcher<com.helger.quartz.JobKey> matcher)

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

        The JobStore should "remember" that the group is paused, and impose the pause on any new jobs that are added to the group while the group is paused.

        Specified by:
        pauseJobs in interface com.helger.quartz.spi.IJobStore
      • resumeTrigger

        public void resumeTrigger​(com.helger.quartz.TriggerKey triggerKey)

        Resume (un-pause) the ITrigger with the given key.

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

        Specified by:
        resumeTrigger in interface com.helger.quartz.spi.IJobStore
      • resumeTriggers

        public com.helger.commons.collection.impl.ICommonsList<String> resumeTriggers​(com.helger.quartz.impl.matchers.GroupMatcher<com.helger.quartz.TriggerKey> matcher)
        Specified by:
        resumeTriggers in interface com.helger.quartz.spi.IJobStore
      • resumeJob

        public void resumeJob​(com.helger.quartz.JobKey jobKey)
        Specified by:
        resumeJob in interface com.helger.quartz.spi.IJobStore
      • resumeJobs

        public com.helger.commons.collection.impl.ICommonsCollection<String> resumeJobs​(com.helger.quartz.impl.matchers.GroupMatcher<com.helger.quartz.JobKey> matcher)
        Specified by:
        resumeJobs in interface com.helger.quartz.spi.IJobStore
      • pauseAll

        public void pauseAll()
        Specified by:
        pauseAll in interface com.helger.quartz.spi.IJobStore
      • resumeAll

        public void resumeAll()

        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 com.helger.quartz.spi.IJobStore
        See Also:
        pauseAll()
      • applyMisfire

        @MustBeLocked(WRITE)
        protected boolean applyMisfire​(com.helger.schedule.jobstore.TriggerWrapper tw)
      • getFiredTriggerRecordId

        protected String getFiredTriggerRecordId()
      • acquireNextTriggers

        public com.helger.commons.collection.impl.ICommonsList<com.helger.quartz.spi.IOperableTrigger> acquireNextTriggers​(long noLaterThan,
                                                                                                                           int maxCount,
                                                                                                                           long timeWindow)
        Specified by:
        acquireNextTriggers in interface com.helger.quartz.spi.IJobStore
      • releaseAcquiredTrigger

        public void releaseAcquiredTrigger​(com.helger.quartz.spi.IOperableTrigger trigger)

        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 com.helger.quartz.spi.IJobStore
      • triggersFired

        public com.helger.commons.collection.impl.ICommonsList<com.helger.quartz.spi.TriggerFiredResult> triggersFired​(List<com.helger.quartz.spi.IOperableTrigger> firedTriggers)

        Inform the JobStore that the scheduler is now firing the given Trigger (executing its associated Job), that it had previously acquired (reserved).

        Specified by:
        triggersFired in interface com.helger.quartz.spi.IJobStore
      • triggeredJobComplete

        public void triggeredJobComplete​(com.helger.quartz.spi.IOperableTrigger trigger,
                                         com.helger.quartz.IJobDetail jobDetail,
                                         com.helger.quartz.ITrigger.ECompletedExecutionInstruction triggerInstCode)
        Specified by:
        triggeredJobComplete in interface com.helger.quartz.spi.IJobStore
      • setAllTriggersOfJobToState

        @MustBeLocked(WRITE)
        protected void setAllTriggersOfJobToState​(com.helger.quartz.JobKey jobKey,
                                                  int state)
      • peekTriggers

        protected String peekTriggers()
      • getPausedTriggerGroups

        public com.helger.commons.collection.impl.ICommonsSet<String> getPausedTriggerGroups()
                                                                                      throws com.helger.quartz.JobPersistenceException
        Specified by:
        getPausedTriggerGroups in interface com.helger.quartz.spi.IJobStore
        Throws:
        com.helger.quartz.JobPersistenceException
        See Also:
        IJobStore.getPausedTriggerGroups()
      • setInstanceId

        public void setInstanceId​(String schedInstId)
        Specified by:
        setInstanceId in interface com.helger.quartz.spi.IJobStore
      • setInstanceName

        public void setInstanceName​(String schedName)
        Specified by:
        setInstanceName in interface com.helger.quartz.spi.IJobStore
      • setThreadPoolSize

        public void setThreadPoolSize​(int poolSize)
        Specified by:
        setThreadPoolSize in interface com.helger.quartz.spi.IJobStore
      • getEstimatedTimeToReleaseAndAcquireTrigger

        public long getEstimatedTimeToReleaseAndAcquireTrigger()
        Specified by:
        getEstimatedTimeToReleaseAndAcquireTrigger in interface com.helger.quartz.spi.IJobStore
      • isClustered

        public boolean isClustered()
        Specified by:
        isClustered in interface com.helger.quartz.spi.IJobStore