Interface ClaimableJobDao<C,R,S extends ClaimableJobState,T extends ClaimableJob<C,R,S,PK>,PK extends Serializable>

Type Parameters:
C - the job configuration type
R - the job result type
S - the job state type
T - the job entity type
PK - 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 Type
    Method
    Description
    Claim a queued job.
    long
    purgeOldJobs(Instant olderThanDate)
    Purge old jobs.
    boolean
    updateJobConfiguration(PK id, C configuration)
    Update the configuration for a specific job.
    boolean
    updateJobProgress(PK id, double percentComplete, R result)
    Update the progress of a specific job.
    boolean
    updateJobState(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

      long purgeOldJobs(Instant olderThanDate)
      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

      boolean updateJobState(PK id, S desiredState, Set<S> expectedStates)
      Update the state of a specific job.
      Parameters:
      id - the ID of the job to update
      desiredState - the state to change the job to
      expectedStates - a set of states that must include the job's current state in order to change it to desiredState, or null if the current state of the job does not matter
      Returns:
      true if the job state was changed
    • updateJobConfiguration

      boolean updateJobConfiguration(PK id, C configuration)
      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 update
      configuration - the configuration to save with the job, completely replacing any existing configuration
      Returns:
      true if the job configuration was changed
    • updateJobProgress

      boolean updateJobProgress(PK id, double percentComplete, R result)
      Update the progress of a specific job.
      Parameters:
      id - the ID of the job to update
      percentComplete - the percent complete, from 0 to 1
      result - the result
      Returns:
      true if the job progress was updated