JSON API (running jobs)
These methods support running and controlling jobs:
enqueue dequeue suspend resume
Submit jobs (enqueue)
Use this method for scheduling jobs for later execution. The response will contain the identity that can be used in future API requests.
curl -XPOST "http://chemgps.bmc.uu.se/batchelor/api/json/enqueue?pretty=1" -d '{"data":"hello world","type":"data"}'
{
"status": "success",
"result": {
"identity": {
"jobid": "34f95c954-09ce-46b7-bb59-820386cc9c89",
"result": "15421967654378"
},
"status": {
"queued": {
"date": "2018-11-15 20:59:33.875054",
"timezone_type": 3,
"timezone": "Europe/Stockholm"
},
"started": null,
"finished": null,
"state": "pending"
},
"submit": {
"task": "default",
"name": null
}
}
}
The complete input data is:
{
"data": "hello world",
"type": "data",
"task": "task1",
"name": "Job name"
}
- [Required] The data is the input to process. If encoding is required, it has to be established by the target task.
- [Required] The type tells what kind of data the data member contains (possible values are 'data' or 'url'). When using url, the data member should contain an HTTP(s) or FTP(s) URL from where data can be downloaded.
- [Optional] The task is the target processor on the server side for processing the input data. This member is optional and default to 'default' task.
- [Optional] The name is some generic string used to identify the job. It don't affect the job execution and is only used for sorting and search.
Form POST
Sending large files in the data member would be potential slow and error-prone and possibly lead to out of memory errors. Therefor its also possible to enqueue jobs by ordinary file POST. The task and name can be set as POST parameters. Use file as identifier, but if unset it should be auto detected on server side.
curl -XPOST "http://chemgps.bmc.uu.se/batchelor/api/json/enqueue?pretty=1" -i -F file=@indata.txt -F task=default -F "name=my task name"
{
"status": "success",
"result": {
"identity": {
"jobid": "34f95c954-09ce-46b7-bb59-820386cc9c89",
"result": "15421967654378"
},
"status": {
"queued": {
"date": "2018-11-15 21:21:40.286134",
"timezone_type": 3,
"timezone": "Europe/Stockholm"
},
"started": null,
"finished": null,
"state": "pending"
},
"submit": {
"task": "default",
"name": "my task name"
}
}
}
Remove/cancel job (dequeue)
Use this method to cancel a pending or running job. It can also be used to delete a finished job.
curl -XPOST "http://chemgps.bmc.uu.se/batchelor/api/json/dequeue?pretty=1" -d '{"jobid":"34f95c954-09ce-46b7-bb59-820386cc9c89","result":"15421969943499"}'
{
"status": "success",
"result": true
}
The complete input data is:
{
"jobid": "6633e06c-deaf-4222-bbdf-036e4be4f0a0",
"result": "f52764d624db129b32c21fbca0cb8d6"
}
Pause running job (suspend)
Use this method to pause an running job. Pause the job will remove it from the list of running tasks to make room for other tasks.
curl -XPOST "http://chemgps.bmc.uu.se/batchelor/api/json/suspend?pretty=1" -d '{"jobid":"34f95c954-09ce-46b7-bb59-820386cc9c89","result":"15421967654378"}'
{
"status": "success",
"result": true
}
The complete input data is:
{
"jobid": "6633e06c-deaf-4222-bbdf-036e4be4f0a0",
"result": "f52764d624db129b32c21fbca0cb8d6"
}
Trying to suspend an job not running will render an exception.
Continue paused job (resume)
Use this method to resume execution of an paused job. Resuming a job will not immediately make it start again, instead its moved to the ready list that will be consumed before other pending jobs.
curl -XPOST "http://chemgps.bmc.uu.se/batchelor/api/json/resume?pretty=1" -d '{"jobid":"34f95c954-09ce-46b7-bb59-820386cc9c89","result":"15421967654378"}'
{
"status": "success",
"result": true
}
The complete input data is:
{
"jobid": "6633e06c-deaf-4222-bbdf-036e4be4f0a0",
"result": "f52764d624db129b32c21fbca0cb8d6"
}
Trying to resume an job not paused will render an exception.