You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 13 Next »

Locks in the JobScheduler stop the execution of a job, as long as a particular lock has been acquired by one or more jobs. Locks are available for individual jobs and for jobs in job chains. Should a job be waiting for a lock to be released (lock contention), then it will be automatically started as soon as the lock has been freed.

On a lock you configure how much jobs can use the lock nonexclusive in parallel.
A job can have multiple locks and can use them exclusive or nonexclusive. If a lock is used nonexclusive then other jobs with the same lock can start in parallel until the maximum number of nonexclusive jobs is reached.
If a job used the lock exclusive then other jobs with the same lock must wait until the lock is released.

See also http://www.sos-berlin.com/doc/en/scheduler.doc/lock.xml

Example1: 3 Jobs using the same lock, one of them exclusive

First you have to create a lock then it can be acquired by jobs.
For example open the folder ./live/lockExample/ in JOE.
We create the lock "testLock"

and three jobs "job1", "job2", "job3" where "job1" use the "testLock" exclusive and the other non exclusive.

You can download this Example here.

We start the jobs in different orders to see what happens

  1. job1 -> job2 -> job3
    In this case job1 holds the lock exclusive and job2 and job3 don't start until job1 is finished and release the lock.
  2. job2 -> job3 -> job1
    In this case job2 and job3 start both because they hold the lock non exclusive. job1 wants to use the lock exclusive so it doesn't start until job2 and job3 are finish and release the lock.
  3. job2 -> job1 -> job3
    Same behaviour like case 2.

Example2: number of max nonexclusive jobs (useful for maintainance weekends)

We have a lock "maintain" with unlimited maximal number of nonexclusive jobs and we have the jobs "job1" and "job2" which have acquired the lock "maintain" nonexclusive.
Look above how you create the lock in JOE and how do you assign a lock to a job nonexclusive.

Both jobs starts in the same manner like without the lock because they use it nonexclusive and the maximal number of nonexclusive jobs is unlimited.
Because of the lock is configured for unlimited nonexclusive use.

In this example a job chain is added with a job which change the maximal number of nonexclusive jobs.
The job chain has two orders. For one order the job set the maximal number of nonexclusive jobs equal 0.
For the other order the job set the maximal number of nonexclusive jobs unlimited (2^31-1).
If the maximal number of nonexclusive jobs equal 0 then no job starts which use this lock.

So you have one order to lock both jobs and another to release the jobs.
Has a job a schedule which tries to start the job while it is locked then this start goes into a task queue for later execution.
When the job is released then all planned starts from the task queue are executed.

We assume that you have jobs which need the same resource (e.g. the same remote host for SSH jobs) then give them the same lock.
If this resource is not available for a specific time then this example is a way to lock these jobs.
This example is further a good method for a planned maintainance.

You can download this Example here.

  • No labels