Introduction
Jira |
---|
server | SOS JIRA |
---|
columns | key,summary,type,created,updated,due,assignee,reporter,priority,status,resolution |
---|
serverId | 6dc67751-9d67-34cd-985b-194a8cdc9602 |
---|
key | JS-1416 |
---|
|
...
The Universal Agent comes with a REST web service client that allows it to be controlled from the command line or an application. The service supports the following operations:
- sending commands and
- showing status information.
...
- by use of a REST URI that is called from an HTTP client.
- by use of the Agent start script that makes use of a Java class that implements the HTTP client.
- sending commands
- via any client application that sends the command with an HTTP request (JSON).
Web Service Status Information
Start Script Status Information
Jira |
---|
server | SOS JIRA |
---|
columns | key,summary,type,created,updated,due,assignee,reporter,priority,status,resolution |
---|
serverId | 6dc67751-9d67-34cd-985b-194a8cdc9602 |
---|
key | JS-1426 |
---|
|
The Agent start script provides status information by internal use of web services. The information is returned in JSON format.
If the Agent is not available, an exit status is returned accordingly.
The status information is retrieved using:
Code Block |
---|
language | bash |
---|
title | Retrieve status information |
---|
collapse | true |
---|
|
./jobscheduler_agent.sh status |
URI Status Information
Jira |
---|
server | SOS JIRA |
---|
columns | key,summary,type,created,updated,due,assignee,reporter,priority,status,resolution |
---|
serverId | 6dc67751-9d67-34cd-985b-194a8cdc9602 |
---|
key | JS-1480 |
---|
|
Jira |
---|
server | SOS JIRA |
---|
columns | key,summary,type,created,updated,due,assignee,reporter,priority,status,resolution |
---|
serverId | 6dc67751-9d67-34cd-985b-194a8cdc9602 |
---|
key | JS-1412 |
---|
|
The Universal Agent provides status information via
...
Termination
web services. The information is returned in JSON format.
URI Syntax
All API URIs start with an optional prefix (if set on starting the Agent with the command line option -uri-prefix
) followed by the path.
- General status information is provided by:
http://host:port/jobscheduler/agent/api
- General status information is also provided by:
http://host:port
/jobscheduler/agent/api/overview
- Information about the Agent tasks running is provided by the web service:
http://host:port
/jobscheduler/agent/api/task
- Information about the active command is provided by the web service:
http://host:port
/jobscheduler/agent/api/tunnel
- Information about the active command is provided by the web service:
http://host:port
/jobscheduler/agent/api/tunnel
(without an end forward slash)
- A list of tunnels is provided by the web service:
http://host:port
/jobscheduler/agent/api/tunnel
/ (with an end forward slash)
- A summary of the commands running is provided by the web service:
http://host:port
/jobscheduler/agent/api/command
(without an end forward slash)
- A list of the commands running is provided by the web service:
http://host:port
/jobscheduler/agent/api/command
/ (with an end forward slash)
Note
These web services are read-only (HTTP verb GET).
The following web services are addressed with the verb POST:
http://host:port
/jobscheduler/agent/api/task/command
http://host:port
/jobscheduler/agent/api/tunnel/id
Examples
Code Block |
---|
language | text |
---|
title | Response for URI http://host:port/jobscheduler/agent/api |
---|
collapse | true |
---|
|
totalTaskCount: 0
isTerminating: false
system:
hostname: docker-agent
mxBeans:
operatingSystem:
processCpuLoad: 9.71859949958501E-7
availableProcessors: 8
freePhysicalMemorySize: 1791545344
systemCpuLoad: 0.00774040220626055
committedVirtualMemorySize: 4809150464
totalPhysicalMemorySize: 4897579008
currentTaskCount: 0
java:
systemProperties:
java.vendor: Azul Systems, Inc.
os.arch: amd64
os.version: 3.10.0-229.7.2.el7.x86_64
os.name: Linux
java.version: 1.8.0_25
version: 1.10.0-xx
startedAt: '2015-08-19T15:21:42.423Z' |
Code Block |
---|
language | text |
---|
title | Response for URI http://host:port/jobscheduler/agent/api/task - Agent tasks running |
---|
collapse | true |
---|
|
tasks:
- id: 4-259101459
tunnelId: '4'
controllerAddress: 127.0.0.1:9338
startedAt: '2015-08-19T13:11:18.239Z'
- id: 2-15899022
tunnelId: '2'
controllerAddress: 127.0.0.1:9338
startedAt: '2015-08-19T13:11:18.239Z'
- id: 3-707059672
tunnelId: '3'
controllerAddress: 127.0.0.1:9338
startedAt: '2015-08-19T13:11:18.239Z' |
Web Service Commands
Changes are made to the Agent by using the command service (api/command
).
http://host:port
/jobscheduler/agent/api/command
The only command is terminate
.
Termination Command
Jira |
---|
server | SOS JIRA |
---|
columns | key,summary,type,created,updated,due,assignee,reporter,priority,status,resolution |
---|
serverId | 6dc67751-9d67-34cd-985b-194a8cdc9602 |
---|
key | JS-1400 |
---|
|
Jira |
---|
server | SOS JIRA |
---|
columns | key,summary,type,created,updated,due,assignee,reporter,priority,status,resolution |
---|
serverId | 6dc67751-9d67-34cd-985b-194a8cdc9602 |
---|
key | JS-1401 |
---|
|
The JobScheduler Universal Agent is terminated by either:
- use of the start script, e.g.
./jobscheduler_agent.sh stop
- calling the Agent web service URL for commands with a JSON command
http://host:port/jobscheduler/agent/api/command
JSON commands to terminate the Agent are sent by an HTTP POST request and include the operationsThe JobScheduler Universal Agent should be terminated by the following actions:
- abort immediately:
- the Agent will kill all running tasks and will terminate immediately
- the web service client sends:
{ "$TYPE": "AbortImmediately" }
- this corresponds to the XML command that is used for a Master:
<modify_spooler cmd='abort_immediately'/>
- terminate:
- the Agent will not start new tasks, existing tasks can continue and the Agent will terminate after all tasks have completed
- optionally a SIGTERM can be sent to the tasks
- the web service client sends:
{ "$TYPE": "Terminate", "sigtermProcesses": false }
- this corresponds to the XML command that is used for a Master:
<modify_spooler cmd='terminate'
/>
- terminate with timeout:
- the Agent sends all tasks a SIGTERM command and will wait for the specified timeout.
Should any task not terminate within the specified timeout then it will be killed with a SIGKILL signal. - the web service client sends:
{ "$TYPE": "Terminate", "sigtermProcesses": false, "sigkillProcessesAfter": 15 }
- this corresponds to the XML command that is used for a Master:
<modify_spooler cmd='terminate'
timeout='15'
/>
Sample Web Service Client for sending Commands
Sample Script
A sample web service client is provided by the class com.sos.scheduler.engine.agent.client.main.AgentClientMain
that can be used with individual scripts, e.g. for a Unix environment like this:
Code Block |
---|
language | bash |
---|
title | Sample web service client script: agent-client.sh |
---|
collapse | true |
---|
|
export JAVA_HOME=/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
export JAVA_BIN=${JAVA_HOME}/bin/java
export SCHEDULER_AGENT_HOME=/Users/ap/Documents/jobscheduler_agent
# set logging impl (log4j or logback)
export SCHEDULER_AGENT_LOG_BRIDGE=logback
export SCHEDULER_AGENT_CLASSPATH="${SCHEDULER_AGENT_HOME}/lib/log/${SCHEDULER_AGENT_LOG_BRIDGE}/*:${SCHEDULER_AGENT_HOME}/lib/3rd-party/*:${SCHEDULER_AGENT_HOME}/lib/sos/*"
"${JAVA_BIN}" -classpath "${SCHEDULER_AGENT_CLASSPATH}" com.sos.scheduler.engine.agent.client.main.AgentClientMain "$@" |
Usage for Status Information
Code Block |
---|
language | xml |
---|
title | Show information |
---|
collapse | true |
---|
|
./agent-client.sh http://localhost:4445 /overview |
The first argument is the Agent URI, for example http://localhost:4445
The following arguments are web service paths (each starting with a slash) or commands (JSON or YAML).
With no argument, the client checks whether the Agent is alive.
Usage for Commands
Code Block |
---|
language | xml |
---|
title | Terminate Agent |
---|
collapse | true |
---|
|
./agent-client.sh http://localhost:4445 '{$TYPE: Terminate, sigtermProcesses: true}'
./agent-client.sh http://localhost:4445 '{$TYPE: Terminate, sigtermProcesses: true}' /overview |
The command responses are written to stdout
. In case of an error, the error message is written to stdout
and detailed messages are written to stderr
.
References
See also
Change Management References
...
Jira |
---|
server | SOS JIRA |
---|
columns | type,key,issuelinks,fixversions,status,priority,summary,updated |
---|
maximumIssues | 20 |
---|
jqlQuery | labels in (agent) and labels in (restweb-clientservice) |
---|
serverId | 6dc67751-9d67-34cd-985b-194a8cdc9602 |
---|
|