Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents
outlinh1. true
outlinh1. true
1printablefalse
2stylh1. none
3indent20px
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.

Example 1: Three 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 uses the "testLock" exclusive and the other jobs use lock 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 exclusively and job2 and job3 don won't start until job1 is finished completed and will release the lock.
  2. job2 -> job3 -> job1
    In this case job2 and job3 start both because they can get hold of the lock non exclusive-exclusively. job1 wants to use the lock exclusive exclusively so it doesn't start until job2 and job3 are finish completed and will release the lock.
  3. job2 -> job1 -> job3
    Same behaviour like case 2.as for case 2.

Example 2: Number of maximum non-exclusive jobs (useful for maintenance windows)

We assume a lock maintain with an unlimited number of non-exclusive jobs and we assume the jobs job1 and job2 to have acquired the lock maintain in non-exclusive mode.

See above how to create the lock in JOE and how to assign the lock to a job in non-exclusive mode.

Both jobs start in the same way as without the lock because they use it non-exclusively and the maximum number of non-exclusive jobs is unlimited as the lock is configured for unlimited non-exclusive use.

In this example a job chain is added with a job that modifies the maximum number of non-exclusive jobs. This job chain has two orders:

  • For one order the job sets the maximum number of non-exclusive locks to 0 (zero).
  • For the other order the job sets the maximum number of non-exclusive jobs to unlimited (2^31-1).

If the maximum number of non-exclusive jobs equals zero then no job will start that uses this lock.

Therefore with the sample you receive one order is used to to lock both jobs and another order is used to release the jobs.
If a job uses a schedule that is configured to start the job while it is locked then the job is moved to a task queue for later execution.
As soon as the job is released then all planned starts from the task queue are executed.

We assume that you have jobs that required the same resources, e.g. a database table or the same remote host for SSH jobs, and that you would assign them the same lock.
If this resource is not available for a specific time then this example shows a way how to lock these jobs.
This example is further a possible method for a planned maintenance.

Related Downloads

See also