create_snapshot.asciidoc 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. [[java-rest-high-snapshot-create-snapshot]]
  2. === Create Snapshot API
  3. Use the Create Snapshot API to create a new snapshot.
  4. [[java-rest-high-snapshot-create-snapshot-request]]
  5. ==== Create Snapshot Request
  6. A `CreateSnapshotRequest`:
  7. ["source","java",subs="attributes,callouts,macros"]
  8. --------------------------------------------------
  9. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-snapshot-request]
  10. --------------------------------------------------
  11. ==== Required Arguments
  12. The following arguments are mandatory:
  13. ["source","java",subs="attributes,callouts,macros"]
  14. --------------------------------------------------
  15. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-snapshot-request-repositoryName]
  16. --------------------------------------------------
  17. <1> The name of the repository.
  18. ["source","java",subs="attributes,callouts,macros"]
  19. --------------------------------------------------
  20. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-snapshot-request-snapshotName]
  21. --------------------------------------------------
  22. <1> The name of the snapshot.
  23. ==== Optional Arguments
  24. The following arguments are optional:
  25. ["source","java",subs="attributes,callouts,macros"]
  26. --------------------------------------------------
  27. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-snapshot-request-indices]
  28. --------------------------------------------------
  29. <1> A list of indices the snapshot is applied to.
  30. ["source","java",subs="attributes,callouts,macros"]
  31. --------------------------------------------------
  32. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-snapshot-request-indicesOptions]
  33. --------------------------------------------------
  34. <1> Options applied to the indices.
  35. ["source","java",subs="attributes,callouts,macros"]
  36. --------------------------------------------------
  37. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-snapshot-request-partial]
  38. --------------------------------------------------
  39. <1> Set `partial` to `true` to allow a successful snapshot without the
  40. availability of all the indices primary shards. Defaults to `false`.
  41. ["source","java",subs="attributes,callouts,macros"]
  42. --------------------------------------------------
  43. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-snapshot-request-includeGlobalState]
  44. --------------------------------------------------
  45. <1> Set `includeGlobalState` to `false` to prevent writing the cluster's global
  46. state as part of the snapshot. Defaults to `true`.
  47. ["source","java",subs="attributes,callouts,macros"]
  48. --------------------------------------------------
  49. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-snapshot-request-masterTimeout]
  50. --------------------------------------------------
  51. <1> Timeout to connect to the master node as a `TimeValue`.
  52. <2> Timeout to connect to the master node as a `String`.
  53. ["source","java",subs="attributes,callouts,macros"]
  54. --------------------------------------------------
  55. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-snapshot-request-waitForCompletion]
  56. --------------------------------------------------
  57. <1> Waits for the snapshot to be completed before a response is returned.
  58. [[java-rest-high-snapshot-create-snapshot-sync]]
  59. ==== Synchronous Execution
  60. Execute a `CreateSnapshotRequest` synchronously to receive a `CreateSnapshotResponse`.
  61. ["source","java",subs="attributes,callouts,macros"]
  62. --------------------------------------------------
  63. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-snapshot-execute]
  64. --------------------------------------------------
  65. Retrieve the `SnapshotInfo` from a `CreateSnapshotResponse` when the snapshot is fully created.
  66. (The `waitForCompletion` parameter is `true`).
  67. ["source","java",subs="attributes,callouts,macros"]
  68. --------------------------------------------------
  69. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-snapshot-response-snapshot-info]
  70. --------------------------------------------------
  71. <1> The `SnapshotInfo` object.
  72. [[java-rest-high-snapshot-create-snapshot-async]]
  73. ==== Asynchronous Execution
  74. The asynchronous execution of a create snapshot request requires both the
  75. `CreateSnapshotRequest` instance and an `ActionListener` instance to be
  76. passed as arguments to the asynchronous method:
  77. ["source","java",subs="attributes,callouts,macros"]
  78. --------------------------------------------------
  79. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-snapshot-execute-async]
  80. --------------------------------------------------
  81. <1> The `CreateSnapshotRequest` to execute and the `ActionListener` to use when
  82. the execution completes.
  83. The asynchronous method does not block and returns immediately. Once it is
  84. completed the `ActionListener` is called back with the `onResponse` method
  85. if the execution is successful or the `onFailure` method if the execution
  86. failed.
  87. A typical listener for `CreateSnapshotResponse` looks like:
  88. ["source","java",subs="attributes,callouts,macros"]
  89. --------------------------------------------------
  90. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-snapshot-execute-listener]
  91. --------------------------------------------------
  92. <1> Called when the execution is successfully completed. The response is
  93. provided as an argument.
  94. <2> Called in case of a failure. The raised exception is provided as an
  95. argument.
  96. [[java-rest-high-snapshot-create-snapshot-response]]
  97. ==== Snapshot Create Response
  98. Use the `CreateSnapshotResponse` to retrieve information about the evaluated
  99. request:
  100. ["source","java",subs="attributes,callouts,macros"]
  101. --------------------------------------------------
  102. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-snapshot-response]
  103. --------------------------------------------------
  104. <1> Indicates the node has started the request.