Sequence jobs

Build sequence jobs to run multiple jobs in conjunction with other jobs. By using sequence jobs, you can integrate programming controls into your job workflow, such as branching and looping.

You create the sequence job on the job design canvas and add stages. The stages that you add are known as activities. When you link two activities together, you define the triggers that define the flow of control. The job sequence includes properties and can have parameters, which are passed to the activities in the sequence job.

Each activity also contains properties that are passed to other activities in the sequence job. As with stages, you can define job parameters for each activity. You can test the parameters in the trigger expressions, and pass the parameters to other activities in the sequence job.

The following activities are supported:

Annotation

You can use annotations for a wide variety of purposes throughout your job design. For example, you can use annotations to explain, summarize, or describe a job design or to help identify parts of a job design. You enter annotation text yourself and you can add as many of this annotations as required. Use it to annotate stages and links in your job design.

Annotations do not obstruct the display of the stages, links, or other components in your job design.

Nested condition

Use a Nested Condition stage to further branch the execution of a sequence job, depending on a condition.

Each nested condition can have one input trigger and typically has multiple output triggers. For example, you could use a Nested Condition stage to implement the following control sequence.
Load/init jobA
Run jobA
If ExitStatus of jobA = OK then /*tested by trigger*/
   If Today = "Wednesday" then /*tested by nested condition*/
      run jobW
   If Today = "Saturday" then
      run jobS
Else
   run JobB
You specify the conditions that determine the sequence of actions for each output triggers on the Triggers tab. For example, you might link an ExecCommand stage to your Nested Condition stage. In the Triggers tab of the Nested Condition stage, you enter the following expression.
DayCommand.$CommandOutput = "Wednesday"

This expression indicates that the ExecCommand stage runs the DayCommand activity, which returns the value of the $CommandOutput variable. In this case, the value Wednesday is displayed as the command ouput.

Endloop activity

The end loop stage marks the end of the loop.

All the stages in between the Start Loop and End Loop stages are included in that loop. You draw a link back to the Start Loop activity stage that this stage is paired with.

The stage has no special properties.

Exception handler

There are some exception handler variables that can be used in the sequence of activities that the Exception Activity stage initiates. These are:

  • stage_label.$ErrSource. This is the stage label of the activity stage that raised the exception (for example, the job activity stage calling a job that failed to run).
  • stage_label.$ErrNumber. Indicates the reason the Exception Handler activity was invoked, and is one of:
    • 1. Activity ran a job but it aborted, and there was no specific handler set up.
    • -1. Job failed to run for some reason.
  • stage_label.$ErrMessage. The text of the message that will be logged as a warning when the exception is raised.

Job activity

Use the Job activity stage to specify information about the job that the job activity runs.

The Job activity stage contains the following fields:
Job name
Use this field to specify the name of the job that the activity runs.
Execution action

Use this option to specify what action the activity takes when the job runs. Choose one of the following options from the list:

  • Run (the default)
  • Reset if required then run
  • Validate only
  • Reset only
Parameters

Use this grid to provide values for any parameters that the job requires. The grid displays all parameters that are expected by the job.

  • Type an expression that specifies a value for the parameter in the Value Expression column. Literal values must be enclosed in inverted commas.
  • Select a parameter and click Default to enter the default for that parameter as defined in the job itself.

Notification activity

Use the Notification stage to specify information about an email notification activity.

An email template file called dssendmail_template.txt dictates the format of the notification email that is sent. A copy of this file exists in every project directory, such as C:\IBM\InformationServer\Server\projects\myproject. You edit this file so that you can use different email formats for each project.

You can specify a parameter whose value you indicate at run time for the SMTP Mail server name field, Senders email address field, Recipients email address field, and Email subject field.

The Notification stage includes the following fields:
SMTP Mail server name
The name of the server or its IP address. You can specify a parameter whose value you indicate at run time.
Senders email address
The email address that the notification is sent from.
Recipients email address
The email address that the notification is sent to. You can specify multiple email addresses, separated by a space.
Email subject
The text that is included in the subject line of the notification.
Attachments
Files to be sent with the notification. Specify a path name or a comma-separated list of pathnames, which must be enclosed in single-quotes or double-quotes. You can also specify an expression that resolves to a pathname or comma-separated pathnames.
Email body
The text that is included in the body of the notification.
Include job status in email
Checkbox that specifies whether you want to include available job status information in the message.

Oozie workflow activity

Use the Oozie Workflow Activity stage to invoke Oozie workflows. Oozie workflows are a collection of actions that are arranged in a control dependency. These actions are computation tasks that are written in Jaql, MapReduce, or other frameworks that you use to write applications to process large amounts of data.

The Oozie Workflow Activity stage contains the following fields:
Oozie server
Specify the URL for the Oozie server to connect to. For example, http://myserver:8280/oozie, where myserver is the name of the Oozie server that you are connecting to. The port number 8020 differs depending on the Hadoop system that you use.
Workflow definition path
Enter the location of the workflow definition that you want to run. A workflow definition is a programmatic description of a workflow in XML format.
You must include the full path to the workflow definition, which is defined as hdfs://host:Hadoop_port/HDFS_application_path/workflow_directory. For example, hdfs://mymachine.host.com:8280/user/biadmin/workflows/aasd-098098098.xml.
host
The machine where your Hadoop application is installed.
Hadoop_port
The port number that your Hadoop application is listening on.
HDFS_application_path
The application path to your Hadoop distributed file system application.
workflow_directory
The directory that contains the workflow.xml that you want to run.
Workflow parameters
Enter values for any parameters that the activity requires. The grid displays all parameters that are expected by the activity.
Name
Type a name for your parameter.
Value Expression
Type an expression that specifies a value for the parameter. Literal values must be enclosed in inverted commas.

