17 Defining and Using Job Sets

This chapter describes how to define and submit an Oracle Enterprise Scheduler job set, a collection of job definitions that can be grouped together to run as a single unit.

This chapter includes the following sections:

17.1 Introduction to Defining and Using Job Sets

Oracle Enterprise Scheduler provides for collections of job definitions that can be grouped together to run as a single unit called a job set. A job set may be nested; thus a job set may contain a collection of job definitions or one or more child job sets. Each job definition or job set included within a job set is called a job set step.

A job set is defined as either a serial job set or a parallel job set. At runtime, Oracle Enterprise Scheduler runs parallel job set steps together, in parallel. When a serial job set runs, Oracle Enterprise Scheduler runs the steps one after another in a specific sequence. Using a serial job set Oracle Enterprise Scheduler supports conditional branching between steps based on the execution status of a previous step.

You can define a serial job set to include a parallel job set, or a parallel job set to include a serial job set. Job sets that include a mix of parallel and serial job sets are called complex job sets. For example, when a serial job set contains a child parallel job set, the serial job set runs serially until it reaches the child parallel job set. Then, all the job definitions or job set definitions in the child parallel job set run in parallel. Upon completion of the child parallel job set the serial job set continues running its remaining steps serially. Nested parallel job sets behave the same as non-nested parallel job sets.

For every step in a job set Oracle Enterprise Scheduler supports a property (SYS_selectState) that provides runtime flexibility for how a particular step affects the entire job set. This property is defined on a per step basis. Table 17-1 describes SYS_selectState.


Table 17-1 Job Set Step Property

Property Description

SYS_selectState

Specifies whether the result state of a job set step should be included when determining the state of the job set. Specifies whether the execution state of the step affects the eventual state of entire job set.

By default, all job set steps affect the job set state. To prevent the state of a particular job set step from affecting the state of the job set, set SELECT_STATE to false for that step. To allow the state of a job set step to affect the overall state of the job set, set SELECT_STATE to true for that step.


Oracle Enterprise Scheduler provides the capability for a job set to execute across multiple applications. A job set runs in its hosting application and by default all job set steps also run in this application.

17.2 Defining Job Sets

You can define a job set in Oracle JDeveloper by specifying the following:

  • The name, package, and description for the job set

  • The application defined properties for the job set

  • The system properties for the job set

  • Specifying the job set steps

The contents of a job set are specified when you define the job set steps. For example, for a serial job set you specify the name and the execution mode and then you add the job set steps to define the sequence of job definitions or child job sets that run when the job set runs.

17.2.1 How to Define a Job Set

An Oracle Enterprise Scheduler job set is defined by a name, a package, a job set execution mode, step definitions, application defined properties, and system properties.

To create a job set:

  1. In Oracle JDeveloper, right-click in the project to view the New Gallery.

  2. In the All Technologies tab, under Categories, expand Business Tier and select Enterprise Scheduler Metadata.

  3. Under Items, select Job Set and click OK. This displays the Create Job Set window.

  4. In the Create Job Set window, specify the following:

    1. In the Name field, enter a name for the job set or accept the default name.

    2. In the Package field, enter a package name for the job set.

    3. The Location field displays the full path of the directory where the job set file is stored.

    4. Click OK. This creates the job set and displays the Job Set Definition page, as shown in Figure 17-1.

      Figure 17-1 Job Set Editor with Serial Job Set

      Job Set Editor with serial job set
  5. In the Job Set Editor pane, in the Description field enter a description for the job set.

  6. In the Job Set Steps area, select the Parallel or Serial radio button to specify parallel or serial execution mode for the job set.

  7. In the Job Set Editor pane add the job set steps. For more information on adding job set steps, see How to Define Serial Job Set Steps or How to Define Parallel Job Set Steps.

  8. In the Application Defined Properties area, click Add to add properties associated with the job set. You use these to represent an application-specific or step-specific application defined property for the job set. For more information on using application defined properties, see Introduction to Using Parameters and System Properties. For more information, see What You Need to Know About Job Set Level Parameter Materialization.

  9. In the System Properties area, click Add to add system properties associated with the job set. For more information on using system properties, see Using System Properties.

  10. In the Access Control area, click Add to modify the list of roles that have access to this metadata, along with their access levels. For more information on defining access, see Oracle Enterprise Scheduler Security .

  11. In the Localization area, enter the following information for localizing this job set:

    • Resource Bundle Base Name -- The base name for the resource bundle that specifies internationalized values.

    • Display Name Resource Key -- The resource key that specifies the display name value in the resource bundle.

    • Description Resource Key -- The resource key that specifies the description text in the resource bundle.

  12. Save the job set.

