类 SimpleJobOperator
- java.lang.Object
- org.springframework.batch.core.launch.support.SimpleJobOperator
- 所有已实现的接口:
JobOperator
,org.springframework.beans.factory.InitializingBean
public class SimpleJobOperator extends java.lang.Object implements JobOperator, org.springframework.beans.factory.InitializingBean
Simple implementation of the JobOperator interface. Due to the amount of functionality the implementation is combining, the following dependencies are required:- 从以下版本开始:
- 2.0
- 作者:
- Dave Syer, Lucas Ward, Will Schipp, Mahmoud Ben Hassine
构造器概要
构造器 构造器 说明 SimpleJobOperator()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 JobExecution
abandon(long jobExecutionId)
Mark theJobExecution
as ABANDONED.void
afterPropertiesSet()
Check mandatory properties.java.util.List<java.lang.Long>
getExecutions(long instanceId)
List theJobExecutions
associated with a particularJobInstance
, in reverse order of creation (and therefore usually of execution).java.util.List<java.lang.Long>
getJobInstances(java.lang.String jobName, int start, int count)
List theJobInstances
for a given job name, in reverse order of creation (and therefore usually of first execution).java.util.Set<java.lang.String>
getJobNames()
List the available job names that can be launched withJobOperator.start(String, String)
.java.lang.String
getParameters(long executionId)
Get theJobParameters
as an easily readable String.java.util.Set<java.lang.Long>
getRunningExecutions(java.lang.String jobName)
Get the id values of all the runningJobExecutions
with the given job name.java.util.Map<java.lang.Long,java.lang.String>
getStepExecutionSummaries(long executionId)
Summarise theStepExecution
instances belonging to theJobExecution
with the supplied id, giving details of status, start and end times etc.java.lang.String
getSummary(long executionId)
Summarise theJobExecution
with the supplied id, giving details of status, start and end times etc.java.lang.Long
restart(long executionId)
Restart a failed or stoppedJobExecution
.void
setJobExplorer(JobExplorer jobExplorer)
Public setter for theJobExplorer
.void
setJobLauncher(JobLauncher jobLauncher)
Public setter for theJobLauncher
.void
setJobParametersConverter(JobParametersConverter jobParametersConverter)
Public setter for theJobParametersConverter
.void
setJobRegistry(ListableJobLocator jobRegistry)
Public setter for theListableJobLocator
.void
setJobRepository(JobRepository jobRepository)
java.lang.Long
start(java.lang.String jobName, java.lang.String parameters)
Start a new instance of a job with the parameters specified.java.lang.Long
startNextInstance(java.lang.String jobName)
Launch the next in a sequence ofJobInstance
determined by theJobParametersIncrementer
attached to the specified job.boolean
stop(long executionId)
Send a stop signal to theJobExecution
with the supplied id.
构造器详细资料
SimpleJobOperator
public SimpleJobOperator()
方法详细资料
afterPropertiesSet
public void afterPropertiesSet() throws java.lang.Exception
Check mandatory properties.- 指定者:
afterPropertiesSet
在接口中org.springframework.beans.factory.InitializingBean
- 抛出:
java.lang.Exception
- 另请参阅:
InitializingBean.afterPropertiesSet()
setJobParametersConverter
public void setJobParametersConverter(JobParametersConverter jobParametersConverter)
Public setter for theJobParametersConverter
.- 参数:
jobParametersConverter
- theJobParametersConverter
to set
setJobRegistry
public void setJobRegistry(ListableJobLocator jobRegistry)
Public setter for theListableJobLocator
.- 参数:
jobRegistry
- theListableJobLocator
to set
setJobExplorer
public void setJobExplorer(JobExplorer jobExplorer)
Public setter for theJobExplorer
.- 参数:
jobExplorer
- theJobExplorer
to set
setJobRepository
public void setJobRepository(JobRepository jobRepository)
setJobLauncher
public void setJobLauncher(JobLauncher jobLauncher)
Public setter for theJobLauncher
.- 参数:
jobLauncher
- theJobLauncher
to set
getExecutions
public java.util.List<java.lang.Long> getExecutions(long instanceId) throws NoSuchJobInstanceException
从接口复制的说明:JobOperator
List theJobExecutions
associated with a particularJobInstance
, in reverse order of creation (and therefore usually of execution).- 指定者:
getExecutions
在接口中JobOperator
- 参数:
instanceId
- the id of aJobInstance
- 返回:
- the id values of all the
JobExecutions
associated with this instance - 抛出:
NoSuchJobInstanceException
- if theJobInstance
associated with theinstanceId
cannot be found.
getJobNames
public java.util.Set<java.lang.String> getJobNames()
从接口复制的说明:JobOperator
List the available job names that can be launched withJobOperator.start(String, String)
.- 指定者:
getJobNames
在接口中JobOperator
- 返回:
- a set of job names
getJobInstances
public java.util.List<java.lang.Long> getJobInstances(java.lang.String jobName, int start, int count) throws NoSuchJobException
从接口复制的说明:JobOperator
List theJobInstances
for a given job name, in reverse order of creation (and therefore usually of first execution).- 指定者:
getJobInstances
在接口中JobOperator
- 参数:
jobName
- the job name that all the instances havestart
- the start index of the instancescount
- the maximum number of values to return- 返回:
- the id values of the
JobInstances
- 抛出:
NoSuchJobException
- is thrown if noJobInstance
s for the jobName exist.
getParameters
public java.lang.String getParameters(long executionId) throws NoSuchJobExecutionException
从接口复制的说明:JobOperator
Get theJobParameters
as an easily readable String.- 指定者:
getParameters
在接口中JobOperator
- 参数:
executionId
- the id of an existingJobExecution
- 返回:
- the job parameters that were used to launch the associated instance
- 抛出:
NoSuchJobExecutionException
- if the id was not associated with anyJobExecution
getRunningExecutions
public java.util.Set<java.lang.Long> getRunningExecutions(java.lang.String jobName) throws NoSuchJobException
从接口复制的说明:JobOperator
Get the id values of all the runningJobExecutions
with the given job name.- 指定者:
getRunningExecutions
在接口中JobOperator
- 参数:
jobName
- the name of the job to search under- 返回:
- the id values of the running
JobExecution
instances - 抛出:
NoSuchJobException
- if there are noJobExecutions
with that job name
getStepExecutionSummaries
public java.util.Map<java.lang.Long,java.lang.String> getStepExecutionSummaries(long executionId) throws NoSuchJobExecutionException
从接口复制的说明:JobOperator
Summarise theStepExecution
instances belonging to theJobExecution
with the supplied id, giving details of status, start and end times etc.- 指定者:
getStepExecutionSummaries
在接口中JobOperator
- 参数:
executionId
- the id of an existingJobExecution
- 返回:
- a map of step execution id to String summarising the state of the execution
- 抛出:
NoSuchJobExecutionException
- if there is noJobExecution
with the supplied id
getSummary
public java.lang.String getSummary(long executionId) throws NoSuchJobExecutionException
从接口复制的说明:JobOperator
Summarise theJobExecution
with the supplied id, giving details of status, start and end times etc.- 指定者:
getSummary
在接口中JobOperator
- 参数:
executionId
- the id of an existingJobExecution
- 返回:
- a String summarising the state of the job execution
- 抛出:
NoSuchJobExecutionException
- if there is noJobExecution
with the supplied id
restart
public java.lang.Long restart(long executionId) throws JobInstanceAlreadyCompleteException, NoSuchJobExecutionException, NoSuchJobException, JobRestartException, JobParametersInvalidException
从接口复制的说明:JobOperator
Restart a failed or stoppedJobExecution
. Fails with an exception if the id provided does not exist or corresponds to aJobInstance
that in normal circumstances already completed successfully.- 指定者:
restart
在接口中JobOperator
- 参数:
executionId
- the id of a failed or stoppedJobExecution
- 返回:
- the id of the
JobExecution
that was started - 抛出:
JobInstanceAlreadyCompleteException
- if the job was already successfully completedNoSuchJobExecutionException
- if the id was not associated with anyJobExecution
NoSuchJobException
- if theJobExecution
was found, but its correspondingJob
is no longer available for launchingJobRestartException
- if there is a non-specific error with the restart (e.g. corrupt or inconsistent restart data)JobParametersInvalidException
- if the parameters are not valid for this job
start
public java.lang.Long start(java.lang.String jobName, java.lang.String parameters) throws NoSuchJobException, JobInstanceAlreadyExistsException, JobParametersInvalidException
从接口复制的说明:JobOperator
Start a new instance of a job with the parameters specified.- 指定者:
start
在接口中JobOperator
- 参数:
jobName
- the name of theJob
to launchparameters
- the parameters to launch it with (comma or newline separated name=value pairs)- 返回:
- the id of the
JobExecution
that is launched - 抛出:
NoSuchJobException
- if there is noJob
with the specified nameJobInstanceAlreadyExistsException
- if a job instance with this name and parameters already existsJobParametersInvalidException
- thrown if any of the job parameters are invalid.
startNextInstance
public java.lang.Long startNextInstance(java.lang.String jobName) throws NoSuchJobException, UnexpectedJobExecutionException, JobParametersInvalidException
从接口复制的说明:JobOperator
Launch the next in a sequence ofJobInstance
determined by theJobParametersIncrementer
attached to the specified job. If the previous instance is still in a failed state, this method should still create a new instance and run it with different parameters (as long as theJobParametersIncrementer
is working).
The last three exception described below should be extremely unlikely, but cannot be ruled out entirely. It points to some other thread or process trying to use this method (or a similar one) at the same time.- 指定者:
startNextInstance
在接口中JobOperator
- 参数:
jobName
- the name of the job to launch- 返回:
- the
JobExecution
id of the execution created when the job is launched - 抛出:
NoSuchJobException
- if there is no such job definition availableUnexpectedJobExecutionException
- if an unexpected condition arisesJobParametersInvalidException
- thrown if some of the job parameters are invalid.
stop
@Transactional public boolean stop(long executionId) throws NoSuchJobExecutionException, JobExecutionNotRunningException
从接口复制的说明:JobOperator
Send a stop signal to theJobExecution
with the supplied id. The signal is successfully sent if this method returns true, but that doesn't mean that the job has stopped. The only way to be sure of that is to poll the job execution status.- 指定者:
stop
在接口中JobOperator
- 参数:
executionId
- the id of a runningJobExecution
- 返回:
- true if the message was successfully sent (does not guarantee that the job has stopped)
- 抛出:
NoSuchJobExecutionException
- if there is noJobExecution
with the id suppliedJobExecutionNotRunningException
- if theJobExecution
is not running (so cannot be stopped)
abandon
public JobExecution abandon(long jobExecutionId) throws NoSuchJobExecutionException, JobExecutionAlreadyRunningException
从接口复制的说明:JobOperator
Mark theJobExecution
as ABANDONED. If a stop signal is ignored because the process died this is the best way to mark a job as finished with (as opposed to STOPPED). An abandoned job execution cannot be restarted by the framework.- 指定者:
abandon
在接口中JobOperator
- 参数:
jobExecutionId
- the job execution id to abort- 返回:
- the
JobExecution
that was aborted - 抛出:
NoSuchJobExecutionException
- thrown if there is no job execution for the jobExecutionId.JobExecutionAlreadyRunningException
- if the job is running (it should be stopped first)