Interface JobRepository

All Superinterfaces:
JobExplorer
All Known Implementing Classes:
ResourcelessJobRepository, SimpleJobRepository

public interface JobRepository extends JobExplorer

Repository responsible for persistence of batch meta-data entities.

Author:
Lucas Ward, Dave Syer, Robert Kasanicky, David Turanski, Michael Minella, Mahmoud Ben Hassine, Parikshit Dutta
See Also:
  • Method Details

    • getJobNames

      default List<String> getJobNames()
      Query the repository for all unique JobInstance names (sorted alphabetically).
      Specified by:
      getJobNames in interface JobExplorer
      Returns:
      the list of job names that have been executed.
    • getJobInstances

      default List<JobInstance> getJobInstances(String jobName, int start, int count)
      Fetch JobInstance values in descending order of creation (and, therefore, usually, of first execution).
      Specified by:
      getJobInstances in interface JobExplorer
      Parameters:
      jobName - The name of the job to query.
      start - The start index of the instances to return.
      count - The maximum number of instances to return.
      Returns:
      the JobInstance values up to a maximum of count values.
    • findJobInstances

      default List<JobInstance> findJobInstances(String jobName)
      Fetch all JobInstance values for a given job name.
      Parameters:
      jobName - The name of the job.
      Returns:
      the JobInstance values.
      Since:
      6.0
    • getJobInstance

      default @Nullable JobInstance getJobInstance(long jobInstanceId)
      Specified by:
      getJobInstance in interface JobExplorer
      Parameters:
      jobInstanceId - The ID for the JobInstance to obtain.
      Returns:
      the JobInstance that has this ID, or null if not found.
    • getLastJobInstance

      default @Nullable JobInstance getLastJobInstance(String jobName)
      Find the last job instance, by ID, for the given job.
      Specified by:
      getLastJobInstance in interface JobExplorer
      Parameters:
      jobName - The name of the job.
      Returns:
      the last job instance by Id if any or null otherwise.
      Since:
      4.2
    • getJobInstance

      default @Nullable JobInstance getJobInstance(String jobName, JobParameters jobParameters)
      Specified by:
      getJobInstance in interface JobExplorer
      Parameters:
      jobName - String name of the job.
      jobParameters - JobParameters parameters for the job instance.
      Returns:
      the JobInstance with the given name and parameters, or null.
      Since:
      5.0
    • getJobInstanceCount

      default long getJobInstanceCount(String jobName) throws NoSuchJobException
      Query the repository for the number of unique JobInstance objects associated with the supplied job name.
      Specified by:
      getJobInstanceCount in interface JobExplorer
      Parameters:
      jobName - The name of the job for which to query.
      Returns:
      the number of JobInstances that exist within the associated job repository.
      Throws:
      NoSuchJobException - thrown when there is no JobInstance for the jobName specified.
    • getJobExecution

      default @Nullable JobExecution getJobExecution(long executionId)
      Retrieve a JobExecution by its ID. The complete object graph for this execution should be returned (unless otherwise indicated), including the parent JobInstance and associated ExecutionContext and StepExecution instances (also including their execution contexts).
      Specified by:
      getJobExecution in interface JobExplorer
      Parameters:
      executionId - The job execution ID.
      Returns:
      the JobExecution that has this ID or null if not found.
    • getJobExecutions

      default List<JobExecution> getJobExecutions(JobInstance jobInstance)
      Retrieve job executions by their job instance. The corresponding step executions may not be fully hydrated (for example, their execution context may be missing), depending on the implementation. In that case, use getStepExecution(long) to hydrate them.
      Specified by:
      getJobExecutions in interface JobExplorer
      Parameters:
      jobInstance - The JobInstance to query.
      Returns:
      the list of all executions for the specified JobInstance.
    • getLastJobExecution

      default @Nullable JobExecution getLastJobExecution(JobInstance jobInstance)
      Find the last JobExecution that has been created for a given JobInstance.
      Specified by:
      getLastJobExecution in interface JobExplorer
      Parameters:
      jobInstance - The JobInstance for which to find the last JobExecution.
      Returns:
      the last JobExecution that has been created for this instance or null if no job execution is found for the given job instance.
      Since:
      4.2
    • getLastJobExecution

      default @Nullable JobExecution getLastJobExecution(String jobName, JobParameters jobParameters)
      Specified by:
      getLastJobExecution in interface JobExplorer
      Parameters:
      jobName - the name of the job that might have run
      jobParameters - parameters identifying the JobInstance
      Returns:
      the last execution of job if exists, null otherwise
    • findRunningJobExecutions

      default Set<JobExecution> findRunningJobExecutions(String jobName)
      Retrieve running job executions. The corresponding step executions may not be fully hydrated (for example, their execution context may be missing), depending on the implementation. In that case, use getStepExecution(long) to hydrate them.
      Specified by:
      findRunningJobExecutions in interface JobExplorer
      Parameters:
      jobName - The name of the job.
      Returns:
      the set of running executions for jobs with the specified name.
    • getStepExecution

      @Deprecated(since="6.0", forRemoval=true) default @Nullable StepExecution getStepExecution(long jobExecutionId, long stepExecutionId)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 6.0 in favor of getStepExecution(long)
      Retrieve a StepExecution by its ID and parent JobExecution ID. The execution context for the step should be available in the result, and the parent job execution should have its primitive properties, but it may not contain the job instance information.
      Specified by:
      getStepExecution in interface JobExplorer
      Parameters:
      jobExecutionId - The parent job execution ID.
      stepExecutionId - The step execution ID.
      Returns:
      the StepExecution that has this ID or null if not found.
      See Also:
    • getStepExecution

      default @Nullable StepExecution getStepExecution(long stepExecutionId)
      Retrieve a StepExecution by its ID. The execution context for the step should be available in the result, and the parent job execution should have its primitive properties, but it may not contain the job instance information.
      Parameters:
      stepExecutionId - The step execution ID.
      Returns:
      the StepExecution that has this ID or null if not found.
      Since:
      6.0
    • getLastStepExecution

      default @Nullable StepExecution getLastStepExecution(JobInstance jobInstance, String stepName)
      Specified by:
      getLastStepExecution in interface JobExplorer
      Parameters:
      jobInstance - JobInstance instance containing the step executions.
      stepName - the name of the step execution that might have run.
      Returns:
      the last execution of step for the given job instance.
    • getStepExecutionCount

      default long getStepExecutionCount(JobInstance jobInstance, String stepName) throws NoSuchStepException
      Specified by:
      getStepExecutionCount in interface JobExplorer
      Parameters:
      jobInstance - JobInstance instance containing the step executions.
      stepName - the name of the step execution that might have run.
      Returns:
      the execution count of the step within the given job instance.
      Throws:
      NoSuchStepException
    • createJobInstance

      JobInstance createJobInstance(String jobName, JobParameters jobParameters)
      Create a new JobInstance with the name and job parameters provided.
      Parameters:
      jobName - logical name of the job
      jobParameters - parameters used to execute the job
      Returns:
      the new JobInstance
    • deleteJobInstance

      default void deleteJobInstance(JobInstance jobInstance)
      Delete the job instance object graph (ie the job instance with all associated job executions along with their respective object graphs as specified in deleteJobExecution(JobExecution)).
      Parameters:
      jobInstance - the job instance to delete
      Since:
      5.0
    • createJobExecution

      default JobExecution createJobExecution(JobInstance jobInstance, JobParameters jobParameters, ExecutionContext executionContext)
      Create a JobExecution for a given JobInstance, JobParameters and ExecutionContext. The JobInstance must already exist. The returned JobExecution will be associated with the JobInstance (ie. should be added to the list of JobInstance.getJobExecutions().
      Parameters:
      jobInstance - the job instance to which the execution belongs
      jobParameters - the runtime parameters for the job
      executionContext - the execution context to associate with the job execution
      Returns:
      a valid JobExecution for the arguments provided
      Since:
      6.0
    • update

      void update(JobExecution jobExecution)
      Update the JobExecution (but not its ExecutionContext).

      Preconditions: JobExecution must contain a valid JobInstance and be saved (have an id assigned).

      Parameters:
      jobExecution - JobExecution instance to be updated in the repo.
    • updateExecutionContext

      void updateExecutionContext(JobExecution jobExecution)
      Persist the updated ExecutionContext of the given JobExecution.
      Parameters:
      jobExecution - JobExecution instance to be used to update the context.
    • deleteJobExecution

      default void deleteJobExecution(JobExecution jobExecution)
      Delete the job execution object graph (ie the job execution with its execution context, all related step executions and their executions contexts, as well as associated job parameters)
      Parameters:
      jobExecution - the job execution to delete
      Since:
      5.0
    • createStepExecution

      default StepExecution createStepExecution(String stepName, JobExecution jobExecution)
      Create a StepExecution for a given JobExecution and step name. The JobExecution must already exist. The returned StepExecution should be associated with the JobExecution (ie. should be added to the list of JobExecution.getStepExecutions().
      Parameters:
      stepName - the name of the step
      jobExecution - the job execution to which the step execution belongs
      Returns:
      a valid StepExecution for the arguments provided
      Since:
      6.0
    • update

      void update(StepExecution stepExecution)
      Update the StepExecution (but not its ExecutionContext).

      Preconditions: StepExecution must be saved (have an id assigned).

      Parameters:
      stepExecution - StepExecution instance to be updated in the repo.
    • updateExecutionContext

      void updateExecutionContext(StepExecution stepExecution)
      Persist the updated ExecutionContexts of the given StepExecution.
      Parameters:
      stepExecution - StepExecution instance to be used to update the context.
    • deleteStepExecution

      default void deleteStepExecution(StepExecution stepExecution)
      Delete the step execution along with its execution context.
      Parameters:
      stepExecution - the step execution to delete
      Since:
      5.0