Interface JobRepository
- All Known Implementing Classes:
SimpleJobRepository
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 Summary
Modifier and TypeMethodDescriptionvoidadd(StepExecution stepExecution) Save theStepExecutionand itsExecutionContext.voidaddAll(Collection<StepExecution> stepExecutions) Save a collection ofStepExecutions and eachExecutionContext.createJobExecution(String jobName, JobParameters jobParameters) createJobInstance(String jobName, JobParameters jobParameters) Create a newJobInstancewith the name and job parameters provided.default voiddeleteJobExecution(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)default voiddeleteJobInstance(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 indeleteJobExecution(JobExecution)).default voiddeleteStepExecution(StepExecution stepExecution) Delete the step execution along with its execution context.default List<JobExecution>findJobExecutions(JobInstance jobInstance) Return allJobExecutions for givenJobInstance, sorted backwards by creation order (so the first element is the most recent).default List<JobInstance>findJobInstancesByName(String jobName, int start, int count) Fetch the last job instances with the provided name, sorted backwards by primary key, using a 'like' criteriadefault JobInstancegetJobInstance(String jobName, JobParameters jobParameters) Retrieve the names of all job instances sorted alphabetically - i.e.getLastJobExecution(String jobName, JobParameters jobParameters) getLastStepExecution(JobInstance jobInstance, String stepName) longgetStepExecutionCount(JobInstance jobInstance, String stepName) booleanisJobInstanceExists(String jobName, JobParameters jobParameters) Check if an instance of this job already exists with the parameters provided.voidupdate(JobExecution jobExecution) Update theJobExecution(but not itsExecutionContext).voidupdate(StepExecution stepExecution) Update theStepExecution(but not itsExecutionContext).voidupdateExecutionContext(JobExecution jobExecution) Persist the updatedExecutionContextof the givenJobExecution.voidupdateExecutionContext(StepExecution stepExecution) Persist the updatedExecutionContexts of the givenStepExecution.
-
Method Details
-
getJobNames
Retrieve the names of all job instances sorted alphabetically - i.e. jobs that have ever been executed.- Returns:
- the names of all job instances
- Since:
- 5.0
-
findJobInstancesByName
Fetch the last job instances with the provided name, sorted backwards by primary key, using a 'like' criteria- Parameters:
jobName-Stringcontaining the name of the job.start- int containing the offset of where list of job instances results should begin.count- int containing the number of job instances to return.- Returns:
- a list of
JobInstancefor the job name requested. - Since:
- 5.0
-
findJobExecutions
Return allJobExecutions for givenJobInstance, sorted backwards by creation order (so the first element is the most recent).- Parameters:
jobInstance- parentJobInstanceof theJobExecutions to find.- Returns:
Listcontaining JobExecutions for the jobInstance.- Since:
- 5.0
-
isJobInstanceExists
Check if an instance of this job already exists with the parameters provided.- Parameters:
jobName- the name of the jobjobParameters- the parameters to match- Returns:
- true if a
JobInstancealready exists for this job name and job parameters
-
createJobInstance
Create a newJobInstancewith the name and job parameters provided.- Parameters:
jobName- logical name of the jobjobParameters- parameters used to execute the job- Returns:
- the new
JobInstance
-
createJobExecution
JobExecution createJobExecution(String jobName, JobParameters jobParameters) throws JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException Create a
JobExecutionfor a givenJobandJobParameters. If matchingJobInstancealready exists, the job must be restartable and it's last JobExecution must *not* be completed. If matchingJobInstancedoes not exist yet it will be created.If this method is run in a transaction (as it normally would be) with isolation level at
Isolation.REPEATABLE_READor better, then this method should block if another transaction is already executing it (for the sameJobParametersand job name). The first transaction to complete in this scenario obtains a validJobExecution, and others throwJobExecutionAlreadyRunningException(or timeout). There are no such guarantees if theJobInstanceDaoandJobExecutionDaodo not respect the transaction isolation levels (e.g. if using a non-relational data-store, or if the platform does not support the higher isolation levels).- Parameters:
jobName- the name of the job that is to be executedjobParameters- the runtime parameters for the job- Returns:
- a valid
JobExecutionfor the arguments provided - Throws:
JobExecutionAlreadyRunningException- if there is aJobExecutionalready running for the job instance with the provided job and parameters.JobRestartException- if one or more existingJobInstances is found with the same parameters andJob.isRestartable()is false.JobInstanceAlreadyCompleteException- if aJobInstanceis found and was already completed successfully.
-
update
Update theJobExecution(but not itsExecutionContext). Preconditions:JobExecutionmust contain a validJobInstanceand be saved (have an id assigned).- Parameters:
jobExecution-JobExecutioninstance to be updated in the repo.
-
add
Save theStepExecutionand itsExecutionContext. ID will be assigned - it is not permitted that an ID be assigned before calling this method. Instead, it should be left blank, to be assigned by aJobRepository. Preconditions:StepExecutionmust have a validStep.- Parameters:
stepExecution-StepExecutioninstance to be added to the repo.
-
addAll
Save a collection ofStepExecutions and eachExecutionContext. The StepExecution ID will be assigned - it is not permitted that an ID be assigned before calling this method. Instead, it should be left blank, to be assigned byJobRepository. Preconditions:StepExecutionmust have a validStep.- Parameters:
stepExecutions- collection ofStepExecutioninstances to be added to the repo.
-
update
Update theStepExecution(but not itsExecutionContext). Preconditions:StepExecutionmust be saved (have an id assigned).- Parameters:
stepExecution-StepExecutioninstance to be updated in the repo.
-
updateExecutionContext
Persist the updatedExecutionContexts of the givenStepExecution.- Parameters:
stepExecution-StepExecutioninstance to be used to update the context.
-
updateExecutionContext
Persist the updatedExecutionContextof the givenJobExecution.- Parameters:
jobExecution-JobExecutioninstance to be used to update the context.
-
getJobInstance
- Parameters:
jobName-Stringname of the job.jobParameters-JobParametersparameters for the job instance.- Returns:
- the
JobInstancewith the given name and parameters, ornull. - Since:
- 5.0
-
getLastStepExecution
- Parameters:
jobInstance-JobInstanceinstance 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
- Parameters:
jobInstance-JobInstanceinstance 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.
-
getLastJobExecution
- Parameters:
jobName- the name of the job that might have runjobParameters- parameters identifying theJobInstance- Returns:
- the last execution of job if exists, null otherwise
-
deleteStepExecution
Delete the step execution along with its execution context.- Parameters:
stepExecution- the step execution to delete- Since:
- 5.0
-
deleteJobExecution
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
-
deleteJobInstance
Delete the job instance object graph (ie the job instance with all associated job executions along with their respective object graphs as specified indeleteJobExecution(JobExecution)).- Parameters:
jobInstance- the job instance to delete- Since:
- 5.0
-