17.2.2 How to Define Serial Job Set Steps

To define serial job set steps you select the serial execution mode and then add job set steps. Job set steps are created from the available job definitions and job sets defined in the current project. You define serial job set steps when you specify a step ID and a job definition child job set definition associated with the step. You also define links from a job set step terminal states to specify the next step. Table 17-2 lists the possible terminal states that you can specify using JDeveloper.


Table 17-2 Job Set Serial Execution Step Terminal States

Terminal State Description

SUCCEEDED

Oracle JDeveloper indicates this state with a check mark button. This path represents a child step or child job set was successfully processed by the system.

WARNING

Oracle JDeveloper indicates this step with a warning button. A child step or child job set resulted in a warning.

ERROR

Oracle JDeveloper indicates this step with an error button. Some aspect of the request to run the child step or child job set processing resulted in an error.


To add serial job set steps:

  1. First, define the appropriate job definitions or job sets and define the parent job set to contain the steps.
  2. In the Job Set Editor pane, in the Job Set Steps area, select Serial execution mode.
  3. Click the Add button to add a job set step. This displays the Add Step window.
  4. In the Step ID field, enter the step ID. For example, enter step1.
  5. In the Job field, from the dropdown list select a job definition or a job set to associate with the step. For example, select Job1.
  6. If you need to define step level application defined properties, then select the Application Defined Properties tab and add properties for the step.
  7. If you need to define step level system properties, then select the System Properties tab and add job set step system properties for the step.
  8. Select a destination for the step. The step can be added as part of the job set by selecting Insert into main diagram. To make the step available for use in another step, for either error or warning states, select Add to list of available steps.
  9. Click OK, this adds the job set step, as shown in Figure 17-2.

    Figure 17-2 Job Set with a Step Added

    Job set with a step added
  10. From the dropdown list next to the error icon, select Stop or select the step for the ERROR terminal state for the step. For example, from the dropdown list select Step_error (Step_error must be defined).
  11. From the dropdown list next to the warning icon, select Stop or select the step for the WARNING terminal state for the step. For example, from the dropdown list select Step_warning (Step_warning must be defined).
  12. Click the Add button and add additional steps as needed.
  13. Click OK, as shown in Figure 17-3.

    Figure 17-3 Job Set with Two Steps Added

    Job set with two steps added

17.2.3 How to Define Parallel Job Set Steps

You can add parallel job set steps to a job set.

To add parallel job set steps:

  1. First, define the appropriate job definitions and job set definitions and the parent job set.
  2. In the Job Set Editor, select the Parallel execution mode.
  3. Click the Add button to add a job set step to the job set.

    The Add Step window displays.

  4. In the Job field, select a job definition or a job set.
  5. If you need to define step level application defined properties, then select the Application Defined Properties tab and add properties for the step.
  6. If you need to define step level system properties, then select the System Properties tab and add job set step system properties for the step.
  7. Click OK, this adds the job set step.
  8. Click the Add button.
  9. In the Add Step dialog, select the job set or job definition to use for next job in the parallel job set.
  10. Click OK. The job set step displays in the job set, as shown in Figure 17-4.

    Figure 17-4 Adding Job Set Steps to a Parallel Job Set

    Adding job set steps to a parallel job set

17.2.4 What Happens When You Define a Job Set

When you define a job set with Oracle JDeveloper, Oracle JDeveloper creates an XML file containing elements that represent the steps that you define.

When you define a parallel job set you specify a set of job set steps that run together. A parallel job set only contains steps, and does not contain links between steps, as all the steps execute together and do not depend on each other or upon the order in which each step runs.

