health.asciidoc 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. [[java-rest-high-cluster-health]]
  2. === Cluster Health API
  3. The Cluster Health API allows getting cluster health.
  4. [[java-rest-high-cluster-health-request]]
  5. ==== Cluster Health Request
  6. A `ClusterHealthRequest`:
  7. ["source","java",subs="attributes,callouts,macros"]
  8. --------------------------------------------------
  9. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health-request]
  10. --------------------------------------------------
  11. There are no required parameters. By default, the client will check all indices and will not wait
  12. for any events.
  13. ==== Indices
  14. Indices which should be checked can be passed in the constructor:
  15. ["source","java",subs="attributes,callouts,macros"]
  16. --------------------------------------------------
  17. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health-request-indices-ctr]
  18. --------------------------------------------------
  19. Or using the corresponding setter method:
  20. ["source","java",subs="attributes,callouts,macros"]
  21. --------------------------------------------------
  22. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health-request-indices-setter]
  23. --------------------------------------------------
  24. ==== Other parameters
  25. Other parameters can be passed only through setter methods:
  26. ["source","java",subs="attributes,callouts,macros"]
  27. --------------------------------------------------
  28. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health-request-timeout]
  29. --------------------------------------------------
  30. <1> Timeout for the request as a `TimeValue`. Defaults to 30 seconds
  31. <2> As a `String`
  32. ["source","java",subs="attributes,callouts,macros"]
  33. --------------------------------------------------
  34. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health-request-master-timeout]
  35. --------------------------------------------------
  36. <1> Timeout to connect to the master node as a `TimeValue`. Defaults to the same as `timeout`
  37. <2> As a `String`
  38. ["source","java",subs="attributes,callouts,macros"]
  39. --------------------------------------------------
  40. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health-request-wait-status]
  41. --------------------------------------------------
  42. <1> The status to wait (e.g. `green`, `yellow`, or `red`). Accepts a `ClusterHealthStatus` value.
  43. <2> Using predefined method
  44. ["source","java",subs="attributes,callouts,macros"]
  45. --------------------------------------------------
  46. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health-request-wait-events]
  47. --------------------------------------------------
  48. <1> The priority of the events to wait for. Accepts a `Priority` value.
  49. ["source","java",subs="attributes,callouts,macros"]
  50. --------------------------------------------------
  51. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health-request-level]
  52. --------------------------------------------------
  53. <1> The level of detail of the returned health information. Accepts a `ClusterHealthRequest.Level` value.
  54. Default value is `cluster`.
  55. ["source","java",subs="attributes,callouts,macros"]
  56. --------------------------------------------------
  57. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health-request-wait-relocation]
  58. --------------------------------------------------
  59. <1> Wait for 0 relocating shards. Defaults to `false`
  60. ["source","java",subs="attributes,callouts,macros"]
  61. --------------------------------------------------
  62. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health-request-wait-initializing]
  63. --------------------------------------------------
  64. <1> Wait for 0 initializing shards. Defaults to `false`
  65. ["source","java",subs="attributes,callouts,macros"]
  66. --------------------------------------------------
  67. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health-request-wait-nodes]
  68. --------------------------------------------------
  69. <1> Wait for `N` nodes in the cluster. Defaults to `0`
  70. <2> Using `>=N`, `<=N`, `>N` and `<N` notation
  71. <3> Using `ge(N)`, `le(N)`, `gt(N)`, `lt(N)` notation
  72. ["source","java",subs="attributes,callouts,macros"]
  73. --------------------------------------------------
  74. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health-request-wait-active]
  75. --------------------------------------------------
  76. <1> Wait for all shards to be active in the cluster
  77. <2> Wait for `N` shards to be active in the cluster
  78. ["source","java",subs="attributes,callouts,macros"]
  79. --------------------------------------------------
  80. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health-request-local]
  81. --------------------------------------------------
  82. <1> Non-master node can be used for this request. Defaults to `false`
  83. [[java-rest-high-cluster-health-sync]]
  84. ==== Synchronous Execution
  85. ["source","java",subs="attributes,callouts,macros"]
  86. --------------------------------------------------
  87. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health-execute]
  88. --------------------------------------------------
  89. [[java-rest-high-cluster-health-async]]
  90. ==== Asynchronous Execution
  91. The asynchronous execution of a cluster health request requires both the
  92. `ClusterHealthRequest` instance and an `ActionListener` instance to be
  93. passed to the asynchronous method:
  94. ["source","java",subs="attributes,callouts,macros"]
  95. --------------------------------------------------
  96. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health-execute-async]
  97. --------------------------------------------------
  98. <1> The `ClusterHealthRequest` to execute and the `ActionListener` to use
  99. when the execution completes
  100. The asynchronous method does not block and returns immediately. Once it is
  101. completed the `ActionListener` is called back using the `onResponse` method
  102. if the execution successfully completed or using the `onFailure` method if
  103. it failed.
  104. A typical listener for `ClusterHealthResponse` looks like:
  105. ["source","java",subs="attributes,callouts,macros"]
  106. --------------------------------------------------
  107. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health-execute-listener]
  108. --------------------------------------------------
  109. <1> Called when the execution is successfully completed. The response is
  110. provided as an argument
  111. <2> Called in case of a failure. The raised exception is provided as an argument
  112. [[java-rest-high-cluster-health-response]]
  113. ==== Cluster Health Response
  114. The returned `ClusterHealthResponse` contains the next information about the
  115. cluster:
  116. ["source","java",subs="attributes,callouts,macros"]
  117. --------------------------------------------------
  118. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health-response-general]
  119. --------------------------------------------------
  120. <1> Name of the cluster
  121. <2> Cluster status (`green`, `yellow` or `red`)
  122. ["source","java",subs="attributes,callouts,macros"]
  123. --------------------------------------------------
  124. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health-response-request-status]
  125. --------------------------------------------------
  126. <1> Whether request was timed out while processing
  127. <2> Status of the request (`OK` or `REQUEST_TIMEOUT`). Other errors will be thrown as exceptions
  128. ["source","java",subs="attributes,callouts,macros"]
  129. --------------------------------------------------
  130. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health-response-nodes]
  131. --------------------------------------------------
  132. <1> Number of nodes in the cluster
  133. <2> Number of data nodes in the cluster
  134. ["source","java",subs="attributes,callouts,macros"]
  135. --------------------------------------------------
  136. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health-response-shards]
  137. --------------------------------------------------
  138. <1> Number of active shards
  139. <2> Number of primary active shards
  140. <3> Number of relocating shards
  141. <4> Number of initializing shards
  142. <5> Number of unassigned shards
  143. <6> Number of unassigned shards that are currently being delayed
  144. <7> Percent of active shards
  145. ["source","java",subs="attributes,callouts,macros"]
  146. --------------------------------------------------
  147. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health-response-task]
  148. --------------------------------------------------
  149. <1> Maximum wait time of all tasks in the queue
  150. <2> Number of currently pending tasks
  151. <3> Number of async fetches that are currently ongoing
  152. ["source","java",subs="attributes,callouts,macros"]
  153. --------------------------------------------------
  154. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health-response-indices]
  155. --------------------------------------------------
  156. <1> Detailed information about indices in the cluster
  157. ["source","java",subs="attributes,callouts,macros"]
  158. --------------------------------------------------
  159. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health-response-index]
  160. --------------------------------------------------
  161. <1> Detailed information about a specific index
  162. ["source","java",subs="attributes,callouts,macros"]
  163. --------------------------------------------------
  164. include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health-response-shard-details]
  165. --------------------------------------------------
  166. <1> Detailed information about a specific shard