Background

It is a common case that you need to run calculation jobs in a certain sequence or with dependencies, e.g., CFSs prior to LPGs or various Data Loads in Analytics.

A typical scenario looks like this: There is a file loaded to Analytics once per day and IntegrationManager triggers a Data Feed → Data Source Flush job. You want to define that the data will end up in the Datamart as soon as possible, so you define that a Data Source → Datamart Refresh job gets triggered once the Data Feed → Data Source is finished for any of the depending data sources.

Another scenario assumes that there is a CFS running on the Product master triggered by IntegrationManager. You want to define that LPG gets triggered once the CFS finishes.

Solution

There is a "Jenkins style" dependent jobs solution available. The dependent jobs are passed in as an extra parameter (JSON API or calculation flow) for the main job. That means that the dependencies are not statically defined. This approach has a number of notable effects:

The main job control is implemented in a data structure like this:

public class ChainedJobInfo {
private boolean executeOnError;
private List<ChainedJobInfo> nextJobs;
private String targetObject;
private Map<String,Object> parameters;
}

This class is also covered in the Groovy API Documentation.

This structure can be passed into the calculation flow actions as well as injected in JSON API like this:

{
	"data": {
		"nextJobs" : [
			{
				"executeOnError" : true,
				"targetObject":"38.CFS"
,
				"nextJobs" : [ ... ]
		}
		]
	}
}

The above would calculate LPG with ID 155 and then CFS with ID 38, and if the inner nextJobs would be filled, some more jobs after that CFS.

Please note: The type of jobs that can be scheduled are those that run within the so called "Job Status Tracker" framework. The parameters that are required for a job to properly run can vary by job type. Best is to pick a manually started JST job from the admin console as an example. The chaining is only implementing a sequential order of jobs being executed. There is no contextual "wrapper" of any kind within that chain. I.e., no back or forward references or "knowledge" where in the chain a job is running.

How to Synchronize Dependent Jobs (Advanced Use Case)

Example requirement: One job A that spawns child jobs A1, A2 and A3. Once these three are all done, job B (or more) should be triggered.

This could be implemented as follows: