public interface ClusteredJobDao
Although additional requirements may be specified on individual methods, implementations:
JobId is constrained as UNIQUE.| Modifier and Type | Method and Description |
|---|---|
boolean |
create(ClusteredJob clusteredJob)
Called to create a new clustered job in the database.
|
boolean |
delete(com.atlassian.scheduler.config.JobId jobId)
Called to remove a scheduled cluster job by its ID.
|
ClusteredJob |
find(com.atlassian.scheduler.config.JobId jobId)
Finds and returns the persisted details for a clustered job.
|
Set<com.atlassian.scheduler.config.JobRunnerKey> |
findAllJobRunnerKeys()
Returns the set of distinct job runner keys that have at least one job schedule stored here.
|
Collection<ClusteredJob> |
findByJobRunnerKey(com.atlassian.scheduler.config.JobRunnerKey jobRunnerKey)
Returns all jobs that use the given job runner.
|
Date |
getNextRunTime(com.atlassian.scheduler.config.JobId jobId)
Returns the next run time for the given job ID, if there is one.
|
Long |
getVersion(com.atlassian.scheduler.config.JobId jobId)
Returns the current version of the persisted clustered job with this ID.
|
Map<com.atlassian.scheduler.config.JobId,Date> |
refresh()
Returns the job ID and next run time for every clustered job that should be in the queue.
|
boolean |
updateNextRunTime(com.atlassian.scheduler.config.JobId jobId,
Date nextRunTime,
long expectedVersion)
Updates the next run time for an existing clustered job.
|
@Nullable Date getNextRunTime(com.atlassian.scheduler.config.JobId jobId)
Implementations MAY implement this with:
ClusteredJob clusteredJob = find(jobId);
return (clusteredJob != null) ? clusteredJob.getNextRunTime() : null;
However, this would be wasteful, and implementations SHOULD use a more efficient query when possible.
jobId - the job ID whose existence and current version is to be checkedjobId; null if no such job exists
or if it exists but its schedule prevents it from ever running again.@Nullable Long getVersion(com.atlassian.scheduler.config.JobId jobId)
Implementations MAY implement this with:
ClusteredJob clusteredJob = find(jobId);
return (clusteredJob != null) ? clusteredJob.getVersion() : null;
However, this would be wasteful, and implementations SHOULD use a more efficient query when possible.
jobId - the job ID whose existence and current version is to be checkedjobId, or null if no such job exists@Nullable ClusteredJob find(com.atlassian.scheduler.config.JobId jobId)
jobId - the job ID for the job details to be loadednull if the job does not exist@Nonnull Collection<ClusteredJob> findByJobRunnerKey(com.atlassian.scheduler.config.JobRunnerKey jobRunnerKey)
Implementations:
SELECT * FROM jobs WHERE jobRunnerKey = ?
to retrieve all job details that match the given jobRunnerKey.ClusteredJob for each clustered job that has been persisted
with the specified jobRunnerKey.jobRunnerKey - the job runner key for which to search@Nonnull Map<com.atlassian.scheduler.config.JobId,Date> refresh()
Implementations:
SELECT jobId, nextRunTime FROM jobs WHERE nextRunTime IS NOT NULL to retrieve all
existing job IDs that have scheduled next time to run.null for any entry in the
returned map.@Nonnull Set<com.atlassian.scheduler.config.JobRunnerKey> findAllJobRunnerKeys()
Implementations:
SELECT DISTINCT jobRunnerKey FROM jobs
to retrieve all unique job runner keys.nextRunTime is null or not.boolean create(ClusteredJob clusteredJob)
Implementations:
INSERT INTO jobs ... VALUES ...
to create a representation of this job.false rather than throw an exception if the request fails
due to a UNIQUE constraintSELECT for a conflicting
entry if the persistence layer does not make it possible to distinguish UNIQUE constraint
failures reliably.clusteredJob - the job details to be createdboolean updateNextRunTime(com.atlassian.scheduler.config.JobId jobId,
@Nullable
Date nextRunTime,
long expectedVersion)
Implementations:
UPDATE jobs SET nextRunTime = ?, version = ? WHERE jobId = ? AND version = ?false if no rows are updated, whether because the job does not
exist or because the specified version is incorrect.jobId - the job ID for which to update the next run timenextRunTime - the new next run time, or null if it will never run againexpectedVersion - the version of the job details that are expected to be foundtrue if the update is successful; false otherwiseboolean delete(com.atlassian.scheduler.config.JobId jobId)
Implementations:
DELETE FROM jobs WHERE jobId = ?false if there is no matching row to delete; note that this
is not an error and the implementation MUST NOT throw an exception for itjobId - the job to be unscheduledtrue if the job is successfully removed; false, otherwiseCopyright © 2019 Atlassian. All rights reserved.