rethrottle.asciidoc 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. --
  2. :api: rethrottle
  3. :request: RethrottleRequest
  4. :response: ListTasksResponse
  5. --
  6. [id="{upid}-{api}"]
  7. === Rethrottle API
  8. [id="{upid}-{api}-request"]
  9. ==== Rethrottle Request
  10. A +{request}+ can be used to change the current throttling on a running
  11. reindex, update-by-query or delete-by-query task or to disable throttling of
  12. the task entirely. It requires the task Id of the task to change.
  13. In its simplest form, you can use it to disable throttling of a running
  14. task using the following:
  15. ["source","java",subs="attributes,callouts,macros"]
  16. --------------------------------------------------
  17. include-tagged::{doc-tests-file}[{api}-disable-request]
  18. --------------------------------------------------
  19. <1> Create a +{request}+ that disables throttling for a specific task id
  20. By providing a `requestsPerSecond` argument, the request will change the
  21. existing task throttling to the specified value:
  22. ["source","java",subs="attributes,callouts,macros"]
  23. --------------------------------------------------
  24. include-tagged::{doc-tests-file}[{api}-request]
  25. --------------------------------------------------
  26. <1> Request to change the throttling of a task to 100 requests per second
  27. The rethrottling request can be executed by using one of the three appropriate
  28. methods depending on whether a reindex, update-by-query or delete-by-query task
  29. should be rethrottled:
  30. ["source","java",subs="attributes,callouts,macros"]
  31. --------------------------------------------------
  32. include-tagged::{doc-tests-file}[{api}-request-execution]
  33. --------------------------------------------------
  34. <1> Execute reindex rethrottling request
  35. <2> The same for update-by-query
  36. <3> The same for delete-by-query
  37. [id="{upid}-{api}-async"]
  38. ==== Asynchronous Execution
  39. The asynchronous execution of a rethrottle request requires both the +{request}+
  40. instance and an `ActionListener` instance to be passed to the asynchronous
  41. method:
  42. ["source","java",subs="attributes,callouts,macros"]
  43. --------------------------------------------------
  44. include-tagged::{doc-tests-file}[{api}-execute-async]
  45. --------------------------------------------------
  46. <1> Execute reindex rethrottling asynchronously
  47. <2> The same for update-by-query
  48. <3> The same for delete-by-query
  49. The asynchronous method does not block and returns immediately.
  50. Once it is completed the `ActionListener` is called back using the `onResponse` method
  51. if the execution successfully completed or using the `onFailure` method if
  52. it failed. A typical listener looks like this:
  53. ["source","java",subs="attributes,callouts,macros"]
  54. --------------------------------------------------
  55. include-tagged::{doc-tests-file}[{api}-request-async-listener]
  56. --------------------------------------------------
  57. <1> Code executed when the request is successfully completed
  58. <2> Code executed when the request fails with an exception
  59. [id="{upid}-{api}-response"]
  60. ==== Rethrottle Response
  61. Rethrottling returns the task that has been rethrottled in the form of a
  62. +{response}+. The structure of this response object is described in detail
  63. in <<java-rest-high-cluster-list-tasks-response,this section>>.