You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Current »

Solution Components

Job: sync

Define a sync job. Add the parameter ParallelExecution_required_orderh1. 2 and ParallelSample_required_orders1. The value of ParallelExecution_required_orders is the number of entry points in the job chain ParallelExecution (see below).

 

 <?xml version="1.0" encoding="ISO-8859-1"?>
  <job order="yes">
    <params>
        <param name="ParallelExecution_required_orders" value="2"/>
        <param name="ParallelSample_required_orders"    value="1"/>
    </params>
    <script language="java"
            java_class="sos.scheduler.job.JobSchedulerSynchronizeJobChains"/>
    <run_time/>
 </job>

Job: execute

Define a job execute. This is Javaccript API job, which will create orders for the parallel execution. Set the parameter job_chain to the value /SampleParallel/ParallelExecution.

 

 <?xml version="1.0" encoding="ISO-8859-1"?>
 <job order="yes">
    <params>
        <param name="job_chain"  value="/SampleParallel/ParallelExecution"/>
    </params>
    <script language="javascript"><![CDATA[
 		function spooler_process() {
		   	var actOrder = spooler_task.order;
   			var order = spooler.create_order();
   			var job_chain = spooler.job_chain( spooler_task.params.value( "job_chain" ) );
   			order.state = actOrder.state;
   			order.params.merge(actOrder.params);
   			order.id = order.state + ":" + actOrder.id;
   			job_chain.add_or_replace_order(order);   
   			return true;
 		}
    ]]></script>
    <monitor name="configuration_monitor"
             ordering="0">
        <script java_class="sos.scheduler.managed.configuration.ConfigurationOrderMonitor"
                language="java"
                java_class_path=""/>
    </monitor>
    <run_time/>
 </job>

Job Chain: ParallelExecution

Define a job chain ParallelExecution. This job chain has several entry points. One for each parallel execution.
In this example we have two entry points named p1 and p2. p1 has a next state and p2 just executes one job. Both ends at sync.

 

 <?xml version="1.0" encoding="ISO-8859-1"?>
 <job_chain orders_recoverable="yes">
    <job_chain_node state="p1"
                    job="ParallelJob1"
                    next_state="p1.b"
                    error_state="error"/>
    <job_chain_node state="p1.b"
                    job="aJob"
                    next_state="sync"
                    error_state="error"/>
    <job_chain_node state="p2"
                    job="ParallelJob2"
                    next_state="sync"
                    error_state="error"/>
    <job_chain_node state="sync"
                    job="Sync"
                    next_state="success"
                    error_state="error"/>
    <job_chain_node state="success"/>
    <job_chain_node state="error"/>
 </job_chain>

Job Chain: ParallelSample

Define a job chain ParallelSample. This job chain starts the jobs that are to be executed in parallel and can have one scheduled order. There can also be steps before and after the jobs to be executed in parallel. Add a step for each job to be executed in parallel. The state of this step must be the same as in job chain ParallelExecution. In this example it is p1 and p2.

 

 <?xml version="1.0" encoding="ISO-8859-1"?>
 <job_chain orders_recoverable="yes"
           visible="yes">
    <job_chain_node state="100"
                    job="anyJobBefore"
                    next_state="p1"
                    error_state="error"/>
    <job_chain_node state="p1"
                    job="execute"
                    next_state="p2"
                    error_state="error"/>
    <job_chain_node state="p2"
                    job="execute"
                    next_state="sync"
                    error_state="sync"/>
    <job_chain_node state="sync"
                    job="Sync"
                    next_state="200"
                    error_state="error"/>
    <job_chain_node state="200"
                    job="anyJobAfter"
                    next_state="success"
                    error_state="error"/>
    <job_chain_node state="success"/>
    <job_chain_node state="error"/>
 </job_chain>

Add an order for the job chain ParallelSample. You can assign a schedule for this order.

 

 <?xml version="1.0" encoding="ISO-8859-1"?>
 <order>
    <run_time>
        <period single_start="10:00"/>
    </run_time>
 </order>

Related Downloads

You can download the source for this example from here.

 

  • No labels