When you define a job set Oracle JDeveloper creates an XML document that conforms to the Oracle Enterprise Scheduler job step schema.

17.2.5 What You Need to Know About Serial Job Sets

When you define a serial job set, the associated XML document includes job set steps and links. Oracle Enterprise Scheduler enforces the following limitations for serial job set definitions:

  • To prevent looping within a job set, job set definitions should not contain circular execution paths. A circular execution path, or a loop, is defined at the job set level as follows: loop is a path from one job set step along the links of any number of other steps back to the same job set step. For example, in a job set with a flow from Job_A, to Job_B, to Job_C defined, Oracle Enterprise Scheduler does not allow you to define an execution path from Job_B or Job_C back to Job_A. For example you could a create circular execution path, or a loop, if one of the links in a job set step for success, error, or warning links back to the same job set step. Thus, each job set step can link to any of the available job definitions or job sets, or they could all use the same job definition or job set as a link for the success, error and warning case. There is only a possible loop based on the path through the job set steps, as identified by the job set step ID. Oracle Enterprise Scheduler validates job sets at submission time to try to prevent job set step level looping. Also, Oracle JDeveloper does not allow you to create a job set containing a job set step level loop.

  • To prevent looping within a job set, job set definitions should not contain self-referencing execution paths. For example, in a job set with Job_B defined, Oracle Enterprise Scheduler does not allow you to define an execution path from Job_B to Job_B itself if Job_B ends up with a terminal state of ERROR. However using the RETRIES property available for a job definition or a job set, you can have multiple executions up to the configured RETRIES number.

  • When there is no job set link defined for a terminal state of a step, it implies that the job set should stop if the step ends with the unspecified terminal state. For example if there is no link defined for a step Job_D for the state WARNING, and if the step Job_D ends up with the state of WARNING, the job set stops execution.

Each job set step can be defined to use any of the available job definitions or job sets, and multiple steps may use the same job definition or job set.

17.2.6 What You Need to Know About Job Set Application Defined Properties and System Properties

There are cases where job set application defined properties or system properties may conflict with application defined properties or system properties set either in metadata or when a job request is submitted. For more information on how job set application defined properties and system properties are handled, see Using Parameters with the Metadata Service and Using Parameters with the Runtime Service.

17.2.7 What Happens at Runtime for Job Set State Priorities and State Transitions

At runtime, the individual steps in a job set can end up with different terminal states, as indicated in Table 17-2. When a job set step is a job set, the job set step also ends with one of these terminal states. Oracle Enterprise Scheduler provides a priority hierarchy for the terminal states of job set steps. This means that when there are multiple steps in a job set, the job set terminal state is applied the terminal state of the step with the highest priority terminal state. Thus, the highest priority terminal state of the steps determines the resulting state for the entire job set.

The resulting state of a job set affects all subsequent state dependent processing within the system. A job set always follows the basic rule of transitioning to a terminal state based on the terminal states of its child requests, only after the completion of all child requests. As a rule, the job set transitions to one of the computed terminal states only after all child requests have finished and transitioned to terminal states. For example, if a given job set is actually a step within another job set, then the way in which the state of the inner job set request is computed affects the conditional execution within the outer job set.

Table 17-3 shows the possible job set terminal states with the level indicated in the Priority column.


Table 17-3 Job Set Terminal State Transitions

Terminal State Description Priority

ERROR

If any step in a job set finishes with the terminal state of ERROR, the entire job set is marked with the terminal state of ERROR no matter what the state of the other steps.

For serial job sets, if one step goes to ERROR, subsequent steps do not execute. For parallel job sets, all steps begin at the same time, and the job set state is not determined until the job set steps reach a terminal state.

The ERROR state has the highest priority.

WARNING

If any step in a job set ends up with the terminal state of WARNING, and there is no step with the terminal state of ERROR then the job set is marked with the terminal state WARNING. When the terminal state is WARNING, post processing begins.

Lower than ERROR

EXPIRED

