mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-24 23:27:25 -04:00
HLRC: Add get rollup job (#33921)
Adds support for the get rollup job to the High Level REST Client. I had to do three interesting and unexpected things: 1. I ported the rollup state wiping code into the high level client tests. I'll move this into the test framework in a followup and remove the x-pack version. 2. The `timeout` in the rollup config was serialized using the `toString` representation of `TimeValue` which produces fractional time values which are more human readable but aren't supported by parsing. So I switched it to `getStringRep`. 3. Refactor the xcontent round trip testing utilities so we can test parsing of classes that don't implements `ToXContent`.
This commit is contained in:
parent
7dbc403226
commit
f904c41506
15 changed files with 1093 additions and 51 deletions
71
docs/java-rest/high-level/rollup/get_job.asciidoc
Normal file
71
docs/java-rest/high-level/rollup/get_job.asciidoc
Normal file
|
@ -0,0 +1,71 @@
|
|||
[[java-rest-high-x-pack-rollup-get-job]]
|
||||
=== Get Rollup Job API
|
||||
|
||||
The Get Rollup Job API can be used to get one or all rollup jobs from the
|
||||
cluster. It accepts a `GetRollupJobRequest` object as a request and returns
|
||||
a `GetRollupJobResponse`.
|
||||
|
||||
[[java-rest-high-x-pack-rollup-get-rollup-job-request]]
|
||||
==== Get Rollup Job Request
|
||||
|
||||
A `GetRollupJobRequest` can be built without any parameters to get all of the
|
||||
rollup jobs or with a job name to get a single job:
|
||||
|
||||
["source","java",subs="attributes,callouts,macros"]
|
||||
--------------------------------------------------
|
||||
include-tagged::{doc-tests}/RollupDocumentationIT.java[x-pack-rollup-get-rollup-job-request]
|
||||
--------------------------------------------------
|
||||
<1> Gets all jobs.
|
||||
<2> Gets `job_1`.
|
||||
|
||||
[[java-rest-high-x-pack-rollup-get-rollup-job-execution]]
|
||||
==== Execution
|
||||
|
||||
The Get Rollup Job API can be executed through a `RollupClient`
|
||||
instance. Such instance can be retrieved from a `RestHighLevelClient`
|
||||
using the `rollup()` method:
|
||||
|
||||
["source","java",subs="attributes,callouts,macros"]
|
||||
--------------------------------------------------
|
||||
include-tagged::{doc-tests}/RollupDocumentationIT.java[x-pack-rollup-get-rollup-job-execute]
|
||||
--------------------------------------------------
|
||||
|
||||
[[java-rest-high-x-pack-rollup-get-rollup-job-response]]
|
||||
==== Response
|
||||
|
||||
The returned `GetRollupJobResponse` includes a `JobWrapper` per returned job
|
||||
which contains the configuration of the job, the job's current status, and
|
||||
statistics about the job's past execution.
|
||||
|
||||
["source","java",subs="attributes,callouts,macros"]
|
||||
--------------------------------------------------
|
||||
include-tagged::{doc-tests}/RollupDocumentationIT.java[x-pack-rollup-get-rollup-job-response]
|
||||
--------------------------------------------------
|
||||
<1> We only asked for a single job
|
||||
|
||||
[[java-rest-high-x-pack-rollup-get-rollup-job-async]]
|
||||
==== Asynchronous Execution
|
||||
|
||||
This request can be executed asynchronously:
|
||||
|
||||
["source","java",subs="attributes,callouts,macros"]
|
||||
--------------------------------------------------
|
||||
include-tagged::{doc-tests}/RollupDocumentationIT.java[x-pack-rollup-get-rollup-job-execute-async]
|
||||
--------------------------------------------------
|
||||
<1> The `GetRollupJobRequest` to execute and the `ActionListener` to use when
|
||||
the execution completes
|
||||
|
||||
The asynchronous method does not block and returns immediately. Once it is
|
||||
completed the `ActionListener` is called back using the `onResponse` method
|
||||
if the execution successfully completed or using the `onFailure` method if
|
||||
it failed.
|
||||
|
||||
A typical listener for `GetRollupJobResponse` looks like:
|
||||
|
||||
["source","java",subs="attributes,callouts,macros"]
|
||||
--------------------------------------------------
|
||||
include-tagged::{doc-tests}/RollupDocumentationIT.java[x-pack-rollup-get-rollup-job-execute-listener]
|
||||
--------------------------------------------------
|
||||
<1> Called when the execution is successfully completed. The response is
|
||||
provided as an argument
|
||||
<2> Called in case of failure. The raised exception is provided as an argument
|
|
@ -285,8 +285,10 @@ include::migration/get-assistance.asciidoc[]
|
|||
The Java High Level REST Client supports the following Rollup APIs:
|
||||
|
||||
* <<java-rest-high-x-pack-rollup-put-job>>
|
||||
* <<java-rest-high-x-pack-rollup-get-job>>
|
||||
|
||||
include::rollup/put_job.asciidoc[]
|
||||
include::rollup/get_job.asciidoc[]
|
||||
|
||||
== Security APIs
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue