Job Networks




Job Networks

      Simple Network

This section of the manual discusses one method you can use to chain together many jobs to run in a particular sequence. This chapter shows how you can have Jol manage a network and SUBMIT a job or jobs after a particular job or group of parallel running jobs has ended. The next chapter demonstrates how you can SUBMIT a job from a currently executing job (Dependent Job Processing).

The major differences between the two methods are:

  • With Job Networking, Jol manages the submission of jobs and controls parallel execution of jobs and the waiting for the termination of jobs before submitting other jobs in the network. Basically, you code your Jol programs as though they are independent jobs, and then code a special set of Jol network instructions that then submit the jobs in the desired sequence for you.

    Jobs are usually submitted only when the current job ends, although you can force Jol to examine the status of the network at any time, and depending on the status, submit other jobs.

  • Dependent job processing allows you to SUBMIT a job at any time from the current job. You code the SUBMIT instructions at appropriate points in your Jol program. The SUBMIT commands can be coded before the job ends, and allows for parallel processing, but you cannot wait for two jobs to terminate before submitting another.

    It is recommended that you be familiar with, or review, the SUBMIT and SAVESYMS commands. These commands, with their protocols, are explained in the Jol Reference Manual and Jol Reference Guide, and in the Appendices of this book.

Job Networks

Often it is desirable to process two or more jobs in parallel, and after those jobs have reached completion, start one or more jobs.

To prepare a Jol network is a simple task. You can use your previous Jol or JCL jobs without alteration. You prepare your network commands and place them in the JOL.NETWORK partitioned data set under the member name of the network.

A typical network job might be that jobs JOB1 and JOB2 are to run, and after both jobs have completed JOB3 is to commence. This can be shown as:

 
      Simple Network

Figure 2-1: A Small Job Network

This may be coded in Jol as shown on the following:




    NETWORK ONE;
        SUBMIT JOB1;

        SUBMIT JOB2;

        SUBMIT JOB3 AFTER JOB1 & JOB2 ENDED;
    ENDNET;


Notice the Jol instructions NETWORK and ENDNET. The NETWORK instruction is followed by the name of a network. This defines a unique network so that you can submit the same jobs in different networks, and still allow Jol to network the correct jobs. The ENDNET informs Jol that any instructions following are not part of the network.

You can also use other Jol instructions such as PANEL in a network. Any instruction will be executed as normal, except for SUBMIT, which is copied to a work file for possible re-execution at the end of each job.

