Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: 'Display content by label' macro added

Table of Contents
outlinh1. true
outlinh1. true
1printablefalse
2stylh1. none
3indent20px

The JobScheduler can be controlled by commands (e.g. starting a jobs) from external applications (or scripts).
More information of all available commands can be found here: Jetty/xml_commands.xml Command List].

...

An external application, which is able and has the authorisation to send such commands to the JSEngine can use http(s) or tcp/ip to establish the communication. That means, that even a script language like javascript can be used to communicate. For Java users we have a wrapper class paket which was created using JAXB and the xsd schema for the commands and answers.

...

Protocols

The commands can be transferred to the JobScheduler via the following protocols:

  • httpHTTP
  • httpsHTTPS
  • tcpTCP
  • udpUDP

and telnet.

In addition a cli command line interface (CLI) is available via the "jobscheduler.sh" script.

Example using JOC

You can use JOC to send a command using the URL:

Code Block

  http://[scheduler_host]:[scheduler_port]/<span style="color:red;"><show<show_state/></span>>

or if you open JOC with [How_to_run_JobScheduler_with_  Jetty then type:

Code Block

  http://[scheduler_host]:[jetty_port]/jobscheduler/engine-cpp/<span style="color:red;"><show<show_state/></span>>

where <span style="color:red;"><show<show_state/></span> > is an example for a command of the JobScheduler external API.

Example using the JobScheduler script

You can use the startscript found in "./bin" to send a command too.
An example for using the command line option

Code Block

  jobscheduler.sh command "<span style="color:red;"><show<show_state/></span>>"

The answer of jobscheduler.sh command ... is without indent and newlines.
If you want a more readable answer then type

Code Block

  jobscheduler.sh command "<span style="color:red;"><show<show_state/></span>>" | sed -e 's;[^>]*$;;' | xmllint --format -

Object Model: start an order

Code Block
languagejava
collapsetrue

package com.sos.scheduler.model.commands;
import java.util.List;

import org.apache.log4j.Logger;
import org.junit.BeforeClass;
import org.junit.Test;

import com.sos.JSHelper.Exceptions.JobSchedulerException;
import com.sos.scheduler.model.SchedulerObjectFactory;
import com.sos.scheduler.model.answers.Answer;
import com.sos.scheduler.model.answers.ERROR;
import com.sos.scheduler.model.objects.Param;
import com.sos.scheduler.model.objects.Params;
import com.sos.scheduler.model.objects.Spooler;

public class JSCmdAddOrderTest \{

	private final static Logger logger 				logger	= Logger.getLogger(JSCmdAddOrderTest.class);
	
	private static SchedulerObjectFactory 	factory 	= null;

	@BeforeClass
	 public static void setUpBeforeClass() throws Exception \{
		factory = new SchedulerObjectFactory("localhost", 4112);
		factory.initMarshaller(Spooler.class);
	\}

	@Test
	 public final void testSetValidXmlContent() \{
		
		JSCmdAddOrder cmdOrder = factory.createAddOrder();
		
		cmdOrder.setJobChain("/job_chain_multiple_inheritance_sample/job_chain_multiple_inheritance_sample");
		cmdOrder.setReplace("yes");
		cmdOrder.setId("A");
		cmdOrder.setTitle("JobNet: null");
		Param p1 = factory.createParam("uuid_jobnet_identifier","989ac2ce-2538-4276-8003-3350a6224c97"cmdOrder.setParams(new Params());
		ParamList<Object> p2objL = factory.createParam("jobnet","/job_chain_multiple_inheritance_sample/job_chain_multiple_inheritance_sample"cmdOrder.getParams().getParamOrCopyParamsOrInclude();
		Param p3 = objL.add(factory.createParam("successor", "B,C,D,"));
		Param p4 = objL.add(factory.createParam("predecessor", ""));
		Param p5 = objL.add(factory.createParam("script_to_execute", "echo Here is the bootstrap order");
		cmdOrder.setParams( new Params() );
		cmdOrder.getParams().getParamOrCopyParamsOrInclude().add(p3);
		cmdOrder.getParams().getParamOrCopyParamsOrInclude().add(p4);
		cmdOrder.getParams().getParamOrCopyParamsOrInclude().add(p5);
		cmdOrder.getParams().getParamOrCopyParamsOrInclude().add(p1);
		cmdOrder.getParams().getParamOrCopyParamsOrInclude().add(p2objL.add(factory.createParam("uuid_jobnet_identifier", "989ac2ce-2538-4276-8003-3350a6224c97"));
		objL.add(factory.createParam("jobnet", "/job_chain_multiple_inheritance_sample/job_chain_multiple_inheritance_sample"));
		cmdOrder.setAt("2012-04-17 22:00");
		String xml = cmdOrder.toXMLString();
		cmdOrder.run();
		Answer answer = cmdOrder.getAnswer();
		ERROR jsError = answer.getERROR();
		if (jsError != null) \{
			logger.debug(xml + "\n"      String xml = cmdOrder.toXMLString();
			logger.debug(xml+ jsError.getText());
			throw new JobSchedulerException("CommandError notin executedexecution due to an errorof order");
		\}
	\}
\}

see also

Resources

Display content by label
TypeExample
Labelsjobscheduler example api

See also