Class CachedScheduledJobDao
- java.lang.Object
-
- com.atlassian.confluence.schedule.persistence.dao.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 Summary
Fields Modifier and Type Field Description static String
CONFIGURATION_CONTEXT_KEY
-
Constructor Summary
Constructors Constructor Description CachedScheduledJobDao(com.atlassian.cache.CacheFactory cacheFactory, com.atlassian.bandana.BandanaManager bandanaManager)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addHistory(com.atlassian.scheduler.config.JobId jobId, @Nullable ScheduledJobHistory history, Date nextOccurrence)
Adds to an event to the history to the cache, and updates the nextOccurrence in the ScheduledJobStatus.@Nullable ScheduledJobConfiguration
getScheduledJobConfiguration(com.atlassian.scheduler.config.JobId jobId)
Gets the job configuration for the specified job.@Nullable ScheduledJobStatus
getScheduledJobStatus(com.atlassian.scheduler.config.JobId jobId)
Gets the specified job's status.void
saveScheduledJobConfiguration(com.atlassian.scheduler.config.JobId jobId, ScheduledJobConfiguration job)
Stores the job configuration.void
saveScheduledJobStatus(com.atlassian.scheduler.config.JobId jobId, ScheduledJobStatus status)
Stores the status for the specified job.void
updateNextOccurrence(com.atlassian.scheduler.config.JobId jobId, Date nextOccurrence)
Updates the nextOccurrence in the ScheduledJobStatus.void
updateStatus(com.atlassian.scheduler.config.JobId jobId, ExecutionStatus status)
Updates the status in the corresponding ScheduledJobStatus for the job.
-
-
-
Field Detail
-
CONFIGURATION_CONTEXT_KEY
public static final String CONFIGURATION_CONTEXT_KEY
-
-
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 interfaceScheduledJobDao
- 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 interfaceScheduledJobDao
- Parameters:
jobId
- the job IDstatus
- 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 interfaceScheduledJobDao
- Parameters:
jobId
- the job IDhistory
- the event that occurrednextOccurrence
- 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 interfaceScheduledJobDao
-
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 interfaceScheduledJobDao
- Parameters:
jobId
- the job IDnextOccurrence
- the date that the job is expected to execute next
-
saveScheduledJobConfiguration
public void saveScheduledJobConfiguration(com.atlassian.scheduler.config.JobId jobId, ScheduledJobConfiguration job)
Description copied from interface:ScheduledJobDao
Stores the job configuration.- Specified by:
saveScheduledJobConfiguration
in interfaceScheduledJobDao
- Parameters:
jobId
- the job IDjob
- the configuration
-
getScheduledJobConfiguration
public @Nullable ScheduledJobConfiguration getScheduledJobConfiguration(com.atlassian.scheduler.config.JobId jobId)
Description copied from interface:ScheduledJobDao
Gets the job configuration for the specified job.- Specified by:
getScheduledJobConfiguration
in interfaceScheduledJobDao
- Parameters:
jobId
- the job ID- Returns:
- null if not found.
-
-