For example, the jobs above may require the Operator to provide Symbolic Variables for the jobs. For example:



    PANEL
    ('ENTER TODAY''S DOLLAR RATE',DOLLVAL,7);
    NETWORK ONE;
        SUBMIT JOB1 SYMS('DOLLVAL=%DOLLVAL);
        SUBMIT JOB2;

        SUBMIT JOB3 SYMS('DAY=%DAY')

               AFTER JOB1 & JOB2 ENDED ;
    ENDNET;

Figure 2-2: A Small Network with PANEL and Symbolic Variables.

The Panel instruction displays a data entry panel on the User's Screen, and allows him or her to enter the day's Dollar Exchange Rate.  This is then pased through to the SUBMIT JOB1 instruction.

A more complex example is represented below:

 
Advanced Network

Figure 2-3: An Advanced Network.

In this example, JOB1 and JOB2 may proceed in parallel. The other jobs must execute in the following sequence:

  • JOB3 can commence processing after either JOB1 or JOB2 have ended.

  • JOB4 cannot commence until both JOB1 and JOB2 have finished.

  • JOB5 must wait for JOB2 to end before it can start.

  • JOB6 must wait for JOB3, JOB4 and JOB6 before it can start.

  • JOB7 must wait for JOB6 to end, and it is to be executed only on Fridays.

    One possible method of coding the example above is presented:



    NETWORK TWO;

        SUBMIT JOB1;
        SUBMIT JOB2;

        SUBMIT JOB3
               AFTER JOB1 OR JOB2 ENDED;

        SUBMIT JOB4
               AFTER JOB1 AND JOB2 ENDED;

        SUBMIT JOB5
               AFTER JOB2 ENDED;

        SUBMIT JOB6
               AFTER JOB3 & JOB4 & JOB5 ENDED;

        IF %DAY='FRIDAY' THEN
               SUBMIT JOB7      AFTER JOB6 ENDED;

    ENDNET;


Figure 2-4: Coding the Advanced Network.

Submitting Operating System JCL Jobs

The Jol SUBMIT command is extremely flexible: you can pass symbolic variables from job to job, test completion codes before submitting other jobs and other facilities are available.

You can also use SUBMIT to submit JCL jobs by enclosing the JCL to be submitted in quotes. When SUBMIT detects that parameters have been coded in quotes, it passes them directly through to the Operating System, after replacing any Jol Sysmbolic Variables. For example:


    NETWORK TWO;

    Job1:

        SUBMIT '//JOB1 JOB (ACCT),NAME'
            '// EXEC VALIDATE,'
            '// PARM=''PROG1=%DAY''';

    Job2:

        SUBMIT '//JOB2 JOB (ACCT),NAME'
            '// EXEC UPDATE'
             AFTER JOB1 ENDED;

        SUBMIT JOB3 AFTER JOB1 AND JOB2 ENDED;

    ENDNET;



Figure 2-5: Submitting JCL in a Network.

Notes

Note that when you are submitting JCL or MS/DOS commands, you must code a Jol label (Job1: in the example above) so that Jol can identify the job in the Network.

Submitting Dependent Jobs

In addition to the Jol NETWORK instructions, the Jol SUBMIT Command ensures that the correct order of processing interdependent jobs is observed. Other jobs may be SUBMITted at any time - even before the end of the current job.

Usually, the source text for SUBMITted jobs can be found in a library.

Please note that ASP and JES3 have facilities allowing the creation of a "Job Net". Jobnets are not yet supported by Jol.

Notes

  • No job is submitted more than once, even if there are two or more SUBMITs for it. This allows you to code multiple conditions for a job to start.

  • You must code the jobs that must run before the successor jobs. However, jobs are not necessarily submitted in the order that they are coded - rather they are submitted as soon as Jol can determine that the dependencies have been satisfied.

  • Jobs in the network may also SUBMIT other jobs. However, these jobs, which may run in parallel with any jobs in the network, are not executed under control of the network manager.

  • If an abend occurs in a job in the network, the default action is to stop the network. The IF ERROR instruction can be used to determine if an abend occured, and any appropriate action can be taken.

Examining the Status of a Network

The Jol Network Facility uses a single standard Partitioned Data Set to contain information about all the Networks under its control. To review the status of any job in a Network, you can use ISPF or PFD to examine the data set SYS2.JOLNET.STATUS.

Each member of the SYS2.JOLNET.STATUS data set is the name of a Network, and each member contains the current state of each job in the Network as a series of assignment statements for Jol. For example, in a network called PAYROLL there may be jobs VALIDATE and UPDATE. The member PAYROLL will contain statements similar to:


    %VALIDATE='ENDED';

    %UPDATE='SUBMITTED';



Restarting a Network

Should a Networked job fail for any reason, correct the problem, and enter:


    Start Jol at the terminal with:

    JOL *

    Then enter

    $JOB; /* Create a Job Card */

    CHECKNET network-name;

/*


This will restart the job net for you.

If you must restart at an earlier job in the network, simply edit the SYS2.JOLNET.STATUS(network-name) data set and alter the network to the status you require, and follow the instructions above.

Building in a Restart Job

Often, you can program restarts for various jobs or networks if a failure occurs. To do this, code similar to the following may be used:


    IF ERROR /* An ABEND Occurred */
    | MAXCC>4 /* A Program Detected an Error */
    THEN DO;
        SUBMIT RESTORE; /* Restore Files */
        STOPNET; /* Stop Current Network */
    END;



The job called RESTORE can restore the data sets, and restart the Network.

Forcing Jol to Examine the Network Status Early

Usually, Jol will wait until the end of a job before it issues a CHECKNET instruction. You may decide that halfway through a job, you would like Jol to examine the Network, and start other jobs if it is able to. To do this, simply code a CHECKNET instruction at the appropriate point if the job. For example:


    IF MAXCC<4 /* Test for errors first */

    THEN CHECKNET;

Method of Operation

When Jol finds a NETWORK command, it does the following:

  • It opens a special work data set into which the SUBMIT command will copy information. This is checked at the end of every job in the network.

  • It sets an indicator that is used by the SUBMIT command.

    When a SUBMIT command is executed, it does the following:

  • If the indicator mentioned above is not set, the SUBMIT instruction operates as usual. That is, the job is submitted to the operating system for execution.

    Otherwise, the SUBMIT takes special actions for controlling the network.

  • If the SUBMIT is an unconditional SUBMIT instruction (it does not contain an AFTER clause), the names of the jobs are copied to the work data as symbolic variables, initialized to 'SUBMITTED'.


  • If the SUBMIT is a conditional SUBMIT instruction (that is, it does contain an AFTER clause), then:

    * The AFTER is converted to a series of IF instructions similar to:

        IF %JOB1='ENDED' THEN SUBMIT ...

    * The names of the jobs are copied to the work data as symbolic variables initialized to '' or null.

  • The SUBMIT instruction then submits the job, but adds a CHECKNET instruction to the end of the job. CHECKNET uses the instructions in the work file as input to Jol. Jol reads the work file, alters the appropriate null symbolic variable to 'ENDED', and rewrites the file. Then Jol reads the file again, and this time submits other jobs, if the required conditions are met.

---000---