The job set transitions to EXPIRED state if at least one of the child requests expires while there is no step that ends with the terminal state of ERROR or WARNING.

Lower than ERROR and WARNING

CANCELLED

Based on the actual outcome of a cancellation attempt, the job set can transition to CANCELLED if at least one child request successfully processes the cancellation attempt and transitions to CANCELLED state. The cancellation might have been requested on the entire job set or just a specific child request.

Further the transition to CANCELLED follows the priorities of terminal states. Therefore the job set transitions to CANCELLED terminal state only if there is no step that ends with the state of ERROR, WARNING, or EXPIRED and there is at least one step with terminal state of CANCELLED.

When a job set is canceled, steps that have not been added or run are considered to be CANCELLED for the purpose of final state.

Lower than ERROR, WARNING, and EXPIRED

SUCCEEDED

The job set is considered as SUCCEEDED if and only if all child requests completed with the terminal state of SUCCEEDED.

The SUCCEEDED state has the lowest priority among all terminal states


Table 17-4 lists additional possible states for a job set:


Table 17-4 Possible Job Set Runtime States

State Description

WAIT

This is the initial state of the submitted job set request. After the job set request transitions to RUNNING state, however, all generated child requests transition directly to READY state rather than WAIT state.

READY

Job sets go from WAIT to READY to RUNNING. This is true for all job set steps, whether the step is a job definition or nested job set.

RUNNING

The submitted job set transitions from WAIT to READY to RUNNING. Nested job sets start in READY and transition to RUNNING.

CANCELLING

A job set transitions to CANCELLING when the user requests a cancellation for the entire job set. This can be done by calling cancelRequest() with the request ID of the parent request representing the job set. Passing the parent request ID indicates that the user wants to cancel entire job set irrespective of its current, non-terminal, state and the states of its child requests.

In such cases, a cancellation is attempted on all child requests that are still active and have not already transitioned to a terminal state.

On the other hand if cancellation is attempted only on a specific child request in the job set, there won't be any state change for the parent request and only the particular child request transitions to CANCELLING if possible.

If the cancel happens during post-processing, the state is set to WARNING rather than CANCELLED. If the job set finishes before the cancel is issued, the job set can have state SUCCEEDED.

COMPLETED

This state indicates that the job set or job set step has finished executing and post-processing begins.

BLOCKED

The BLOCKED state is not a terminal state. However any request can remain in a BLOCKED state for a long period until the blocking condition is eliminated (such as incompatibility).

In the case of a job set, any individual step might be BLOCKED while other steps either complete or may be running. The job set itself, however, remains in a RUNNING state. Eventually if all steps in the job set complete except the ones that are in the BLOCKED state, the job set cannot continue further until the blocking step is ready to run. When the blocked step unblocks and completes, the job set can proceed. After the steps complete, the job set eventually goes to the appropriate terminal state.

For a serial job set, the job set may stop at a step that is in BLOCKED state. In such cases, all previous steps are complete and the job set cannot continue until the blocked step executes.

However for a parallel job set, multiple steps can remain in BLOCKED state. Further, while some steps are blocked, other steps can still continue to run.

HOLD

The HOLD state is very similar to the BLOCKED state. Following the same rules for the BLOCKED state, a job set cannot continue running while a step is in HOLD state. A serial job set cannot continue if the current step in the execution flow is stuck at HOLD state. In the case of a parallel job set, if at least one step is stuck in HOLD state while all other steps have completed, the job set can complete when the step is no longer in HOLD state.


17.3 Cross Application Job Sets

Oracle Enterprise Scheduler provides the capability for a job or a job set to execute across multiple applications as shown in Figure 17-5:

  • Job set FIN has three steps, two of which are defined to execute in different applications.

  • Job set FIN is submitted to the GL application.

  • Step 1 has the EFFECTIVE_APPLICATION system property set to ODI, so Step 1 executes in the ODI application.

  • Step 2 does not have an effective application set, so it executes in the GL application.

  • Step 3 has the EFFECTIVE_APPLICATION system property set to INV, so Step 3 executes in the INV application.

Figure 17-5 Cross Application Job Set Steps

Cross application job set steps

