Class ResourcelessJobRepository
- All Implemented Interfaces:
JobRepository
JobRepository implementation that does not use or store batch meta-data. It
is intended for use-cases where restartability is not required and where the execution
context is not involved in any way (like sharing data between steps through the
execution context, or partitioned steps where partitions meta-data is shared between
the manager and workers through the execution context, etc). This implementation holds a single job instance and a corresponding job execution that are suitable for one-time jobs executed in their own JVM. This job repository works with transactional steps as well as non-transactional steps (in which case, a
ResourcelessTransactionManager can be used). This implementation is not thread-safe and should not be used in any concurrent environment.
- Since:
- 5.2.0
- Author:
- Mahmoud Ben Hassine
-
Constructor Summary
Constructors -
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.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.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.batch.core.repository.JobRepository
deleteJobExecution, deleteJobInstance, deleteStepExecution, findJobExecutions, findJobInstancesByName, getJobInstance, getJobNames
-
Constructor Details
-
ResourcelessJobRepository
public ResourcelessJobRepository()
-
-
Method Details
-
isJobInstanceExists
Description copied from interface:JobRepositoryCheck if an instance of this job already exists with the parameters provided.- Specified by:
isJobInstanceExistsin interfaceJobRepository- 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
Description copied from interface:JobRepositoryCreate a newJobInstancewith the name and job parameters provided.- Specified by:
createJobInstancein interfaceJobRepository- Parameters:
jobName- logical name of the jobjobParameters- parameters used to execute the job- Returns:
- the new
JobInstance
-
createJobExecution
Description copied from interface:JobRepositoryCreate 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).- Specified by:
createJobExecutionin interfaceJobRepository- 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
-
update
Description copied from interface:JobRepositoryUpdate theJobExecution(but not itsExecutionContext).Preconditions:
JobExecutionmust contain a validJobInstanceand be saved (have an id assigned).- Specified by:
updatein interfaceJobRepository- Parameters:
jobExecution-JobExecutioninstance to be updated in the repo.
-
add
Description copied from interface:JobRepositorySave 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.- Specified by:
addin interfaceJobRepository- Parameters:
stepExecution-StepExecutioninstance to be added to the repo.
-
addAll
Description copied from interface:JobRepositorySave 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.- Specified by:
addAllin interfaceJobRepository- Parameters:
stepExecutions- collection ofStepExecutioninstances to be added to the repo.
-
update
Description copied from interface:JobRepositoryUpdate theStepExecution(but not itsExecutionContext).Preconditions:
StepExecutionmust be saved (have an id assigned).- Specified by:
updatein interfaceJobRepository- Parameters:
stepExecution-StepExecutioninstance to be updated in the repo.
-
updateExecutionContext
Description copied from interface:JobRepositoryPersist the updatedExecutionContexts of the givenStepExecution.- Specified by:
updateExecutionContextin interfaceJobRepository- Parameters:
stepExecution-StepExecutioninstance to be used to update the context.
-
updateExecutionContext
Description copied from interface:JobRepositoryPersist the updatedExecutionContextof the givenJobExecution.- Specified by:
updateExecutionContextin interfaceJobRepository- Parameters:
jobExecution-JobExecutioninstance to be used to update the context.
-
getLastStepExecution
- Specified by:
getLastStepExecutionin interfaceJobRepository- 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
- Specified by:
getStepExecutionCountin interfaceJobRepository- 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
- Specified by:
getLastJobExecutionin interfaceJobRepository- Parameters:
jobName- the name of the job that might have runjobParameters- parameters identifying theJobInstance- Returns:
- the last execution of job if exists, null otherwise
-