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

Compare with Current View Page History

« Previous Version 2 Next »

We assume that we have a job in a job chain, to be executed on a JobScheduler Agent.
This requires a process_class that is assigned to the job.

Please read here to know how you create the process class for a JobScheduler Agent and how you assign it to a job.

Now we assume that we have multiple JobScheduler Agents and we want that a job executes on different JobScheduler Agents depending on parameters.

 *Create a process class (e.g. with the name _agents_) in JOE with {*}empty{*} values for _host_ and _port_.
 The values for host and port are set dynamically.
 So you get the following configuration file _./config/live/agents.process_class.xml_:
 <?xml version="1.0" encoding="ISO-8859-1"?>
 
 <process_class max_processes="30"/>  
  • Assign the process class to the order job in JOE. In this example the job is named shell_on_dynamic_agent and calls hostname as shell command.
     So you get the following configuration file _./config/live/shell_on_dynamic_agent.job.xml_:
    
     <?xml version="1.0" encoding="ISO-8859-1"?>
     
     <job process_class="agents" order="yes">
         <script language="shell">
             <![CDATA[
     #! /bin/sh
     # returns the hostname of the agent
     hostname
             ]]>
         </script>
         <run_time/>
     </job>  
    
  • Extends the job with a preprocessing.
     The [JobScheduler API|http://www.sos-berlin.com/doc/en/scheduler.doc/api/api.xml] is used to set the _remote_scheduler_ attribute of the process class to provide that the job is executed on a JobScheduler Agent.
     The preprocessing script requires the two order parameters _agent_host_ and _agent_port_.
     Here the preprocessing is implemented in javascript and has the following code:
    
     function spooler_task_before()\{
    	var agentHost = spooler_task.order.params.value('agent_host');
    	var agentPort = spooler_task.order.params.value('agent_port');
    	spooler_log.info("The agent " + agentHost + ":" + agentPort + " will be used.");
    	spooler_job.process_class.remote_scheduler = agentHost+":"+agentPort;
     \}  
    
     After you have added the postprocessing you get the following configuration file _./config/live/shell_on_dynamic_agent.job.xml_:
    
     <?xml version="1.0" encoding="ISO-8859-1"?>
     
     <job process_class="agents" order="yes">
         <script language="shell">
             <![CDATA[
     #! /bin/sh
     # returns the hostname of the agent
     hostname
             ]]>
         </script>
         <monitor  name="set_agent" ordering="0">
            <script  language="javascript">
                <![CDATA[
     function spooler_task_before()\{
    	var agentHost = spooler_task.order.params.value('agent_host');
    	var agentPort = spooler_task.order.params.value('agent_port');
    	spooler_log.info("The agent " + agentHost + ":" + agentPort + " will be used.");
    	spooler_job.process_class.remote_scheduler = agentHost+":"+agentPort;
     \}
                ]]>
            </script>
         </monitor>
         <run_time/>
     </job>  
    
  • Put the job into a job chain (e.g. job_chain_with_agent_job).
     So you have the configuration file _./config/live/job_chain_with_agent_job.job_chain.xml_:
    
     <?xml version="1.0" encoding="ISO-8859-1"?>
     
     <job_chain  orders_recoverable="yes" visible="yes">
        <job_chain_node  state="100" job="shell_on_dynamic_agent" next_state="success" error_state="error"/>
        <job_chain_node  state="success"/>
        <job_chain_node  state="error"/>
     </job_chain> 
    
  • Add an order to the job chain job_chain_with_agent_job for each JobScheduler Agent you want.
     For example one agent is on HostA with port 4444 and another agent is on HostB with port 4444.
     The orders must have the parameter _agent_host_ and _agent_port_.
     So you have the configuration files _./config/live/job_chain_with_agent_job,hostA-4444.order.xml_ and _./config/live/job_chain_with_agent_job,hostB-4444.order.xml_  :
    
    <?xml version="1.0" encoding="ISO-8859-1"?>
    
    <order>
        <params >
            <param  name="agent_host" value="HostA"/>
            <param  name="agent_port" value="4444"/>
        </params>
        <run_time/>
    </order>
    
    <?xml version="1.0" encoding="ISO-8859-1"?>
    
    <order>
        <params >
            <param  name="agent_host" value="HostB"/>
            <param  name="agent_port" value="4444"/>
        </params>
        <run_time/>
    </order>
    
  • No labels