stop-job.asciidoc 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[rollup-stop-job]]
  4. === Stop Job API
  5. ++++
  6. <titleabbrev>Stop Job</titleabbrev>
  7. ++++
  8. experimental[]
  9. This API stops an existing, started rollup job. If the job does not exist an exception will be thrown.
  10. Stopping an already stopped job has no action.
  11. ==== Request
  12. `POST _xpack/rollup/job/<job_id>/_stop`
  13. //===== Description
  14. ==== Path Parameters
  15. `job_id` (required)::
  16. (string) Identifier for the job
  17. ==== Query Parameters
  18. `wait_for_completion` (optional)::
  19. (boolean) if set to true, causes the API to block until the indexer state completely stops. If set to false, the
  20. API returns immediately and the indexer will be stopped asynchronously in the background. Defaults to `false`.
  21. `timeout` (optional)::
  22. (TimeValue) if `wait_for_completion=true`, the API will block for (at maximum)
  23. the specified duration while waiting for the job to stop. If more than `timeout` time has passed, the API
  24. will throw a timeout exception. Note: even if a timeout exception is thrown, the stop request is still processing and
  25. will eventually move the job to `STOPPED`. The timeout simply means the API call itself timed out while waiting
  26. for the status change. Defaults to `30s`
  27. ==== Request Body
  28. There is no request body for the Stop Job API.
  29. ==== Authorization
  30. You must have `manage` or `manage_rollup` cluster privileges to use this API.
  31. For more information, see
  32. {xpack-ref}/security-privileges.html[Security Privileges].
  33. ==== Examples
  34. If we have an already-started rollup job named `sensor`, it can be stopped with:
  35. [source,js]
  36. --------------------------------------------------
  37. POST _xpack/rollup/job/sensor/_stop
  38. --------------------------------------------------
  39. // CONSOLE
  40. // TEST[setup:sensor_started_rollup_job]
  41. Which will return the response:
  42. [source,js]
  43. ----
  44. {
  45. "stopped": true
  46. }
  47. ----
  48. // TESTRESPONSE
  49. If however we try to stop a job which doesn't exist:
  50. [source,js]
  51. --------------------------------------------------
  52. POST _xpack/rollup/job/does_not_exist/_stop
  53. --------------------------------------------------
  54. // CONSOLE
  55. // TEST[catch:missing]
  56. A 404 `resource_not_found` exception will be thrown:
  57. [source,js]
  58. ----
  59. {
  60. "error" : {
  61. "root_cause" : [
  62. {
  63. "type" : "resource_not_found_exception",
  64. "reason" : "Task for Rollup Job [does_not_exist] not found",
  65. "stack_trace": ...
  66. }
  67. ],
  68. "type" : "resource_not_found_exception",
  69. "reason" : "Task for Rollup Job [does_not_exist] not found",
  70. "stack_trace": ...
  71. },
  72. "status": 404
  73. }
  74. ----
  75. // TESTRESPONSE[s/"stack_trace": .../"stack_trace": $body.$_path/]
  76. ===== Waiting for the job to stop
  77. Since only a stopped job can be deleted, it can be useful to block the StopJob API until the indexer has fully
  78. stopped. This is accomplished with the `wait_for_completion` query parameter, and optionally a `timeout`:
  79. [source,js]
  80. --------------------------------------------------
  81. POST _xpack/rollup/job/sensor/_stop?wait_for_completion=true&timeout=10s
  82. --------------------------------------------------
  83. // CONSOLE
  84. // TEST[setup:sensor_started_rollup_job]
  85. The parameter will block the API call from returning until either the job has moved to `STOPPED`, or the specified
  86. time has elapsed. If the specified time elapses without the job moving to `STOPPED`, a timeout exception will be thrown.
  87. If `wait_for_completion=true` is specified without a `timeout`, a default timeout of 30 seconds is used.