| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 | [[java-rest-high-x-pack-ml-open-job]]=== Open Job APIThe Open Job API provides the ability to open {ml} jobs in the cluster.It accepts a `OpenJobRequest` object and respondswith a `OpenJobResponse` object.[[java-rest-high-x-pack-ml-open-job-request]]==== Open Job RequestAn `OpenJobRequest` object gets created with an existing non-null `jobId`.["source","java",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-open-job-request]--------------------------------------------------<1> Constructing a new request referencing an existing `jobId`<2> Optionally setting the `timeout` value for how long theexecution should wait for the job to be opened.[[java-rest-high-x-pack-ml-open-job-execution]]==== ExecutionThe request can be executed through the `MachineLearningClient` containedin the `RestHighLevelClient` object, accessed via the `machineLearningClient()` method.["source","java",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-open-job-execute]--------------------------------------------------<1> `isOpened()` from the `OpenJobResponse` indicates if the job was successfullyopened or not.[[java-rest-high-x-pack-ml-open-job-execution-async]]==== Asynchronous ExecutionThe request can also be executed asynchronously:["source","java",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-open-job-execute-async]--------------------------------------------------<1> The `OpenJobRequest` to execute and the `ActionListener` to use whenthe execution completesThe method does not block and returns immediately. The passed `ActionListener` is usedto notify the caller of completion. A typical `ActionListener` for `OpenJobResponse` maylook like["source","java",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-open-job-listener]--------------------------------------------------<1> `onResponse` is called back when the action is completed successfully<2> `onFailure` is called back when some unexpected error occurs
 |