reindex-rethrottle.asciidoc 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. [[java-rest-high-document-reindex-rethrottle]]
  2. === Reindex Rethrottle API
  3. [[java-rest-high-document-reindex-rethrottle-request]]
  4. ==== Reindex Rethrolle Request
  5. A `RethrottleRequest` can be used to change existing throttling on a runnind
  6. reindex task or disable it entirely. It requires the task Id of the reindex
  7. task to change.
  8. In its simplest form, you can use it to disable throttling of a running
  9. reindex task using the following:
  10. ["source","java",subs="attributes,callouts,macros"]
  11. --------------------------------------------------
  12. include-tagged::{doc-tests}/CRUDDocumentationIT.java[rethrottle-disable-request]
  13. --------------------------------------------------
  14. <1> Create a `RethrottleRequest` that disables throttling for a specific task id
  15. By providing a `requestsPerSecond` argument, the request will change the
  16. existing task throttling to the specified value:
  17. ["source","java",subs="attributes,callouts,macros"]
  18. --------------------------------------------------
  19. include-tagged::{doc-tests}/CRUDDocumentationIT.java[rethrottle-request]
  20. --------------------------------------------------
  21. <1> Request to change the throttling of a task to 100 requests per second
  22. [[java-rest-high-document-reindex-rethrottle-async]]
  23. ==== Asynchronous Execution
  24. The asynchronous execution of a rethrottle request requires both the `RethrottleRequest`
  25. instance and an `ActionListener` instance to be passed to the asynchronous
  26. method:
  27. ["source","java",subs="attributes,callouts,macros"]
  28. --------------------------------------------------
  29. include-tagged::{doc-tests}/CRUDDocumentationIT.java[rethrottle-execute-async]
  30. --------------------------------------------------
  31. <1> The RethrottleRequest to execute and the ActionListener to use when the
  32. execution completes
  33. The asynchronous method does not block and returns immediately.
  34. Once it is completed the `ActionListener` is called back using the `onResponse` method
  35. if the execution successfully completed or using the `onFailure` method if
  36. it failed. A typical listener looks like this:
  37. ["source","java",subs="attributes,callouts,macros"]
  38. --------------------------------------------------
  39. include-tagged::{doc-tests}/CRUDDocumentationIT.java[rethrottle-request-async]
  40. --------------------------------------------------
  41. <1> Code executed when the request is successfully completed
  42. <2> Code executed when the request fails with an exception
  43. [[java-rest-high-document-reindex-retrottle-response]]
  44. ==== Rethrottle Response
  45. Rethrottling returns the task that has been rethrottled in the form of a
  46. `ListTasksResponse`. The structure of this response object is described in detail
  47. in <<java-rest-high-cluster-list-tasks-response,this section>>.