17.3.1 Overview of Cross Application Job Sets

A job set runs in its hosting application and by default, all job set steps also run in this application. The system property SYS_effectiveApplication should be defined on the job definition or job set (rather than the job set step). For a nested job set that defines SYS_effectiveApplication, the application applies to any child requests of that nested job set. If it is a nested job set, the jobs in the nested job set execute in the effective application. When SYS_effectiveApplication is defined for a job, the request for the job set and any child requests of the job set are associated with the effective application, meaning the APPLICATION system property for those requests is set to the effective application.

The SYS_effectiveApplication system property may only be defined in metadata, specifically job set, job set step, job type, and job. The property SYS_effectiveApplication is not supported in the request parameters. The effective application must be in the same cluster as the hosting application, or an error results. If a submitted job set defines the effective application, that value must be the same as the hosting application, or the job set submission is rejected.

For a job set that executes across multiple applications, querying for requests by application is not sufficient to retrieve all children. Oracle Enterprise Scheduler supports absolute parent ID as a query field, making it possible to query for all requests in a job set regardless of the application. The absolute parent ID is the request ID of the job set that was submitted to the hosting application.

17.3.2 Requirements for Cross Application Job Sets

Oracle Enterprise Scheduler supports cross-application job set subject to the following requirements:

  1. All applications for a given job set must be deployed in the same cluster.

  2. All applications in the job set must share the same enterprise security.

  3. All request metadata must be accessible from the application the job set is submitted to, referred to as the hosting application. All metadata for the request are persisted to the runtime store for the hosting application. The persisted metadata include all metadata used by the submitted job set and any nested job set.

  4. Metadata for subrequests must be accessible from the application that submits the subrequest, unless the metadata used by the subrequest were already persisted to the runtime store at job set submission time.

17.4 Supporting Input and Output Forwarding in Job Sets

Sometimes a step in a job set requires input from the previous step in the job set. Oracle Enterprise Scheduler uses two system properties SYS_inputList and SYS_outputList to facilitate forwarding the output from one step to the input of the next step.

When a job produces information, such as a list of output files, that must be passed on to the next step in a job set, the job adds the information to the SYS_outputList property. Upon completion of the job request execution, Oracle Enterprise Scheduler forwards the SYS_outputList property of the request so that it becomes the SYS_inputList property of the next step before it executes. The next step takes as its input the output of the previous step.

A job set step can be a single job or a job set, Oracle Enterprise Scheduler supports forwarding with nested job sets as well. For a serial job set, Oracle Enterprise Scheduler defines the output of the job set as the output of the last step of the job set, meaning that only the SYS_outputList property of the last step is forwarded to the next step. Similarly, the input to a serial job set is forwarded only to the first step of the job set; that is, only the first step of a serial job set has the SYS_inputList property set to the value of the SYS_outputList property of the previous step.

For a parallel job set, Oracle Enterprise Scheduler specifies that the output of the job set is the concatenation of the SYS_outputList property of every job in the job set, separated by a delimiter (with no order guaranteed). The input to a parallel job set is forwarded to every job in the job set, meaning that every job in the parallel job set has the same INPUT_LIST property. The system property OUTPUT_LIST_DELIMITER specifies the delimiter used when listing output files.

Suppose a job set has two jobs, each job producing its own output file, file1.txt and file2.txt. The system property SYS_outputList for that job set has the values file1.txt;file2.txt, assuming the value of OUTPUT_LIST_DELIMITER is a semi-colon. The concatenated list of output files enables the next job step in the job set to access output files generated by previous steps within the job set.

The InputFile class provides access to files as input to a job definition. There is currently no mechanism for accepting a file as an input to a job request.

Except for forwarding the value of the SYS_outputList property of a step to the value of the SYS_inputList property of the next step, Oracle Enterprise Scheduler treats the two properties like any other system properties. Oracle Enterprise Scheduler does not define the format for the value of the properties (except for the semicolon delimiter in case of parallel job set). It is the responsibility of the job to define the syntax and semantics for the properties; for example using a fully qualified name or relative path name and a comma or space as a delimiter.