Class CachedScheduledJobDao

  • All Implemented Interfaces:
    ScheduledJobDao

    public class CachedScheduledJobDao
    extends Object
    implements ScheduledJobDao
    Provides an implementation for storing data used by the ScheduledJobManager.

    Runtime/transient data is stored into Cache's (either ehcache or coherence caches) for quick access. The caches do not expire, and are sufficiently large not to fill up. There is currently no checking if they are full, and this will cause issues if this occurs. Use of cache's will allow the data to be synchronised across cluster nodes by coherence.

    Runtime/transient data includes the scheduled job status, and the default cron expressions.

    Persistent data is stored into Bandana, it's not intended to be used for high-frequency updates.

    Persistent data includes persisted history (when enabled), and the job configuration (changed cron expression, enabled/disabled flag).

    • Field Detail

      • CONFIGURATION_CONTEXT_KEY

        public static final String CONFIGURATION_CONTEXT_KEY
    • Constructor Detail

      • CachedScheduledJobDao

        public CachedScheduledJobDao​(com.atlassian.cache.CacheFactory cacheFactory,
                                     com.atlassian.bandana.BandanaManager bandanaManager)
        Since:
        7.20
    • Method Detail

      • getScheduledJobStatus

        public @Nullable ScheduledJobStatus getScheduledJobStatus​(com.atlassian.scheduler.config.JobId jobId)
        Description copied from interface: ScheduledJobDao
        Gets the specified job's status.

        It's recommended that ScheduledJobStatusManager be used for access to a job's status, rather than this call directly. The manager handles cache expiry automatically.

        Specified by:
        getScheduledJobStatus in interface ScheduledJobDao
        Parameters:
        jobId - the job ID
        Returns:
        null if the job does not exist, or the status has expired from the cache.
      • saveScheduledJobStatus

        public void saveScheduledJobStatus​(com.atlassian.scheduler.config.JobId jobId,
                                           ScheduledJobStatus status)
        Description copied from interface: ScheduledJobDao
        Stores the status for the specified job.
        Specified by:
        saveScheduledJobStatus in interface ScheduledJobDao
        Parameters:
        jobId - the job ID
        status - stores the job status.
      • addHistory

        public void addHistory​(com.atlassian.scheduler.config.JobId jobId,
                               @Nullable ScheduledJobHistory history,
                               Date nextOccurrence)
        Description copied from interface: ScheduledJobDao
        Adds to an event to the history to the cache, and updates the nextOccurrence in the ScheduledJobStatus.
        Specified by:
        addHistory in interface ScheduledJobDao
        Parameters:
        jobId - the job ID
        history - the event that occurred
        nextOccurrence - the date that the job is expected to execute next
      • updateStatus

        public void updateStatus​(com.atlassian.scheduler.config.JobId jobId,
                                 ExecutionStatus status)
        Description copied from interface: ScheduledJobDao
        Updates the status in the corresponding ScheduledJobStatus for the job.

        {link #saveScheduledJobStatus} should be called first, otherwise the update will be ignored.

        Specified by:
        updateStatus in interface ScheduledJobDao
      • updateNextOccurrence

        public void updateNextOccurrence​(com.atlassian.scheduler.config.JobId jobId,
                                         Date nextOccurrence)
        Description copied from interface: ScheduledJobDao
        Updates the nextOccurrence in the ScheduledJobStatus.
        Specified by:
        updateNextOccurrence in interface ScheduledJobDao
        Parameters:
        jobId - the job ID
        nextOccurrence - the date that the job is expected to execute next