create_snapshot.asciidoc 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. ["source","java",subs="attributes,callouts,macros"]
  61. --------------------------------------------------
  62. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-snapshot-execute]
  63. --------------------------------------------------
  64. [[java-rest-high-snapshot-create-snapshot-async]]
  65. ==== Asynchronous Execution
  66. The asynchronous execution of a create snapshot request requires both the
  67. `CreateSnapshotRequest` instance and an `ActionListener` instance to be
  68. passed as arguments to the asynchronous method:
  69. ["source","java",subs="attributes,callouts,macros"]
  70. --------------------------------------------------
  71. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-snapshot-execute-async]
  72. --------------------------------------------------
  73. <1> The `CreateSnapshotRequest` to execute and the `ActionListener` to use when
  74. the execution completes.
  75. The asynchronous method does not block and returns immediately. Once it is
  76. completed the `ActionListener` is called back with the `onResponse` method
  77. if the execution is successful or the `onFailure` method if the execution
  78. failed.
  79. A typical listener for `CreateSnapshotResponse` looks like:
  80. ["source","java",subs="attributes,callouts,macros"]
  81. --------------------------------------------------
  82. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-snapshot-execute-listener]
  83. --------------------------------------------------
  84. <1> Called when the execution is successfully completed. The response is
  85. provided as an argument.
  86. <2> Called in case of a failure. The raised exception is provided as an
  87. argument.
  88. [[java-rest-high-snapshot-create-snapshot-response]]
  89. ==== Snapshot Create Response
  90. Use the `CreateSnapshotResponse` to retrieve information about the evaluated
  91. request:
  92. ["source","java",subs="attributes,callouts,macros"]
  93. --------------------------------------------------
  94. include-tagged::{doc-tests}/SnapshotClientDocumentationIT.java[create-snapshot-response]
  95. --------------------------------------------------
  96. <1> Indicates the node has started the request.