HLRC: Add support for reindex rethrottling (#33832)

This change adds support for rethrottling reindex requests to the
RestHighLevelClient.
This commit is contained in:
Christoph Büscher 2018-09-20 18:56:12 +02:00 committed by GitHub
parent b33c18d316
commit 77145bb477
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 350 additions and 17 deletions

View file

@ -0,0 +1,60 @@
[[java-rest-high-document-reindex-rethrottle]]
=== Reindex Rethrottle API
[[java-rest-high-document-reindex-rethrottle-request]]
==== Reindex Rethrolle Request
A `RethrottleRequest` can be used to change existing throttling on a runnind
reindex task or disable it entirely. It requires the task Id of the reindex
task to change.
In its simplest form, you can use it to disable throttling of a running
reindex task using the following:
["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests}/CRUDDocumentationIT.java[rethrottle-disable-request]
--------------------------------------------------
<1> Create a `RethrottleRequest` that disables throttling for a specific task id
By providing a `requestsPerSecond` argument, the request will change the
existing task throttling to the specified value:
["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests}/CRUDDocumentationIT.java[rethrottle-request]
--------------------------------------------------
<1> Request to change the throttling of a task to 100 requests per second
[[java-rest-high-document-reindex-rethrottle-async]]
==== Asynchronous Execution
The asynchronous execution of a rethrottle request requires both the `RethrottleRequest`
instance and an `ActionListener` instance to be passed to the asynchronous
method:
["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests}/CRUDDocumentationIT.java[rethrottle-execute-async]
--------------------------------------------------
<1> The RethrottleRequest 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 looks like this:
["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests}/CRUDDocumentationIT.java[rethrottle-request-async]
--------------------------------------------------
<1> Code executed when the request is successfully completed
<2> Code executed when the request fails with an exception
[[java-rest-high-document-reindex-retrottle-response]]
==== Rethrottle Response
Rethrottling returns the task that has been rethrottled in the form of a
`ListTasksResponse`. The structure of this response object is described in detail
in <<java-rest-high-cluster-list-tasks-response,this section>>.

View file

@ -18,6 +18,7 @@ Multi-document APIs::
* <<java-rest-high-document-reindex>>
* <<java-rest-high-document-update-by-query>>
* <<java-rest-high-document-delete-by-query>>
* <<java-rest-high-document-reindex-rethrottle>>
include::document/index.asciidoc[]
include::document/get.asciidoc[]
@ -29,6 +30,7 @@ include::document/multi-get.asciidoc[]
include::document/reindex.asciidoc[]
include::document/update-by-query.asciidoc[]
include::document/delete-by-query.asciidoc[]
include::document/reindex-rethrottle.asciidoc[]
== Search APIs