cancel
Showing results for 
Search instead for 
Did you mean: 

CONTINUE OR STOP ON CHAINS

Former Member
0 Kudos

Hello

I have one big chain.

Within in this one big chain there are 3 others.

Step 1 is a chain

Step 2 is a chain

Step 3 is a chain.

Within step 1, there are 10 jobs, if any of them fail, within step 1, they are all set to continue however, I do not want step 2 to start if this is the case.

The issue is that within step 1 chain, these 10 jobs must run one after another, and not side by side.

if any fail - they continue... to the end of the chain., but I MUST make step 2 ( which is another chain ) stop at that point.

How do I do that?

Accepted Solutions (0)

Answers (1)

Answers (1)

nanda_kumar21
Active Contributor
0 Kudos

Lets call

step 1 chain A

step 2 chain B

step 3 chain C.

All these three steps are within one big chain called Mega_Chain.

I assume that you don't want to run B, if any one job fails in A.

But all 10 jobs in A should complete no matter what.

There are two solutions i can think of 

Solution 1:

  1. Remove the chain A from Mega_Chain.
  2. Create 2 events :
    • JOB_FAILED_IN_A
    • GREEN_LIGHT_B_C
  3. Now edit each job in A to raise the event JOB_FAILED_IN_A in case of status error.
  4. Edit the Mega_Chain  to wait for event GREEN_LIGHT_B_C.
  5. Raise the event GREEN_LIGHT_B_C manually.
  6. Create a Job chain with step 1, call it STOP_MEGA_CHAIN, add the System_Raise_Event job definition and add the following parameters of the job.
    • Event - GREEN_LIGHT_B_C
    • Raise or Clear - Clear
  7. Now go to wait events tab of STOP_MEGA_CHAIN, add the event JOB_FAILED_IN_A and Auto - submit - always.

Now go on with your regular schedule, (you will have to decide when to run Mega_chain, as it now contains only B and C).

Solution 2:

  1. Create 10 events, each one for each job in A.
  2. If job 1 completes in A(step 1), raise event A, if job 2 completes, raise event 2... until job 10.
  3. Make the Step 2 - Chain B to wait for all 10 events.
  4. Open the chain A, and edit the status handlers of each of the 10 steps, to continue on cancelled, error, killed, completed, otherwise, unknown.

Now go on with your schedule. Chain A(Step 1) will run all 10 jobs no matter what, but Chain B(Step 2) will not start, even if one job fails in A.

Thanks

Nanda

Former Member
0 Kudos

Hi,

There are many ways to schedule this kind of jobs

A) schedule mster chain with Job-A jo as last step , which contains 10 steps, with status handlers set, and in action tab write pece of code as post running action to check status of child jobs of Job-A,

you can write your owne ;logic, i prefer to set flag value to zero, and increment count for each child job run. at the end writ if loop and if the count is equal to number of step then start Job-B, else end the job with out put all steps are not completed.

B) add raise event to each step of job-A ,a dn maintain all these events as wait event for job-B, so if all steps completed in A, then wait events of Job_B will be raised, else not. but here you must be care full to clear all pending  events if any of the step of Job-A failes. and the other option would be using status handlers.

KR

Muhammad Asif.

Former Member
0 Kudos

Hi Cindy,

here is post running action for you, copy past this in action tab--> Type: Post Running

Only you need to change the partition and Jab Name : in the code line:

Session.getJobDefinitionByName(jcsSession.getPartitionByName("GLOBAL"), "Jabname_B");

{

                        int flg = 0; 

                        int flg1 = 0;

                          Iterator s = (Iterator) jcsJob.getChildJobs();

                        while (s.hasNext()) {

                              flg1 = flg1 + 1;

                              Job jc1 = (Job) s.next();

                                                      jcsOut.println(jc1.getJobDefinition().getName());

                              Iterator s1 = (Iterator) jc1.getChildJobs();

                                while (s1.hasNext()) {

                                    Job jc2 = (Job) s1.next();

                                                                    jcsOut.println(jc2.getJobDefinition().getName());

                                    if (jc2.getStatus().toString() == "Completed"){

                                          flg = flg + 1;}

                                }

                        }

                        if (flg1 == flg) {

                                    jcsOut.println("All jobs completed" + "        No of completion: " + flg);

                                                                 JobDefinition jd = jcsSession.getJobDefinitionByName(jcsSession.getPartitionByName("GLOBAL"), "Test_Sleep_A");

                                              Job j = jd.prepare();

                                  }

                                        else {jcsOut.println("Not all jobs completed" + "No of completion: " + flg);}

                       

                     }

Hope this helps.

KR

Muhammad Asif.