Package net.solarnetwork.central.dao
Interface ClaimableJobDao<C,R,S extends ClaimableJobState,T extends ClaimableJob<C,R,S,PK>,PK extends Serializable>
- Type Parameters:
C- the job configuration typeR- the job result typeS- the job state typeT- the job entity typePK- the job entity primary key type
public interface ClaimableJobDao<C,R,S extends ClaimableJobState,T extends ClaimableJob<C,R,S,PK>,PK extends Serializable>
DAO API for
ClaimableJob entities.- Since:
- 1.44
-
Method Summary
Modifier and TypeMethodDescriptionClaim a queued job.longpurgeOldJobs(Instant olderThanDate) Purge old jobs.booleanupdateJobConfiguration(PK id, C configuration) Update the configuration for a specific job.booleanupdateJobProgress(PK id, double percentComplete, R result) Update the progress of a specific job.booleanupdateJobState(PK id, S desiredState, Set<S> expectedStates) Update the state of a specific job.
-
Method Details
-
claimQueuedJob
T claimQueuedJob()Claim a queued job. This method will "claim" a job that is currently in a "queued" state, changing the state to "claimed".- Returns:
- a claimed job, or null if none could be claimed
-
purgeOldJobs
Purge old jobs.This method will delete jobs that have reached a "completed" state and whose completion date is older than a given date. It might also delete jobs that are in other, implementation specific, states that meet some implementation specific criteria allowing them to be purged.
- Parameters:
olderThanDate- the maximum date for which to purge old jobs- Returns:
- the number of jobs deleted
-
updateJobState
Update the state of a specific job.- Parameters:
id- the ID of the job to updatedesiredState- the state to change the job toexpectedStates- a set of states that must include the job's current state in order to change it todesiredState, or null if the current state of the job does not matter- Returns:
- true if the job state was changed
-
updateJobConfiguration
Update the configuration for a specific job.The configuration update might be ignored if the job is not in a re-configurable state, e.g. it is "claimed" or "executing".
- Parameters:
id- the ID of the job to updateconfiguration- the configuration to save with the job, completely replacing any existing configuration- Returns:
- true if the job configuration was changed
-
updateJobProgress
Update the progress of a specific job.- Parameters:
id- the ID of the job to updatepercentComplete- the percent complete, from 0 to 1result- the result- Returns:
- true if the job progress was updated
-