Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Assign the process class to the order job in JOE. In this example the job is named shell_on_dynamic_agent shellOnDynamicAgent and calls hostname as shell command.
    No Format
     So you get the following configuration file _./config/live/shell_on_dynamic_agentshellOnDynamicAgent.job.xml_:
    
    Code Block
    languagehtml/xml
     <?xml version="1.0" encoding="ISO-8859-1"?>
     
     <job process_class="agents" order="yes" stop_on_error="no">
         <script language="shell">
             <![CDATA[
     #! /bin/sh
     # returns the hostname of the agent
     hostname
             ]]>
         </script>
         <run_time/>
     </job>  
    
  • Extends Create the following job with a preprocessing.
    Image Removed
    No Format
    
     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:
    
    Code Block
    languagejavascript
    
     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;
     \}  
    
    (e.g. setAgent) and put it into the job chain as the forerunner of the agent job.
    No Format
    
     This job change the process_class setting of the successor job in the job chain according 
    No Format
    
     This code reads the order parameter _agent_host_ and _agent_port_ and writes the _remote_scheduler_ attribute of the job's process class.    
     After you have added the postprocessing you get the following configuration file _./config/live/shell_on_dynamic_agent.job.xml_:
    
    Code Block
    languagehtml/xml
     <?xml version="1.0" encoding="ISO-8859-1"?>
     
     <job process_class="agents" order="yes">
         <script language="shell stop_on_error="no">
             <![CDATA[
     #! /bin/sh
     # returns the hostname of the agent
     hostname
             ]]>
         </script>
         <monitor  name="set_agent" ordering="0"><params />
    
            <script  language="javascript">
                <![CDATA[
     function spooler_task_beforeprocess()\{
    
    	var agentHostcurOrder = spooler_task.order;
    	var agentHost = curOrder.params.value('agent_host');
    	var agentPort = spooler_taskcurOrder.order.params.value('agent_port');
    	var nextJob = curOrder.job_chain_node.next_node.job;
    	spooler_log.info("The agentParams agentHost:agentPort = " + agentHost + ":"+agentPort);
    	spooler_log.info("before: "+ agentPort + " will be used.");
    	spooler_jobnextJob.process_class.remote_scheduler);
            nextJob.process_class.remote_scheduler = agentHost+":"+agentPort;
    	spooler_log.info("after: "+nextJob.process_class.remote_scheduler);
    	return true;
    \}
                ]]>
            </script>
         </monitor>
         <run_time />
     </job>  
    
  • Put the job these jobs into a job chain (e.g. job_chain_with_agent_jobjobChainWithAgentJob). Image Removed
    No Format
     So you have the configuration file _./config/live/job_chain_with_agent_jobjobChainWithAgentJob.job_chain.xml_:
    
    Code Block
    languagehtml/xml
     <?xml version="1.0" encoding="ISO-8859-1"?>
     
     <job_chain  orders_recoverable="yes" visible="yes">
        <job_chain_node  state="100setAgent" job="shell_on_dynamic_agentsetAgent" next_state="callAgent" error_state="error"/>
        <job_chain_node  state="callAgent" job="shellOnDynamicAgent" 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 jobChainWithAgentJob for each JobScheduler Agent you want.
    No Format
     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_.
    
    No Format
     So you have the configuration files _./config/live/job_chain_with_agent_jobjobChainWithAgentJob,hostA-4444.order.xml_ and _./config/live/job_chain_with_agent_jobjobChainWithAgentJob,hostB-4444.order.xml_  :
    
    Code Block
    languagehtml/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>
    
    Code Block
    languagehtml/xml
    <?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>