1- [[java-rest-high-cluster-health]]
1+ --
2+ :api: health
3+ :request: ClusterHealthRequest
4+ :response: ClusterHealthResponse
5+ --
6+
7+ [id="{upid}-{api}"]
28=== Cluster Health API
39
410The Cluster Health API allows getting cluster health.
511
6- [[java-rest-high-cluster-health- request] ]
12+ [id="{upid}-{api}- request" ]
713==== Cluster Health Request
814
9- A `ClusterHealthRequest` :
15+ A +{request}+ :
1016
1117["source","java",subs="attributes,callouts,macros"]
1218--------------------------------------------------
13- include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health -request]
19+ include-tagged::{doc-tests-file}[{api} -request]
1420--------------------------------------------------
1521There are no required parameters. By default, the client will check all indices and will not wait
1622for any events.
@@ -21,14 +27,14 @@ Indices which should be checked can be passed in the constructor:
2127
2228["source","java",subs="attributes,callouts,macros"]
2329--------------------------------------------------
24- include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health -request-indices-ctr]
30+ include-tagged::{doc-tests-file}[{api} -request-indices-ctr]
2531--------------------------------------------------
2632
2733Or using the corresponding setter method:
2834
2935["source","java",subs="attributes,callouts,macros"]
3036--------------------------------------------------
31- include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health -request-indices-setter]
37+ include-tagged::{doc-tests-file}[{api} -request-indices-setter]
3238--------------------------------------------------
3339
3440==== Other parameters
@@ -37,138 +43,103 @@ Other parameters can be passed only through setter methods:
3743
3844["source","java",subs="attributes,callouts,macros"]
3945--------------------------------------------------
40- include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health -request-timeout]
46+ include-tagged::{doc-tests-file}[{api} -request-timeout]
4147--------------------------------------------------
4248<1> Timeout for the request as a `TimeValue`. Defaults to 30 seconds
4349<2> As a `String`
4450
4551["source","java",subs="attributes,callouts,macros"]
4652--------------------------------------------------
47- include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health -request-master-timeout]
53+ include-tagged::{doc-tests-file}[{api} -request-master-timeout]
4854--------------------------------------------------
4955<1> Timeout to connect to the master node as a `TimeValue`. Defaults to the same as `timeout`
5056<2> As a `String`
5157
5258["source","java",subs="attributes,callouts,macros"]
5359--------------------------------------------------
54- include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health -request-wait-status]
60+ include-tagged::{doc-tests-file}[{api} -request-wait-status]
5561--------------------------------------------------
5662<1> The status to wait (e.g. `green`, `yellow`, or `red`). Accepts a `ClusterHealthStatus` value.
5763<2> Using predefined method
5864
5965["source","java",subs="attributes,callouts,macros"]
6066--------------------------------------------------
61- include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health -request-wait-events]
67+ include-tagged::{doc-tests-file}[{api} -request-wait-events]
6268--------------------------------------------------
6369<1> The priority of the events to wait for. Accepts a `Priority` value.
6470
6571["source","java",subs="attributes,callouts,macros"]
6672--------------------------------------------------
67- include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health -request-level]
73+ include-tagged::{doc-tests-file}[{api} -request-level]
6874--------------------------------------------------
69- <1> The level of detail of the returned health information. Accepts a `ClusterHealthRequest .Level` value.
75+ <1> The level of detail of the returned health information. Accepts a +{request} .Level+ value.
7076
7177["source","java",subs="attributes,callouts,macros"]
7278--------------------------------------------------
73- include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health -request-wait-relocation]
79+ include-tagged::{doc-tests-file}[{api} -request-wait-relocation]
7480--------------------------------------------------
7581<1> Wait for 0 relocating shards. Defaults to `false`
7682
7783["source","java",subs="attributes,callouts,macros"]
7884--------------------------------------------------
79- include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health -request-wait-initializing]
85+ include-tagged::{doc-tests-file}[{api} -request-wait-initializing]
8086--------------------------------------------------
8187<1> Wait for 0 initializing shards. Defaults to `false`
8288
8389["source","java",subs="attributes,callouts,macros"]
8490--------------------------------------------------
85- include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health -request-wait-nodes]
91+ include-tagged::{doc-tests-file}[{api} -request-wait-nodes]
8692--------------------------------------------------
8793<1> Wait for `N` nodes in the cluster. Defaults to `0`
8894<2> Using `>=N`, `<=N`, `>N` and `<N` notation
8995<3> Using `ge(N)`, `le(N)`, `gt(N)`, `lt(N)` notation
9096
9197["source","java",subs="attributes,callouts,macros"]
9298--------------------------------------------------
93- include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health -request-wait-active]
99+ include-tagged::{doc-tests-file}[{api} -request-wait-active]
94100--------------------------------------------------
95101
96102<1> Wait for all shards to be active in the cluster
97103<2> Wait for `N` shards to be active in the cluster
98104
99105["source","java",subs="attributes,callouts,macros"]
100106--------------------------------------------------
101- include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health -request-local]
107+ include-tagged::{doc-tests-file}[{api} -request-local]
102108--------------------------------------------------
103109<1> Non-master node can be used for this request. Defaults to `false`
104110
105- [[java-rest-high-cluster-health-sync]]
106- ==== Synchronous Execution
107-
108- ["source","java",subs="attributes,callouts,macros"]
109- --------------------------------------------------
110- include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health-execute]
111- --------------------------------------------------
112-
113- [[java-rest-high-cluster-health-async]]
114- ==== Asynchronous Execution
115-
116- The asynchronous execution of a cluster health request requires both the
117- `ClusterHealthRequest` instance and an `ActionListener` instance to be
118- passed to the asynchronous method:
119-
120- ["source","java",subs="attributes,callouts,macros"]
121- --------------------------------------------------
122- include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health-execute-async]
123- --------------------------------------------------
124- <1> The `ClusterHealthRequest` to execute and the `ActionListener` to use
125- when the execution completes
126-
127- The asynchronous method does not block and returns immediately. Once it is
128- completed the `ActionListener` is called back using the `onResponse` method
129- if the execution successfully completed or using the `onFailure` method if
130- it failed.
131-
132- A typical listener for `ClusterHealthResponse` looks like:
133-
134- ["source","java",subs="attributes,callouts,macros"]
135- --------------------------------------------------
136- include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health-execute-listener]
137- --------------------------------------------------
138- <1> Called when the execution is successfully completed. The response is
139- provided as an argument
140- <2> Called in case of a failure. The raised exception is provided as an argument
111+ include::../execution.asciidoc[]
141112
142- [[java-rest-high-cluster-health- response] ]
113+ [id="{upid}-{api}- response" ]
143114==== Cluster Health Response
144115
145- The returned `ClusterHealthResponse` contains the next information about the
116+ The returned +{response}+ contains the next information about the
146117cluster:
147118
148119["source","java",subs="attributes,callouts,macros"]
149120--------------------------------------------------
150- include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health -response-general]
121+ include-tagged::{doc-tests-file}[{api} -response-general]
151122--------------------------------------------------
152123<1> Name of the cluster
153124<2> Cluster status (`green`, `yellow` or `red`)
154125
155126["source","java",subs="attributes,callouts,macros"]
156127--------------------------------------------------
157- include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health -response-request-status]
128+ include-tagged::{doc-tests-file}[{api} -response-request-status]
158129--------------------------------------------------
159130<1> Whether request was timed out while processing
160131<2> Status of the request (`OK` or `REQUEST_TIMEOUT`). Other errors will be thrown as exceptions
161132
162133["source","java",subs="attributes,callouts,macros"]
163134--------------------------------------------------
164- include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health -response-nodes]
135+ include-tagged::{doc-tests-file}[{api} -response-nodes]
165136--------------------------------------------------
166137<1> Number of nodes in the cluster
167138<2> Number of data nodes in the cluster
168139
169140["source","java",subs="attributes,callouts,macros"]
170141--------------------------------------------------
171- include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health -response-shards]
142+ include-tagged::{doc-tests-file}[{api} -response-shards]
172143--------------------------------------------------
173144<1> Number of active shards
174145<2> Number of primary active shards
@@ -180,26 +151,26 @@ include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health-response-sh
180151
181152["source","java",subs="attributes,callouts,macros"]
182153--------------------------------------------------
183- include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health -response-task]
154+ include-tagged::{doc-tests-file}[{api} -response-task]
184155--------------------------------------------------
185156<1> Maximum wait time of all tasks in the queue
186157<2> Number of currently pending tasks
187158<3> Number of async fetches that are currently ongoing
188159
189160["source","java",subs="attributes,callouts,macros"]
190161--------------------------------------------------
191- include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health -response-indices]
162+ include-tagged::{doc-tests-file}[{api} -response-indices]
192163--------------------------------------------------
193164<1> Detailed information about indices in the cluster
194165
195166["source","java",subs="attributes,callouts,macros"]
196167--------------------------------------------------
197- include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health -response-index]
168+ include-tagged::{doc-tests-file}[{api} -response-index]
198169--------------------------------------------------
199170<1> Detailed information about a specific index
200171
201172["source","java",subs="attributes,callouts,macros"]
202173--------------------------------------------------
203- include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health -response-shard-details]
174+ include-tagged::{doc-tests-file}[{api} -response-shard-details]
204175--------------------------------------------------
205176<1> Detailed information about a specific shard
0 commit comments