Changes

Jump to navigation Jump to search
no edit summary
* The job definitions are stored in a {{Code|jobs.xml}} file in the database directory. It can also be edited manually.
=Basic Functions= ==jobs:current== {| width='100%'|-| width='120' | '''Signatures'''|{{Func|jobs:current||xs:string}}|-| '''Summary'''|Returns the id of the current job.|} ==jobs:list== {| width='100%'|-| width='120' | '''Signatures'''|{{Func|jobs:list||xs:string*}}|-| '''Summary'''|Returns the ids of all jobs that are currently registered. The list includes scheduled, queued, running, stopped, and finished jobs with cached results.|-| '''Examples'''| <code>jobs:list()</code> returns the same job id as {{Function|Executing Jobs|jobs:current}} if no other job is registered.|} ==jobs:list-details== {| width='100%'|-| width='120' | '''Signatures'''|{{Func|jobs:list-details||element(job)*}}<br/>{{Func|jobs:list-details|$id as xs:string|element(job)*}}|-| '''Summary'''|Returns information on all jobs that are currently registered, or on a job with the specified {{Code|$id}} (or an empty sequence if this job is not found). The list includes scheduled, queued, running jobs, and cached jobs. A string representation of the job, or its URI, will be returned as value. The returned elements have additional attributes:* <code>id</code>: job id* <code>type</code>: type of the job (command, query, REST, RESTXQ, etc.)* <code>state</code>: current state of the job: <code>scheduled</code>, <code>queued</code>, <code>running</code>, <code>cached</code>* <code>user</code>: user who started the job* <code>duration</code>: evaluation time (included if a job is running or if the result was cached)* <code>start</code>: next start of job (included if a job will be executed repeatedly)* <code>time</code>: time when job was registered|-| '''Examples'''| <code>jobs:list-details()</code> returns information on the currently running job and possibly others:<syntaxhighlight lang="xml"><job id="job1" type="XQuery" state="running" user="admin" duration="PT0.001S"> XQUERY jobs:list-details()</job></syntaxhighlight>|} ==jobs:finished== {| width='100%'|-| width='120' | '''Signatures'''|{{Func|jobs:finished|$id as xs:string|xs:boolean}}|-| '''Summary'''|Indicates if the evaluation of an already running job with the specified {{Code|$id}} has finished. As the ids of finished jobs will usually be discarded, unless caching is enabled, the function will also return <code>true</code> for unknown jobs.* <code>false</code> indicates that the job id is scheduled, queued, or currently running.* <code>true</code> will be returned if the job has either finished, or if the id is unknown (because the ids of all finished jobs will not be cached).|} ==jobs:services== {| width='100%'|-| width='120' | '''Signatures'''|{{Func|jobs:services||element(job)*}}|-| '''Summary'''|Returns a list of all jobs that have been persistently registered as [[#Services|Services]].|-| '''Errors'''|{{Error|services|#Errors}} Registered services cannot be parsed.<br/>|} =Execution=
There are cases in which a client does not, or cannot, wait until a request is fully processed. The client may be a browser, which sends an HTTP request to the server in order to start another time-consuming query job. The functions in this section allow you to register a new query job from a running query. Jobs can be executed immediately (i.e., as soon as the [[Transaction Management#Concurrency Control|Concurrency Control]] allows it) or scheduled for repeated execution. Each registered job gets a job id, and the id can be used to retrieve a query result, stop a job, or wait for its termination.
| '''Errors'''
|{{Error|self|#Errors}} The current job is addressed.<br/>
|}
 
=Listing Jobs=
 
==jobs:current==
 
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|jobs:current||xs:string}}
|-
| '''Summary'''
|Returns the id of the current job.
|}
 
==jobs:list==
 
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|jobs:list||xs:string*}}
|-
| '''Summary'''
|Returns the ids of all jobs that are currently registered. The list includes scheduled, queued, running, stopped, and finished jobs with cached results.
|-
| '''Examples'''
| <code>jobs:list()</code> returns the same job id as {{Function|Jobs|jobs:current}} if no other job is registered.
|}
 
==jobs:list-details==
 
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|jobs:list-details||element(job)*}}<br/>{{Func|jobs:list-details|$id as xs:string|element(job)*}}
|-
| '''Summary'''
|Returns information on all jobs that are currently registered, or on a job with the specified {{Code|$id}} (or an empty sequence if this job is not found). The list includes scheduled, queued, running jobs, and cached jobs. A string representation of the job, or its URI, will be returned as value. The returned elements have additional attributes:
* <code>id</code>: job id
* <code>type</code>: type of the job (command, query, REST, RESTXQ, etc.)
* <code>state</code>: current state of the job: <code>scheduled</code>, <code>queued</code>, <code>running</code>, <code>cached</code>
* <code>user</code>: user who started the job
* <code>duration</code>: evaluation time (included if a job is running or if the result was cached)
* <code>start</code>: next start of job (included if a job will be executed repeatedly)
* <code>time</code>: time when job was registered
|-
| '''Examples'''
| <code>jobs:list-details()</code> returns information on the currently running job and possibly others:
<syntaxhighlight lang="xml">
<job id="job1" type="XQuery" state="running" user="admin" duration="PT0.001S">
XQUERY jobs:list-details()
</job>
</syntaxhighlight>
|}
 
==jobs:bindings==
 
{{Mark|Introduced with Version 10.0}}
 
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|jobs:bindings|$id as xs:string|map(*)}}
|-
| '''Summary'''
|Returns the variable bindings of an existing job with the specified {{Code|$id}}. If no variables have been bound to this job, an empty map is returned.
|}
 
==jobs:finished==
 
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|jobs:finished|$id as xs:string|xs:boolean}}
|-
| '''Summary'''
|Indicates if the evaluation of an already running job with the specified {{Code|$id}} has finished. As the ids of finished jobs will usually be discarded, unless caching is enabled, the function will also return <code>true</code> for unknown jobs.
* <code>false</code> indicates that the job id is scheduled, queued, or currently running.
* <code>true</code> will be returned if the job has either finished, or if the id is unknown (because the ids of all finished jobs will not be cached).
|}
 
==jobs:services==
 
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|jobs:services||element(job)*}}
|-
| '''Summary'''
|Returns a list of all jobs that have been persistently registered as [[#Services|Services]].
|-
| '''Errors'''
|{{Error|services|#Errors}} Registered services cannot be parsed.<br/>
|}
=Changelog=
 
;Version 10.0
* Added: {{Function|Jobs|jobs:bindings}}
;Version 9.7
Bureaucrats, editor, reviewer, Administrators
12,951

edits

Navigation menu