[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.5.2 Dependence types

In the previous sample, we used a job dependence to force `job2' to wait `job1' termination.

There are three types of dependencies : `onerror', `onsuccess' and `always'.

With an `onerror' dependence, the downstream job will be run only if the upstream job is aborted. For example, it's useful to restore a database, when a job aborts. If the upstream job is terminated without abort, the downstream job is canceled.

With an `onsuccess' dependence, the downstream job will be run only if the upstream job is terminated without abort. Otherwise, the downstream job will be canceled.

With an `always' dependence, the downstream job is executed when the upstream job terminates (with or without abort).

Note : By default, downstream jobs are executed or canceled : if the upstream job aborts, the downstream jobs are not waiting. But you can force the upstream job to stop if it aborts (rjsoec command). An human operator can try to solve the problem and can restart the job.

In this sample, we will use :

First, you must ensure that the dio87d daemon is running (see section 8.1 Start the deamon).

We create a referential with the ra command :

 
$ dio87c -- ra ref1
$

Now, we have to create a task to store our four jobs. The rta command creates the task. The rtoa indicates that the tasks must be run every days.

 
$ dio87c -- rta ref1 t1
$ dio87c -- rtoa ref1 t1 add always
$

We create four jobs `job1', `job2', `job3' and `job4'. These jobs execute a temporization of 30 seconds. The rja commands create jobs, the rjsp commands set the path of the command to execute `/bin/sleep' and the rjsa commands set the argument (30 seconds) :

 
$ dio87c -- rja ref1 t1 job1 "first job"
$ dio87c -- rjsp ref1 t1 job1 "/bin/sleep"
$ dio87c -- rjsa ref1 t1 job1 "30"
$
$ dio87c -- rja ref1 t1 job2 "run if job1 is OK"
$ dio87c -- rjsp ref1 t1 job2 "/bin/sleep"
$ dio87c -- rjsa ref1 t1 job2 "30"
$
$ dio87c -- rja ref1 t1 job3 "run if job1 aborts"
$ dio87c -- rjsp ref1 t1 job3 "/bin/sleep"
$ dio87c -- rjsa ref1 t1 job3 "30"
$
$ dio87c -- rja ref1 t1 job4 "after job2 or job3"
$ dio87c -- rjsp ref1 t1 job4 "/bin/sleep"
$ dio87c -- rjsa ref1 t1 job4 "30"
$

`job2' will start only if `job1' terminates without abort. We use the rjda command to create an `onsuccess' dependence between `job1' and `job2' :

 
$ dio87c -- rjda ref1 t1 job1 job2 onsuccess
$

`job3' will start only if `job1' terminates with abort. We use the rjda command to create an `onerror' dependence between `job1' and `job3' :

 
$ dio87c -- rjda ref1 t1 job1 job3 onerror
$

`job4' will start when `job1' OR `job2' terminates without errors. We have first to create two `onsuccess' dependencies :

 
$dio87c -- rjda ref1 t1 job2 job4 onsuccess
$dio87c -- rjda ref1 t1 job3 job4 onsuccess

By default, a job waits for all its upstream dependencies before to start. With the rji command, you can verify that the field `Wait All Dependence' is set to `true' for `job4' :

 
$ dio87c -- rji ref1 t1 job4
Job Name:       job4
[...]
Wait All Dependencies:  true
$

We use the rjswad command to specify that `job4' must wait for `job2' OR `job3' termination :

 
$ dio87c -- rjswad ref1 t1 job4 false
$
$ dio87c -- rji ref1 t1 job4
Job Name:       job4
[...]
Wait All Dependencies:  false 
$

Now, the field `Wait All Dependence' is set to false.

We can now create a day from our referential :

 
$ dio87c -- rp ref1 "2005-01-18" d1 
$

The first job `job1' is running while the other are waiting for dependence :

 
$ dio87c -- xjl d1 t1 -s
job1	running
job2	wait_for_dep
job3	wait_for_dep
job4	wait_for_dep
$

When the first job is terminated, `job2' starts (onsuccess dependence) and `job3' is canceled. Job `job4' is waiting for `job2' :

 
$ dio87c -- xjl d1 t1 -s
job1	terminated
job2	running
job3	canceled
job4	wait_for_dep

When `job2' is terminated, `job4' starts :

 
$ dio87c -- xjl d1 t1 -st
t1	job1	terminated
t1	job2	terminated
t1	job3	canceled
t1	job4	running

Finally, `job4' is terminated. The task `t1' is terminated :

 
$ dio87c -- xjl d1 t1 -st
t1	job1	terminated
t1	job2	terminated
t1	job3	canceled
t1	job4	terminated
$
$ dio87c -- xtl d1 -s
t1	terminated
$

To simulate an abnormal termination of `job1', we will replace the command to execute by `/bin/false' : this command returns an exit code which is not zero : it's considered as an abnormal termination.

We modify the job path of `job1' with rjsp command.

 
$ dio87c -- rjsp ref1 t1 job1 "/bin/false"
$ dio87c -- rjsa ref1 t1 job1 ""
$
$ dio87c -- rji ref1 t1 job1
Job Name:       job1
[...]
Path:           /bin/false
Argument:       none
$

We create anoter day `d2' from our referential :

 
$ dio87c -- rp ref1 "2005-01-18" d2 
$

`job1' aborts because `/bin/false' returns an exit code which is not zero. `job2' is canceled (`onsuccess' dependence) and `job3' starts (`onerror' dependence). `job4' is waiting for `job3' termination.

 
$ dio87c -- xjl -s d2 t1
job1	aborted
job2	canceled
job3	running
job4	wait_for_dep

`job4' is now running because `job3' is terminated :

 
$ dio87c -- xjl -s d2 t1
job1	aborted
job2	canceled
job3	terminated
job4	running
$

Finally, `job4' is terminated. The task is aborted :

 
$ dio87c -- xjl -s d2 t1
job1	aborted
job2	canceled
job3	terminated
job4	terminated
$
$ dio87c -- xtl -s d2
t1	aborted
$


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by dom on September, 11 2005 using texi2html