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

Compare with Current View Page History

« Previous Version 13 Next »

Events

Question: How can I create inter dependencies between JobChains?

Introduction

My JobChainA starts at morning 08:00 AM and should finish processing within 2 hours.
My JobChainB starts at morning 10:15 AM , but JobChainB can only be started when JobChainA is successfully ended processing.

JobScheduler provides a solution to set off events and to handle these events on an active instance of the event service JobScheduler. However it is also possible to check for events in job chains and then conditionally proceed.
You find the complete documentation in scheduler_events.pdf - Documentation. In particular, how to define event handlers with JOE is described in chapter XML Event Handlers (However this should not be needed for the actual example here.)
To demonstrate how to create an event and wait for it in a job chain we will draw up a simple scenario:

  1. JobChainA contains 3 Task nodes i.e. TaskA1,TaskA2,TaskA3
  2. JobChainA contains 1 job node i.e. Submit_End_Event, which will send a EVENT notification to JobScheduler that job has finished.
  3. JobChainB also contains 3 Task nodes i.e. TaskB1,TaskB2,TaskB3
  4. JobChainB contains 1 job node i.e. Check_End_Event, which will check if required EVENT notification is present in the JobScheduler DB.
  5. JobChainB

Requirements

  1. The JobScheduler must run using a database.
  2. Events are stored permanently in the table "SCHEDULER_EVENTS".
  3. The JobScheduler must be installed with the Event-Service (JobChain sos/
  [[File:Sos-event-service.png]]

Instructions

  • Unzip all files of test_event.zip into the ./config folder of your active instance of the event service JobScheduler installation. After unzipping you will have all the objects needed to run the example in the live/DEP_EVENTS subfolder.
  • Open the JS operations gui for the workload JobScheduler in your browser using http://scheduler_host:scheduler_port
  • Find the DEP_EVENTS/JobChainA/JobChainA job chain and click on it.
  • There is an order assigned to the job chain. In the order menu press Start order now
  • You see the order will run until the step 3 is reached. As the EVENT event does not exist, the order will wait for 10s and then check again.
  • Switch to the tab Jobs.
  • Find the {{test_event/job_event_add }} job chain and click on it.
  • In the Job menu press Start task immediately. This will create the EVENT event.
  • Switch to the tab Job Chains.
  • See the order proceeding with execution of the next step

How it works

The test_event/job_event_add job is a dummy shell script job with a post processing part. In the post processing the com.sos.jitl.eventing.EventMonitorTaskAfter JITL class is used to add an TEST.TEST_EVENT event.

The test_event/job chain_example_wait_for_event }} job chain has 2 dummy steps and the wait for event step. This step executes the {{test_event/job_event_check job to look for the desired event specified in the scheduler_event_spec parameter. As the events are stored in a xml object you have to specify a xpath expression here.

If the event is not raised, the order executes a setback. The wait time between two checks is configured in the delay_order_after_setback definition of the job (and the job chain node).

After adding the event, the order will proceed with the next step and the event will be removed.

The test_event/job chain_example_wait_for_event_db }} job chain has 2 dummy steps and the wait for event step. This step executes the {{test_event/job_event_check_db job to look for the desired event. The difference to to first example is, that this job uses the events database. You can either specify parameters for event_id, event_class and exit_code to test for a specific event or you can specify a condition for the events you are waiting for.

example:

 class_a.event_1:99 and not (class_b.event2 or class_b.event3)
  
 if the event_1 in class class_a exists with exit_code=99 and event2 and event3 from class_b do not exist, this expression evaluates to true.

You also can specify how to handle the existing or not existing of events with the paramters handle_existing_ah1. "error|success" or handle_not_existing_as"error|success"

example

 handle_existing_as=error will wait until the events do not exist

If the event is not raised, the order executes a setback. The wait time between two checks is configured in the delay_order_after_setback definition of the job (and the job chain node).

After adding the event, the order will proceed with the next step and the event will be removed.

Downloads:

  • No labels