Class RAMJobStore

java.lang.Object
org.quartz.core.RAMJobStore
All Implemented Interfaces:
JobStore

public class RAMJobStore extends Object implements JobStore
This class implements a JobStore that utilizes RAM as its storage device.

As you should know, the ramification of this is that access is extremely fast, but the data is completely volatile - therefore this JobStore should not be used if true persistence between program shutdowns is required.

Author:
James House, Sharada Jambula, Eric Mueller
  • Constructor Details

    • RAMJobStore

      public RAMJobStore()
      Create a new RAMJobStore.
  • Method Details

    • initialize

      public void initialize(SchedulerSignaler signaler)
      Called by the QuartzScheduler before the JobStore is used, in order to give the it a chance to initialize.
      Specified by:
      initialize in interface JobStore
    • 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
    • getMisfireThreshold

      public long getMisfireThreshold()
    • setMisfireThreshold

      public void setMisfireThreshold(long misfireThreshold)
      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 -
    • storeJobAndTrigger

      public void storeJobAndTrigger(JobDetail newJob, OperableTrigger newTrigger) throws 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.
      ObjectAlreadyExistsException - if a Job with the same name/group already exists.
      JobPersistenceException
    • storeJob

      public void storeJob(JobDetail newJob, boolean replaceExisting) throws ObjectAlreadyExistsException
      Store the given Job.
      Specified by:
      storeJob in interface JobStore
      Parameters:
      newJob - The Job to be stored.
      replaceExisting - If true, any Job existing in the JobStore with the same name invalid input: '&' group should be over-written.
      Throws:
      ObjectAlreadyExistsException - if a Job with the same name/group already exists, and replaceExisting is set to false.
    • removeJob

      public boolean removeJob(String jobKey)
      Remove (delete) the Job with the given name, and any Trigger s that reference it.
      Specified by:
      removeJob in interface JobStore
      Returns:
      true if a Job with the given name invalid input: '&' group was found and removed from the store.
    • storeTrigger

      public void storeTrigger(OperableTrigger newTrigger, boolean replaceExisting) throws 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 invalid input: '&' group should be over-written.
      Throws:
      ObjectAlreadyExistsException - if a Trigger with the same name/group already exists, and replaceExisting is set to false.
      ObjectAlreadyExistsException - if a Trigger with the same name/group already exists, and replaceExisting is set to false.
      JobPersistenceException
      See Also:
      • invalid @see
        #pauseTriggerGroup(SchedulingContext, String)
    • removeTrigger

      public boolean removeTrigger(String triggerName)
      Description copied from interface: JobStore
      Remove (delete) the Trigger with the given key.

      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
      Returns:
      true if a Trigger with the given name was found and removed from the store.
    • replaceTrigger

      public boolean replaceTrigger(String triggerKey, OperableTrigger newTrigger) throws JobPersistenceException
      Description copied from interface: JobStore
      Remove (delete) the Trigger with the given key, and store the new given one - which must be associated with the same job.
      Specified by:
      replaceTrigger in interface JobStore
      Parameters:
      newTrigger - The new Trigger to be stored.
      Returns:
      true if a Trigger with the given name was found and removed from the store.
      Throws:
      JobPersistenceException
      See Also:
      • invalid @see
        org.quartz.core.JobStore#replaceTrigger(org.quartz.core.SchedulingContext, java.lang.String, java.lang.String, org.quartz.triggers.Trigger)
    • retrieveJob

      public JobDetail retrieveJob(String jobKey)
      Retrieve the JobDetail for the given Job.
      Specified by:
      retrieveJob in interface JobStore
      Returns:
      The desired Job, or null if there is no match.
    • retrieveTrigger

      public OperableTrigger retrieveTrigger(String triggerKey)
      Retrieve the given Trigger.
      Specified by:
      retrieveTrigger in interface JobStore
      Returns:
      The desired Trigger, or null if there is no match.
    • retrieveCalendar

      public Calendar retrieveCalendar(String calName)
      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.
    • getTriggersForJob

      public List<Trigger> getTriggersForJob(String jobKey)
      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
    • acquireNextTriggers

      public List<OperableTrigger> acquireNextTriggers(long noLaterThan, int maxCount, long timeWindow)
      Get a handle to the next trigger to be fired, and mark it as 'reserved' by the calling scheduler.
      Specified by:
      acquireNextTriggers in interface JobStore
      Parameters:
      noLaterThan - If > 0, the JobStore should only return a Trigger that will fire no later than the time represented in this value as milliseconds.
      See Also:
      • invalid @see
        #releaseAcquiredTrigger(SchedulingContext, Trigger)
    • releaseAcquiredTrigger

      public void releaseAcquiredTrigger(OperableTrigger 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 JobStore
    • triggersFired

      public List<TriggerFiredResult> triggersFired(List<OperableTrigger> triggers)
      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 JobStore
      Returns:
      may return null if all the triggers or their calendars no longer exist, or if the trigger was not successfully put into the 'executing' state. Preference is to return an empty list if none of the triggers could be fired.
    • triggeredJobComplete

      public void triggeredJobComplete(OperableTrigger trigger, JobDetail jobDetail, Trigger.CompletedExecutionInstruction 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.
      Specified by:
      triggeredJobComplete in interface JobStore
    • setThreadPoolSize

      public void setThreadPoolSize(int poolSize)
      Description copied from interface: JobStore
      Tells the JobStore the pool size used to execute jobs
      Specified by:
      setThreadPoolSize in interface JobStore
      Parameters:
      poolSize - amount of threads allocated for job execution
    • getJobKeys

      public Set<String> getJobKeys()
      Get the names of all of the Job s
      Specified by:
      getJobKeys in interface JobStore