flush-job.asciidoc 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. [[java-rest-high-x-pack-ml-flush-job]]
  2. === Flush Job API
  3. The Flush Job API provides the ability to flush a {ml} job's
  4. datafeed in the cluster.
  5. It accepts a `FlushJobRequest` object and responds
  6. with a `FlushJobResponse` object.
  7. [[java-rest-high-x-pack-ml-flush-job-request]]
  8. ==== Flush Job Request
  9. A `FlushJobRequest` object gets created with an existing non-null `jobId`.
  10. All other fields are optional for the request.
  11. ["source","java",subs="attributes,callouts,macros"]
  12. --------------------------------------------------
  13. include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-flush-job-request]
  14. --------------------------------------------------
  15. <1> Constructing a new request referencing an existing `jobId`
  16. ==== Optional Arguments
  17. The following arguments are optional.
  18. ["source","java",subs="attributes,callouts,macros"]
  19. --------------------------------------------------
  20. include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-flush-job-request-options]
  21. --------------------------------------------------
  22. <1> Set request to calculate the interim results
  23. <2> Set the advanced time to flush to the particular time value
  24. <3> Set the start time for the range of buckets on which
  25. to calculate the interim results (requires `calc_interim` to be `true`)
  26. <4> Set the end time for the range of buckets on which
  27. to calculate interim results (requires `calc_interim` to be `true`)
  28. <5> Set the skip time to skip a particular time value
  29. [[java-rest-high-x-pack-ml-flush-job-execution]]
  30. ==== Execution
  31. The request can be executed through the `MachineLearningClient` contained
  32. in the `RestHighLevelClient` object, accessed via the `machineLearningClient()` method.
  33. ["source","java",subs="attributes,callouts,macros"]
  34. --------------------------------------------------
  35. include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-flush-job-execute]
  36. --------------------------------------------------
  37. [[java-rest-high-x-pack-ml-flush-job-execution-async]]
  38. ==== Asynchronous Execution
  39. The request can also be executed asynchronously:
  40. ["source","java",subs="attributes,callouts,macros"]
  41. --------------------------------------------------
  42. include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-flush-job-execute-async]
  43. --------------------------------------------------
  44. <1> The `FlushJobRequest` to execute and the `ActionListener` to use when
  45. the execution completes
  46. The method does not block and returns immediately. The passed `ActionListener` is used
  47. to notify the caller of completion. A typical `ActionListener` for `FlushJobResponse` may
  48. look like
  49. ["source","java",subs="attributes,callouts,macros"]
  50. --------------------------------------------------
  51. include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-flush-job-listener]
  52. --------------------------------------------------
  53. <1> `onResponse` is called back when the action is completed successfully
  54. <2> `onFailure` is called back when some unexpected error occurs
  55. [[java-rest-high-x-pack-ml-flush-job-response]]
  56. ==== Flush Job Response
  57. A `FlushJobResponse` contains an acknowledgement and an optional end date for the
  58. last finalized bucket
  59. ["source","java",subs="attributes,callouts,macros"]
  60. --------------------------------------------------
  61. include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-flush-job-response]
  62. --------------------------------------------------
  63. <1> `isFlushed()` indicates if the job was successfully flushed or not.
  64. <2> `getLastFinalizedBucketEnd()` provides the timestamp
  65. (in milliseconds-since-the-epoch) of the end of the last bucket that was processed.