Scope
- Use Case
- Run a specific job within a job chain in a number of parallel instances, i.e. split a job for parallel processing. Each instance is executed on a different Agent.
- The use case is intended for execution of the same job within a job chain in parallel instances, not for parallel execution of different jobs.
- We assume am application for end of day processing that creates balance sheets for a larger number of accounts. The application is installed on a number of servers each equiped with an Agent. The processing is splitted in a way that each instance of the application processes a chunk of accounts.
- A similar use case is explained with the How to split and sync a dynamic number of job instances in a job chain article, however, this use case is about using a different Agent for each parallel process instead of running parallel processes on the same Master or Agent.
- Synchronize jobs after parallel processing.
- Run a specific job within a job chain in a number of parallel instances, i.e. split a job for parallel processing. Each instance is executed on a different Agent.
- Solution Outline
- The number of parallel job instances is dynamically determined from the numbe of Agents that are available to run the application.
- A number of orders is created for a specific job that would be executed in parallel on different Agents. The number of orders corresponds to the number of Agents and each order is parameterized to process a chunk of accounts.
- Finally the parallel job instances are synchronized for further processing.
- References
Solution
- Download parallel_job_instances_with_agents.zip
- Extract the archive to a folder
./config/live
of your JobScheduler installation. - The archive will extract the files to a folder
parallel_job_instances_with_agents.
- You can store the sample files to a any folder as you like, the solution does not make use of specific folder names or job names.
Pattern
Implementation
Components
- The
end_of_day_split
job reads the process class configuration that is assigned to its successor job which is thecreate_balance_statements
job. It creates the numbe of orders that corresponds to the number Agents.- Each order is added the following parameters
number_of_orders
: the number of orders that have been created.<job_chain_name>_required_orders
: the number of orders that theend_of_day_sync
job waits for. This includes the value of thenumber_of_orders
parameter incremented by 1 for the main order. The prefix is made up of the name of the job chain to allow parallel use of this job with a number of job chains.
- The orders are assigned the state that is associated with the next job node, the
create_balance_statements
job node, i.e. the orders will be executed starting with that state. - The orders are assigned the end state that is associated with the
end_of_day_sync
job.
- Each order is added the following parameters
- The
create_balance_statements
job is configured for a maximum number of 10 parallel tasks via the attribute<job tasks="10">
. It could be configured for any number of parallel tasks. For the sake of this sample the limitation shows the behavior of the job to wait for processes to become free that could be assigned to subsequent orders for the same job. - The
end_of_day_sync
job is used to synchronize splitted orders and is provided by the Sync JITL Job with the Java classcom.sos.jitl.sync.JobSchedulerSynchronizeJobChainsJSAdapterClass
.- This job is used without parameters.
- The end_of_day process class configures a number of Agents.
- Hint: to re-use the
end_of_day_split
job you can- store the job to some central folder and reference the job in individual job chains.
- move the JavaScript code of the job to some central location and use a corresponding
<include>
element for individual job scripts.
Explanations
- x
Explanations
- The process class defines an Active Cluster with round-robin scheduling by use of the
select="next"
attribute: each task for an order gets executed on the next Agent. - The process class specifies a number of Agents that are addressed by the http or https protocol.
Explanations
- The order includes the parameters that specify the range of accounts for which balance sheets are created.
- Any order configuration, e.g. run-time rule, can be added.
Usage
- Start the
end_of_day
order for theend_of_day
job chain by use of JOC. - Consider the processing that would
- split the execution into 3 subsequent orders that run for the
create_balance_statements
job each on a different Agent. - move the current order to the
end_of_day_sync
job node.
- split the execution into 3 subsequent orders that run for the
- The splitted orders for the
create_balance_statements
job will arrive in theend_of_day_sync
job node and will wait for all orders to be completed. With all splitted orders being completed the processing will continue.