Skip to content

Task running & Interruption recovery

Changwang Zhang edited this page Apr 4, 2016 · 1 revision

Tasks can be started either from a program or the command line. Below is an example to run the tasks from a program:

 public static void main(String[] args) {
  Tasks tasks = new Tasks();
  tasks.sFLoad = "rolldice.xml";
  tasks.start();
  System.exit(0);
 }

To run the same tasks from the command line:

 java -jar leotask.jar -load=rolldice.xml

The task class (e.g. org.leores.task.app.RollDice) should be either sealed in the leotask.jar or within the class path of Java. Below is the screen output of the example:

LeoTask 1.0.0 (C) Changwang Zhang ...
name=rolldice nRepeats=2000 seed=1429455691359 ...
cores=4 nThreads=3
Roll Dice 1.0 (C) Changwang Zhang mleoking@gmail.com
Start Task: 1/12 Elapsed Time: 0.078 Seconds.
Start Task: 2/12 Elapsed Time: 0.078 Seconds.
Start Task: 3/12 Elapsed Time: 0.078 Seconds.
Checkpoint saved to: rolldice_0419@1601_check.4.ckp
Start Task: 4/12 Elapsed Time: 0.843 Seconds.
Start Task: 5/12 Elapsed Time: 0.843 Seconds.
Start Task: 6/12 Elapsed Time: 0.875 Seconds.
Start Task: 7/12 Elapsed Time: 1.515 Seconds.
Checkpoint saved to: rolldice_0419@1601_check.8.ckp
Start Task: 8/12 Elapsed Time: 1.859 Seconds.
Start Task: 9/12 Elapsed Time: 1.859 Seconds.
Start Task: 10/12 Elapsed Time: 2.546 Seconds.
Start Task: 11/12 Elapsed Time: 2.562 Seconds.
Checkpoint saved to: rolldice_0419@1601_check.12.ckp
Start Task: 12/12 Elapsed Time: 3.406 Seconds.
Log statistic data Elapsed Time: 0.06796666666666666 Minutes.
Finished 12/12 Tasks in 0.12968333333333334 Minutes.

#Interruption recovery

To recover from interruption, one simply needs to rename the latest checkpoint file to check.ckp and start running the tasks either from a program or from the command line. The output when recovering from rolldice_0419@1601_check.8.ckp (i.e. rename it to check.ckp) is shown below:

Loading checkpoint: check.ckp ...
Loaded from checkpoint: check.ckp.
LeoTask 1.0.0 (C) Changwang Zhang ...
name=rolldice nRepeats=2000 seed=1429455803937 ...
cores=4 nThreads=3
Roll Dice 1.0 (C) Changwang Zhang mleoking@gmail.com
*Start Task: 5/12 Elapsed Time: 0.015 Seconds.
*Start Task: 6/12 Elapsed Time: 0.015 Seconds.
*Start Task: 7/12 Elapsed Time: 0.015 Seconds.
Checkpoint saved to: rolldice_0419@1603_check.8.ckp
Start Task: 8/12 Elapsed Time: 0.796 Seconds.
Start Task: 9/12 Elapsed Time: 0.828 Seconds.
Start Task: 10/12 Elapsed Time: 1.078 Seconds.
Start Task: 11/12 Elapsed Time: 1.515 Seconds.
Checkpoint saved to: rolldice_0419@1603_check.12.ckp
Start Task: 12/12 Elapsed Time: 2.187 Seconds.
Log statistic data Elapsed Time: 0.05025 Minutes.
Finished 12/12 Tasks in 0.1125 Minutes.

There is a * for task 5, 6 and 7 indicating that they were running (not finished yet) when the interruption happened and thus are restarted. Note: please delete the check point file check.ckp after finishing the tasks, otherwise LeoTask will always read and recover from that check point.

Clone this wiki locally