rollover.asciidoc 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. [[java-rest-high-rollover-index]]
  2. === Rollover Index API
  3. [[java-rest-high-rollover-request]]
  4. ==== Rollover Request
  5. The Rollover Index API requires a `RolloverRequest` instance.
  6. A `RolloverRequest` requires two string arguments at construction time, and
  7. one or more conditions that determine when the index has to be rolled over:
  8. ["source","java",subs="attributes,callouts,macros"]
  9. --------------------------------------------------
  10. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[rollover-request]
  11. --------------------------------------------------
  12. <1> The alias (first argument) that points to the index to rollover, and
  13. optionally the name of the new index in case the rollover operation is performed
  14. <2> Condition on the age of the index
  15. <3> Condition on the number of documents in the index
  16. <4> Condition on the size of the index
  17. ==== Optional arguments
  18. The following arguments can optionally be provided:
  19. ["source","java",subs="attributes,callouts,macros"]
  20. --------------------------------------------------
  21. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[rollover-request-dryRun]
  22. --------------------------------------------------
  23. <1> Whether the rollover should be performed (default) or only simulated
  24. ["source","java",subs="attributes,callouts,macros"]
  25. --------------------------------------------------
  26. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[rollover-request-timeout]
  27. --------------------------------------------------
  28. <1> Timeout to wait for the all the nodes to acknowledge the index is opened
  29. as a `TimeValue`
  30. <2> Timeout to wait for the all the nodes to acknowledge the index is opened
  31. as a `String`
  32. ["source","java",subs="attributes,callouts,macros"]
  33. --------------------------------------------------
  34. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[rollover-request-masterTimeout]
  35. --------------------------------------------------
  36. <1> Timeout to connect to the master node as a `TimeValue`
  37. <2> Timeout to connect to the master node as a `String`
  38. ["source","java",subs="attributes,callouts,macros"]
  39. --------------------------------------------------
  40. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[rollover-request-waitForActiveShards]
  41. --------------------------------------------------
  42. <1> The number of active shard copies to wait for before the rollover index API
  43. returns a response, as an `int`
  44. <2> The number of active shard copies to wait for before the rollover index API
  45. returns a response, as an `ActiveShardCount`
  46. ["source","java",subs="attributes,callouts,macros"]
  47. --------------------------------------------------
  48. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[rollover-request-settings]
  49. --------------------------------------------------
  50. <1> Add the settings to apply to the new index, which include the number of
  51. shards to create for it
  52. ["source","java",subs="attributes,callouts,macros"]
  53. --------------------------------------------------
  54. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[rollover-request-mapping]
  55. --------------------------------------------------
  56. <1> Add the mappings to associate the new index with. See <<java-rest-high-create-index-request-mappings>>
  57. for examples on the different ways to provide mappings
  58. ["source","java",subs="attributes,callouts,macros"]
  59. --------------------------------------------------
  60. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[rollover-request-alias]
  61. --------------------------------------------------
  62. <1> Add the aliases to associate the new index with
  63. [[java-rest-high-rollover-sync]]
  64. ==== Synchronous Execution
  65. ["source","java",subs="attributes,callouts,macros"]
  66. --------------------------------------------------
  67. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[rollover-execute]
  68. --------------------------------------------------
  69. [[java-rest-high-rollover-async]]
  70. ==== Asynchronous Execution
  71. The asynchronous execution of a rollover request requires both the `RolloverRequest`
  72. instance and an `ActionListener` instance to be passed to the asynchronous
  73. method:
  74. ["source","java",subs="attributes,callouts,macros"]
  75. --------------------------------------------------
  76. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[rollover-execute-async]
  77. --------------------------------------------------
  78. <1> The `RolloverRequest` to execute and the `ActionListener` to use when
  79. the execution completes
  80. The asynchronous method does not block and returns immediately. Once it is
  81. completed the `ActionListener` is called back using the `onResponse` method
  82. if the execution successfully completed or using the `onFailure` method if
  83. it failed.
  84. A typical listener for `RolloverResponse` looks like:
  85. ["source","java",subs="attributes,callouts,macros"]
  86. --------------------------------------------------
  87. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[rollover-execute-listener]
  88. --------------------------------------------------
  89. <1> Called when the execution is successfully completed. The response is
  90. provided as an argument
  91. <2> Called in case of failure. The raised exception is provided as an argument
  92. [[java-rest-high-rollover-response]]
  93. ==== Rollover Response
  94. The returned `RolloverResponse` allows to retrieve information about the
  95. executed operation as follows:
  96. ["source","java",subs="attributes,callouts,macros"]
  97. --------------------------------------------------
  98. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[rollover-response]
  99. --------------------------------------------------
  100. <1> Indicates whether all of the nodes have acknowledged the request
  101. <2> Indicates whether the requisite number of shard copies were started for
  102. each shard in the index before timing out
  103. <3> The name of the old index, eventually rolled over
  104. <4> The name of the new index
  105. <5> Whether the index has been rolled over
  106. <6> Whether the operation was performed or it was a dry run
  107. <7> The different conditions and whether they were matched or not