Hands-On Automation with STAF/STAX 3 - Part 4


Exercise 4.1 - Execute and debug a STAX Job that executes several sub-jobs

Objectives:

  1. Learn how to the <job> element.
  2. Learn how to interact with sub-jobs in the STAX Monitor.

Steps:

  1. Copy the xml files in directory C:\STAFCD\Part4\exercise4.1 to C:\STAF\xml as follows:
    COPY C:\STAFCD\Part4\exercise4.1\*.xml C:\STAF\xml\*.xml

  2. Submit a STAX job using the STAX Monitor, specifying file C:\STAF\xml\subjob.xml. The purpose of this job is to execute 5 subjobs. The job should complete in 60 seconds.

  3. After the job successfully completes, look at the "Testcase Info" panel.

  4. Did all 5 testcases pass? If not, look in the "Messages" panel to see any additional information.

  5. Why did any failures occurs? (Hint: use "staf local help error rc#" )
    ______________________________________________________________________________________
    ______________________________________________________________________________________
    ______________________________________________________________________________________

  6. Correct the problem in the subjob.xml file, and click on the "Resubmit Previous Job" button. Verify that all 5 testcases now pass.

  7. Notice that in the "Active Job Elements" panel, when a subjob is started, the only information displayed in the tree is the subjob itself (with the yellow construction sign). You won't see any of the sub-job's processes, blocks, stafcmds, etc. To view the sub-job's active job elements, you can start monitoring that sub-job. Right-click the mouse on the sub-job in the Active Job Elements" panel, and click on "Start Monitoring". You should see a new STAX Monitor window open that show's all of the sub-job's activity.

  8. In the STAX Monitor window for subret.xml, click on the "Sub-jobs" tab. This tab shows all sub-jobs that have been executed by the subret.xml. You can view their log files by right-clicking on the sub-job's row in the table and select "Display Job Log" or "Display Job User Log". Notice that this table shows you the result that each sub-job returned.

  9. In the main STAX Monitor window, after the job completes you can see the result that subret.xml returned. Note that the result is also displayed in the title bar of the STAX Monitor window for the subret.xml job.

Exercise 4.2 - Using STAXDoc

Objectives:

  1. Learn how to use STAXDoc.

Steps:

  1. Now let's create some STAXDoc documentation for the Part 4 sample jobs.

  2. In a command prompt, go to C:\STAFCD\Part4, and run the following command:
    java -jar c:\STAF\services\STAX\STAXDoc.jar -d c:\STAXDoc\samples samples
  3. This will create the STAXDoc documentation in the c:\STAXDoc\samples directory. Open a browser and navigate to this directory.

  4. Open the index.html file. It will show you the documents that are available. Click on the link for "FunctionParameters.xml" (since this is one of the STAX job for which we included the <function> information).

  5. The right side of the page shows the details about the function and its parameters.

Exercise 4.3 - Using STAX Extensions

Objectives:

  1. Learn how to use STAX Extensions.

Steps:

  1. In this exercise we will add the "Delay" extension. It provides <ext-delay>, <ext-wait>, and <ext-sleep> elements that can be used in your STAX jobs to delay for a specified number of seconds. In the STAX Monitor, these elements will be displayed in the "Active Job Elements" tree as progress bars.
  2. Edit your STAF.cfg file and add
    PARMS "EXTENSION C:/STAFCD/Part4/extensions/ExtDelay.jar"
    to the STAX service configuration statement. This statement should now look like:
    service stax library JSTAF execute c:/staf/services/stax/STAX.jar \
        PARMS "EXTENSION C:/STAFCD/Part4/extensions/ExtDelay.jar"
    
  3. Restart STAFProc on your machine.
  4. Open your favorite text editor, and copy/paste the following STAX job:
  5. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!DOCTYPE stax SYSTEM "stax.dtd">
    
    <stax>
    
      <defaultcall function="test"/>
       
      <function name="test">     
      
       <parallel>
       
        <block name="'Block A'">
      
          <parallel>
            <stafcmd>
              <location>'local'</location>
              <service>'delay'</service>
              <request>'delay 10000'</request>
            </stafcmd>
            <ext-delay>20</ext-delay>
          </parallel>
          
        </block>
        
        <block name="'Block B'">
    
          <ext-sleep>30</ext-sleep>
          
        </block>
       
        <block name="'Block C'">
    
          <parallel>
            <ext-delay>10</ext-delay>
          </parallel>
          
        </block>
        
        <block name="'Block D'">
    
          <parallel>
            <ext-wait>8</ext-wait>
          </parallel>
    
        </block>
    
       </parallel>
    
      </function>
    
    </stax>
    
  6. Save the file and run it via the STAX Monitor. You should see 4 progress bars, representing the Delay elements, in the "Active Job Elements" tree. Also note that STAX extensions can provide aliases (you can use <ext-delay>, <ext-sleep>, or <ext-wait>, which all do the same thing).