Learning Pentaho Data Integration 8 CE(Third Edition)
上QQ阅读APP看书,第一时间看更新

Changing the flow of execution based on conditions

The execution of any Job entry either succeeds or fails. For example:

  • Mail entry succeeds if PDI can send the message, but it fails if the specified SMTP host is unknown
  • ZIP file entry succeeds if PDI can zip the specified files, but will fail if the ZIP file existed and you configured the entry for failing in case PDI hits that condition
  • Create a folder succeeds if PDI can create the folder, but fails if the folder existed or there were no permissions for creating it

Whichever the Job entry and based on the result of its execution, you decide which of the entries following the entry execute and which don't.

In particular, the Job entries under the Conditions category just evaluate a condition and succeed or fail upon the result of the evaluation. As an example, the Checks if files exist entry looks for the existence of a file. If the condition evaluates to true, that is, if the file exists, the entry succeeds. If the file doesn't exist, the entry fails.

So, when you create a Job, you not only arrange the entries and hops according to the expected order of execution, but also specify under which condition each Job entry runs.

You define the conditions in the hops. You can identify the different hops either by looking at the color of the arrow or at the small icon on it. The following table lists the possibilities:

Execution conditions

At any hop, you can define the condition under which the destination Job entry will execute. In most cases, the first hop that leaves an entry is created green. The second hop leaving the entry is created red. To change the color, that is, the behavior of the hop, do any of the following:

  • Right-click on the hop, select Evaluation, and then the condition.
  • Click on the small icon on the hop. Each time you click on it, the type of hop changes.

There are two kinds of hops which you can't edit:

  • The hop or hops that leave the START entry, mandatory in every Job
  • The hop or hops that leave the Dummy entry, a special entry that does nothing and in general is used just as a placeholder

In both cases, the destination Job entries always execute unconditionally.

Finally, a hop can also look light grey. This means that the hop has been disabled. If you don't want an entry to be executed (mainly for testing purposes), you can disable the incoming hop or hops. You do it by right-clicking the hop and selecting Disable. An easier way to do it is by clicking the hop in any place but the small icon on the hop. To revert the status, you can click the hop again in the same way.