rethrottle.asciidoc 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. [[java-rest-high-document-rethrottle]]
  2. === Rethrottle API
  3. [[java-rest-high-document-rethrottle-request]]
  4. ==== Rethrottle Request
  5. A `RethrottleRequest` can be used to change the current throttling on a running
  6. reindex, update-by-query or delete-by-query task or to disable throttling of
  7. the task entirely. It requires the task Id of the task to change.
  8. In its simplest form, you can use it to disable throttling of a running
  9. 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. The rethrottling request can be executed by using one of the three appropriate
  23. methods depending on whether a reindex, update-by-query or delete-by-query task
  24. should be rethrottled:
  25. ["source","java",subs="attributes,callouts,macros"]
  26. --------------------------------------------------
  27. include-tagged::{doc-tests}/CRUDDocumentationIT.java[rethrottle-request-execution]
  28. --------------------------------------------------
  29. <1> Execute reindex rethrottling request
  30. <2> The same for update-by-query
  31. <3> The same for delete-by-query
  32. [[java-rest-high-document-rethrottle-async]]
  33. ==== Asynchronous Execution
  34. The asynchronous execution of a rethrottle request requires both the `RethrottleRequest`
  35. instance and an `ActionListener` instance to be passed to the asynchronous
  36. method:
  37. ["source","java",subs="attributes,callouts,macros"]
  38. --------------------------------------------------
  39. include-tagged::{doc-tests}/CRUDDocumentationIT.java[rethrottle-execute-async]
  40. --------------------------------------------------
  41. <1> Execute reindex rethrottling asynchronously
  42. <2> The same for update-by-query
  43. <3> The same for delete-by-query
  44. The asynchronous method does not block and returns immediately.
  45. Once it is completed the `ActionListener` is called back using the `onResponse` method
  46. if the execution successfully completed or using the `onFailure` method if
  47. it failed. A typical listener looks like this:
  48. ["source","java",subs="attributes,callouts,macros"]
  49. --------------------------------------------------
  50. include-tagged::{doc-tests}/CRUDDocumentationIT.java[rethrottle-request-async-listener]
  51. --------------------------------------------------
  52. <1> Code executed when the request is successfully completed
  53. <2> Code executed when the request fails with an exception
  54. [[java-rest-high-document-retrottle-response]]
  55. ==== Rethrottle Response
  56. Rethrottling returns the task that has been rethrottled in the form of a
  57. `ListTasksResponse`. The structure of this response object is described in detail
  58. in <<java-rest-high-cluster-list-tasks-response,this section>>.