JSR 352 Restarting a job?

2019-03-02 16:17发布

When a job is restarted, only the failed partitions are run again. How do i run a successfully completed job again?

Is there a difference between submitting a job again and restarting the job?

i am using IBM's implementation of JSR 352 on Websphere Liberty.

1条回答
啃猪蹄的小仙女
2楼-- · 2019-03-02 17:01

Java Batch is designed so that when you restart a job instance, execution continues where you left off (in the previous failed or stopped execution).

So typically this means two things:

  1. Within the job, you begin at the previously-failing step (or the step at which the job was stopped).
  2. Within the step, you begin by positioning the input cursor using the checkpoint values kept by the batch container.

So if on the initial execution you completed step1 then failed at step2 at record #4123, and are checkpointing every 100 records, then on a restart you'd typically begin executing at step2 at record #4100.

In some cases it's necessary to execute step1 on the restart as well, before executing step2 where the job had previously failed, and there is an option to get this behavior as well.

It is typical to submit/start a job repeatedly, often on a schedule.

In the terms of the batch specification, a new JobInstance is created each time a job is started. At this time the initial JobExecution for this JobInstance is created. If the execution does not run to completion, the instance may be restarted, at which time a second JobExecution is created for this JobInstance.

So a restart uses the checkpoints and execution history of the previous JobExecution while the start begins with a clean slate.

查看更多
登录 后发表回答