Table of Contents |
---|
Scope
The Join Job (JobSchedulerJoinOrders) is used to join up two parallel executing child segments in a Job Chain. It then continues processing in a single thread once processing of the parallel threads has been completed. It is used in two Job Chain Patterns - Split and Join and "Y".
...
- See the How To Synchronize Job Execution Across Job Chains article for information about synchronizing Jobs in different Job Chains and for joining up parallel executing child Job Chain segments in JobScheduler versions 1.11.3 and older.
Join Patterns
The example described in this article shows the use of a single instance of the Join Job within a single Job Chain. Multiple instances of the Join Job can also be used within a Job Chain. See the Configuration section of the JobSchedulerJoinOrders documentation for more information.
split and join Pattern
The configuration of the Join Job for the Split and Join pattern is described in the How to Execute Jobs in a Job Chain in Parallel article.
...
The ID set for each of the child Job Chain segment Orders is made up from the ID of the main Order and state in the Job Chain of the first Job in the child Job Chain segment.
'Y' Pattern
The following diagram shows the "Y"-pattern Job Chain used in the example download archive that is linked from this article. Note that some of the elements in this pattern have been given particular functions to provide a working example of the Join Job and are not required for its operation in "normal" use.
Flowchart |
---|
main [label="Order:main_order",fillcolor="green"] generate [label="generate",fillcolor="lightskyblue"] add [label="Order:main_order_add-order",fillcolor="green"] wait [label="wait",fillcolor="lightskyblue"] 150 [label="150",fillcolor="lightskyblue"] 160 [label="160",fillcolor="lightskyblue"] join [label="join",fillcolor="lightskyblue"] 200 [label="200",fillcolor="lightskyblue"] success [label="success",fillcolor="orange"] main -> generate generate -> wait wait -> 150 150 -> join add -> 160 160 -> join join -> 200 200 -> success |
Solution
- Download the example y_join.zip.
- Extract the archive to a folder
./config/live
of your JobScheduler Master installation. - The archive will extract the files to a folder
y_join.
- The
y_join
folder can be renamed if required, the solution does not require the use of specific folder or Job names.
Example Description
The Join Job has basically a counting function. This makes it significantly faster than the Sync Job which checks the IDs of the jobs being processed.
...
Note that Child Orders such as the generated Orders or the manually configured the main_order_add-order Order in this example will only be recognized as such when they are started after the Parent Order has been started.
The Job Chain, Jobs and Orders
The Job Chain
The Job Chain ...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<?xml version="1.0" encoding="ISO-8859-1"?> <job_chain title="Y Join"> <job_chain_node state="100" job="generate_orders" next_state="wait" error_state="error"/> <job_chain_node state="150" job="job_a" next_state="join" error_state="error" delay="10"/> <job_chain_node state="wait" job="wait" next_state="join" error_state="error"/> <job_chain_node state="join" job="join" next_state="200" error_state="error"/> <job_chain_node state="200" job="job_b" next_state="success" error_state="error"/> <job_chain_node state="success"/> <job_chain_node state="error"/> </job_chain> |
The Jobs
The Join Job
The configuration of the Join Job is set using the Wizard in following code block:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<?xml version="1.0" encoding="ISO-8859-1"?> <job order="yes" stop_on_error="no" idle_timeout="60" title="Join Job"> <settings > <log_level ><![CDATA[debug9]]></log_level> <history_on_process ><![CDATA[0]]></history_on_process> <history_with_log ><![CDATA[gzip]]></history_with_log> </settings> <params > <param name="show_join_order_list" value="true"/> </params> <script language="java" java_class_path="" java_class="com.sos.jitl.join.JobSchedulerJoinOrdersJSAdapterClass"/> <run_time /> </job> |
The generate_orders Job
The configuration of the generate_orders Job is shown in the next code block along with the script responsible for the generation of the Child Orders.
Note that this Job is only used to create the current demonstration of the Join Job and in is not required for the Join Job itself.
...
- This Job contains a script that generates the Child Orders (see lines 20 - 31 of the listing). The Orders are alternated between the two branches of the Job Chain (even numbered Orders start at the Job corresponding with the Order state 150 and odd numbered Orders at the Job corresponding with the Order state 160). All Child Orders terminate at the Join Job.
The Orders
The Parent Order
The Parent Order, in this example, with ID main_order has the following 3 parameters:
...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<?xml version="1.0" encoding="ISO-8859-1"?> <order > <params > <param name="required_orders" value="12"/> <param name="wait_time" value="35"/> <param name="generate_orders" value="10"/> </params> <run_time /> </order> |
The Child Orders
The generated Child Orders
Have the ID of the Parent Order (main_order) + "_" + * where * is a string - in the current example simple numbers are used a string.
...
depending on which branch of the Job Chain they should be executed on.
The main_order_add-order Order
Has the ID of the Parent Order (main_order) + "_" + * where * is a string - in the current example "add-order" is used.
...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<?xml version="1.0" encoding="ISO-8859-1"?> <order state="150" end_state="join"> <run_time /> </order> |
.....
Logging
A parameter can be set for the Join Job - show_join_order_list. When this parameter is set to true the all the Child Orders counted by the join job will be listed in the Parent Order log file.
...