|
| 1 | +[[java-rest-high-snapshot-clone-snapshot]] |
| 2 | +=== Clone Snapshot API |
| 3 | + |
| 4 | +The Clone Snapshot API clones part or all of a snapshot into a new snapshot. |
| 5 | + |
| 6 | +[[java-rest-high-snapshot-clone-snapshot-request]] |
| 7 | +==== Request |
| 8 | + |
| 9 | +A `CloneSnapshotRequest`: |
| 10 | + |
| 11 | +["source","java",subs="attributes,callouts,macros"] |
| 12 | +-------------------------------------------------- |
| 13 | +include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[clone-snapshot-request] |
| 14 | +-------------------------------------------------- |
| 15 | + |
| 16 | +==== Indices to Clone |
| 17 | + |
| 18 | +Use `indices` to specify a list of indices from the source snapshot to include |
| 19 | +in the snapshot clone: |
| 20 | + |
| 21 | +["source","java",subs="attributes,callouts,macros"] |
| 22 | +-------------------------------------------------- |
| 23 | +include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[clone-snapshot-request-indices] |
| 24 | +-------------------------------------------------- |
| 25 | +<1> Include only `test_index` from the source snapshot. |
| 26 | + |
| 27 | +==== Index Settings and Options |
| 28 | + |
| 29 | +You can also customize index settings and options when cloning a snapshot: |
| 30 | + |
| 31 | +["source","java",subs="attributes,callouts,macros"] |
| 32 | +-------------------------------------------------- |
| 33 | +include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[clone-snapshot-request-index-settings] |
| 34 | +-------------------------------------------------- |
| 35 | +<1> Set `IndicesOptions.Option.IGNORE_UNAVAILABLE` in `#indicesOptions()` to |
| 36 | + have the clone succeed even if indices are missing in the source snapshot. |
| 37 | + |
| 38 | +==== Further Arguments |
| 39 | + |
| 40 | +You can also provide the following optional arguments: |
| 41 | + |
| 42 | +["source","java",subs="attributes,callouts,macros"] |
| 43 | +-------------------------------------------------- |
| 44 | +include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[clone-snapshot-request-masterTimeout] |
| 45 | +-------------------------------------------------- |
| 46 | +<1> Timeout to connect to the master node as a `TimeValue` |
| 47 | +<2> Timeout to connect to the master node as a `String` |
| 48 | + |
| 49 | +[[java-rest-high-snapshot-clone-snapshot-sync]] |
| 50 | +==== Synchronous Execution |
| 51 | + |
| 52 | +["source","java",subs="attributes,callouts,macros"] |
| 53 | +-------------------------------------------------- |
| 54 | +include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[clone-snapshot-execute] |
| 55 | +-------------------------------------------------- |
| 56 | + |
| 57 | +[[java-rest-high-snapshot-clone-snapshot-async]] |
| 58 | +==== Asynchronous Execution |
| 59 | + |
| 60 | +The asynchronous execution of a clone snapshot request requires both the |
| 61 | +`CloneSnapshotRequest` instance and an `ActionListener` instance to be |
| 62 | +passed to the asynchronous method: |
| 63 | + |
| 64 | +["source","java",subs="attributes,callouts,macros"] |
| 65 | +-------------------------------------------------- |
| 66 | +include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[clone-snapshot-execute-async] |
| 67 | +-------------------------------------------------- |
| 68 | +<1> The `CloneSnapshotRequest` to execute and the `ActionListener` |
| 69 | +to use when the execution completes |
| 70 | + |
| 71 | +The asynchronous method does not block and returns immediately. Once it is |
| 72 | +completed the `ActionListener` is called back using the `onResponse` method |
| 73 | +if the execution successfully completed or using the `onFailure` method if |
| 74 | +it failed. |
| 75 | + |
| 76 | +A typical listener for `AcknowledgedResponse` looks like: |
| 77 | + |
| 78 | +["source","java",subs="attributes,callouts,macros"] |
| 79 | +-------------------------------------------------- |
| 80 | +include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[clone-snapshot-execute-listener] |
| 81 | +-------------------------------------------------- |
| 82 | +<1> Called when the execution is successfully completed. The response is |
| 83 | + provided as an argument. |
| 84 | +<2> Called in case of a failure. The raised exception is provided as an argument. |
| 85 | + |
| 86 | +[[java-rest-high-cluster-clone-snapshot-response]] |
| 87 | +==== Response |
| 88 | + |
| 89 | +`AcknowledgedResponse` indicates whether the request was received: |
| 90 | + |
| 91 | +["source","java",subs="attributes,callouts,macros"] |
| 92 | +-------------------------------------------------- |
| 93 | +include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[clone-snapshot-response] |
| 94 | +-------------------------------------------------- |
| 95 | +<1> A boolean value of `true` if the clone successfully completed. Otherwise, the value is `false`. |
0 commit comments