Routine activity

The Routine Activity details card consists of a Routine tab and a Triggers tab.

The Routine tab contains:

  • Routine name. Allows you to specify the name of the routine the activity is to execute. You can select a routine from the drop-down menu.
  • Arguments. Allows you to provide values for any arguments that the routine requires. The grid displays all the arguments expected by the routine. You can:
    • Type in an expression giving the value for the argument in the Value Expression column. Literal values must be enclosed in inverted commas.

You can access routine arguments in the activity triggers in the form routinename.argname. Such arguments can be also be accessed by other activities that occur subsequently in the job sequence. This is most useful for accessing an output argument of a routine, but note that BASIC makes no distinction between input and output arguments, it is up to you to establish which is which.

Execute command

Use the ExecCommand stage to specify information about an Execute Command activity.

The ExecCommand stage contains the following fields in addition to the Triggers tab:
Command
The full pathname of the command to execute. This can be an operating system command, a batch command file, or an executable file. You can use a job parameter so that you can specify the actual command at run time.
Parameters
Allows you to pass parameters to the command. These should be entered in the format that the command expects them. You can also specify a parameter whose value will be specified at run time. Parameters entered in these fields need to be delimited with hashes (#).

Sequencer

Use the Sequencer stage to synchronize the control flow of multiple activities in a job sequence. This stage can have multiple input triggers and multiple output triggers.

On the Sequencer tab, you select the operation mode for the Sequencer stage:

All
All of the inputs must be TRUE to trigger any of the sequencer activities.
Any
Activities are triggered if any of the inputs are TRUE.

The Sequencer stage icon changes slightly depending on the mode that you select.

Start loop activity

The Start Loop stage marks the beginning of the loop and defines it.

You can have a numeric loop (where you define a counter, a limit, and an increment value), or a List loop (where you perform the loop once for each item in a list). You can pass the current value of the counter as a parameter into the stages within your loop in the form stage_label.$Counter, where stage_label is the name of the Start Loop activity stage as given in the canvas. You mark the end of a loop with an End Loop Activity stage, which has a link drawn back to its corresponding Start Loop stage.

You can nest loops if required.

You define the loop setting in the Start Loop tab. The tab contains:

  • Loop type. Choose Numeric to implement a For...Next type loop, or List to implement a For...Each type loop.

When you choose Numeric, the tab contains the following fields:

  • From. The initialization value for the counter.
  • Step. The increment value for the counter.
  • To. The final counter value.

You can use parameters for any of these, and specify actual values at run time. Job parameters entered in this field needs to be delimited with hashes (#).

When you choose List, the tab has different fields:

  • Delimited values. Enter your list with each item separated by the selected delimiter.
  • Delimiter. Specify the delimiter that will separate your list items. Choose from:
    • Comma (the default)
    • Space
    • Other (enter the required character in the text field)

Terminator activity

A terminator stage can be placed in a job sequence to ensure that the sequence is stopped cleanly if certain situations arise.

It cannot have output links, and so has no Triggers tab. The stage can have one input.

You can have multiple Terminator activities and can place them anywhere in the sequence. They are connected to other stages by triggers, which specify when a terminator will be invoked.

The terminator stage allows you to specify that stop requests be sent to all running jobs in the sequence (and optionally have the terminator wait for all jobs to finish), or that the sequence is aborted without sending stop requests. If you specify some final message text, this will be used as the text for the sequence abort message. Do not enclose the message in inverted commas unless you want them to be part of the message.

User variable activity

Use the user variable stage to define global variables within a sequence.

These variables can then be used elsewhere in the sequence, for example to set job parameters. Variables are used in the form stage_label.parameter_name, where stage_label is the name of the User Variable activity stage as displayed on the canvas.

The values of the user variables are set by expressions in the stage's properties.

You would most likely start a sequence with this stage, setting up the variables so they can be accessed by subsequent sequence activities. The exit trigger would initiate the sequence proper. You can also use a User Variable activity further into a sequence to change the value of a variable previously defined by an earlier User Variable activity.

The variables are defined on the details card for the stage. To add a variable:

  • Choose Add from the grid.
  • Enter the name for your variable.
  • Supply an expression for resolving the value of the variable.

Wait for file activity

In addition to the General and Triggers tabs, The Properties dialog box for a wait-for-file activity contains a Wait For File tab.

The Wait For File tab contains:

  • Filename. The full path name of the file that the activity is to wait for. Job parameters entered in this field needs to be delimited with hashes (#).
  • Wait for file to appear. Select this if the activity is to wait for the specified file to appear.
  • Wait for file to disappear. Select this if the activity is to wait for the specified file to disappear.
  • Timeout Length (seconds). The amount of time to wait for the file to appear or disappear before the activity times out and completes.
  • Do not timeout. Select this to specify that the activity should not timeout, i.e, it will wait for the file forever.