shrink_index.asciidoc 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. [[java-rest-high-shrink-index]]
  2. === Shrink Index API
  3. [[java-rest-high-shrink-index-request]]
  4. ==== Resize Request
  5. The Shrink API requires a `ResizeRequest` instance.
  6. A `ResizeRequest` requires two string arguments:
  7. ["source","java",subs="attributes,callouts,macros"]
  8. --------------------------------------------------
  9. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[shrink-index-request]
  10. --------------------------------------------------
  11. <1> The target index (first argument) to shrink the source index (second argument) into
  12. ==== Optional arguments
  13. The following arguments can optionally be provided:
  14. ["source","java",subs="attributes,callouts,macros"]
  15. --------------------------------------------------
  16. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[shrink-index-request-timeout]
  17. --------------------------------------------------
  18. <1> Timeout to wait for the all the nodes to acknowledge the index is opened
  19. as a `TimeValue`
  20. <2> Timeout to wait for the all the nodes to acknowledge the index is opened
  21. as a `String`
  22. ["source","java",subs="attributes,callouts,macros"]
  23. --------------------------------------------------
  24. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[shrink-index-request-masterTimeout]
  25. --------------------------------------------------
  26. <1> Timeout to connect to the master node as a `TimeValue`
  27. <2> Timeout to connect to the master node as a `String`
  28. ["source","java",subs="attributes,callouts,macros"]
  29. --------------------------------------------------
  30. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[shrink-index-request-waitForActiveShards]
  31. --------------------------------------------------
  32. <1> The number of active shard copies to wait for before the shrink index API
  33. returns a response, as an `int`
  34. <2> The number of active shard copies to wait for before the shrink index API
  35. returns a response, as an `ActiveShardCount`
  36. ["source","java",subs="attributes,callouts,macros"]
  37. --------------------------------------------------
  38. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[shrink-index-request-settings]
  39. --------------------------------------------------
  40. <1> The number of shards on the target of the shrink index request
  41. <2> Remove the allocation requirement copied from the source index
  42. ["source","java",subs="attributes,callouts,macros"]
  43. --------------------------------------------------
  44. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[shrink-index-request-aliases]
  45. --------------------------------------------------
  46. <1> The aliases to associate the target index with
  47. [[java-rest-high-shrink-index-sync]]
  48. ==== Synchronous Execution
  49. ["source","java",subs="attributes,callouts,macros"]
  50. --------------------------------------------------
  51. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[shrink-index-execute]
  52. --------------------------------------------------
  53. [[java-rest-high-shrink-index-async]]
  54. ==== Asynchronous Execution
  55. The asynchronous execution of a shrink index request requires both the `ResizeRequest`
  56. instance and an `ActionListener` instance to be passed to the asynchronous
  57. method:
  58. ["source","java",subs="attributes,callouts,macros"]
  59. --------------------------------------------------
  60. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[shrink-index-execute-async]
  61. --------------------------------------------------
  62. <1> The `ResizeRequest` to execute and the `ActionListener` to use when
  63. the execution completes
  64. The asynchronous method does not block and returns immediately. Once it is
  65. completed the `ActionListener` is called back using the `onResponse` method
  66. if the execution successfully completed or using the `onFailure` method if
  67. it failed.
  68. A typical listener for `ResizeResponse` looks like:
  69. ["source","java",subs="attributes,callouts,macros"]
  70. --------------------------------------------------
  71. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[shrink-index-execute-listener]
  72. --------------------------------------------------
  73. <1> Called when the execution is successfully completed. The response is
  74. provided as an argument
  75. <2> Called in case of failure. The raised exception is provided as an argument
  76. [[java-rest-high-shrink-index-response]]
  77. ==== Shrink Index Response
  78. The returned `ResizeResponse` allows to retrieve information about the
  79. executed operation as follows:
  80. ["source","java",subs="attributes,callouts,macros"]
  81. --------------------------------------------------
  82. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[shrink-index-response]
  83. --------------------------------------------------
  84. <1> Indicates whether all of the nodes have acknowledged the request
  85. <2> Indicates whether the requisite number of shard copies were started for
  86. each shard in the index before timing out