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,139 +43,104 @@ 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.
7076Default value is `cluster`.
7177
7278["source","java",subs="attributes,callouts,macros"]
7379--------------------------------------------------
74- include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health -request-wait-relocation]
80+ include-tagged::{doc-tests-file}[{api} -request-wait-relocation]
7581--------------------------------------------------
7682<1> Wait for 0 relocating shards. Defaults to `false`
7783
7884["source","java",subs="attributes,callouts,macros"]
7985--------------------------------------------------
80- include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health -request-wait-initializing]
86+ include-tagged::{doc-tests-file}[{api} -request-wait-initializing]
8187--------------------------------------------------
8288<1> Wait for 0 initializing shards. Defaults to `false`
8389
8490["source","java",subs="attributes,callouts,macros"]
8591--------------------------------------------------
86- include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health -request-wait-nodes]
92+ include-tagged::{doc-tests-file}[{api} -request-wait-nodes]
8793--------------------------------------------------
8894<1> Wait for `N` nodes in the cluster. Defaults to `0`
8995<2> Using `>=N`, `<=N`, `>N` and `<N` notation
9096<3> Using `ge(N)`, `le(N)`, `gt(N)`, `lt(N)` notation
9197
9298["source","java",subs="attributes,callouts,macros"]
9399--------------------------------------------------
94- include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health -request-wait-active]
100+ include-tagged::{doc-tests-file}[{api} -request-wait-active]
95101--------------------------------------------------
96102
97103<1> Wait for all shards to be active in the cluster
98104<2> Wait for `N` shards to be active in the cluster
99105
100106["source","java",subs="attributes,callouts,macros"]
101107--------------------------------------------------
102- include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health -request-local]
108+ include-tagged::{doc-tests-file}[{api} -request-local]
103109--------------------------------------------------
104110<1> Non-master node can be used for this request. Defaults to `false`
105111
106- [[java-rest-high-cluster-health-sync]]
107- ==== Synchronous Execution
108-
109- ["source","java",subs="attributes,callouts,macros"]
110- --------------------------------------------------
111- include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health-execute]
112- --------------------------------------------------
113-
114- [[java-rest-high-cluster-health-async]]
115- ==== Asynchronous Execution
116-
117- The asynchronous execution of a cluster health request requires both the
118- `ClusterHealthRequest` instance and an `ActionListener` instance to be
119- passed to the asynchronous method:
120-
121- ["source","java",subs="attributes,callouts,macros"]
122- --------------------------------------------------
123- include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health-execute-async]
124- --------------------------------------------------
125- <1> The `ClusterHealthRequest` to execute and the `ActionListener` to use
126- when the execution completes
127-
128- The asynchronous method does not block and returns immediately. Once it is
129- completed the `ActionListener` is called back using the `onResponse` method
130- if the execution successfully completed or using the `onFailure` method if
131- it failed.
132-
133- A typical listener for `ClusterHealthResponse` looks like:
134-
135- ["source","java",subs="attributes,callouts,macros"]
136- --------------------------------------------------
137- include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health-execute-listener]
138- --------------------------------------------------
139- <1> Called when the execution is successfully completed. The response is
140- provided as an argument
141- <2> Called in case of a failure. The raised exception is provided as an argument
112+ include::../execution.asciidoc[]
142113
143- [[java-rest-high-cluster-health- response] ]
114+ [id="{upid}-{api}- response" ]
144115==== Cluster Health Response
145116
146- The returned `ClusterHealthResponse` contains the next information about the
117+ The returned +{response}+ contains the next information about the
147118cluster:
148119
149120["source","java",subs="attributes,callouts,macros"]
150121--------------------------------------------------
151- include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health -response-general]
122+ include-tagged::{doc-tests-file}[{api} -response-general]
152123--------------------------------------------------
153124<1> Name of the cluster
154125<2> Cluster status (`green`, `yellow` or `red`)
155126
156127["source","java",subs="attributes,callouts,macros"]
157128--------------------------------------------------
158- include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health -response-request-status]
129+ include-tagged::{doc-tests-file}[{api} -response-request-status]
159130--------------------------------------------------
160131<1> Whether request was timed out while processing
161132<2> Status of the request (`OK` or `REQUEST_TIMEOUT`). Other errors will be thrown as exceptions
162133
163134["source","java",subs="attributes,callouts,macros"]
164135--------------------------------------------------
165- include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health -response-nodes]
136+ include-tagged::{doc-tests-file}[{api} -response-nodes]
166137--------------------------------------------------
167138<1> Number of nodes in the cluster
168139<2> Number of data nodes in the cluster
169140
170141["source","java",subs="attributes,callouts,macros"]
171142--------------------------------------------------
172- include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health -response-shards]
143+ include-tagged::{doc-tests-file}[{api} -response-shards]
173144--------------------------------------------------
174145<1> Number of active shards
175146<2> Number of primary active shards
@@ -181,26 +152,26 @@ include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health-response-sh
181152
182153["source","java",subs="attributes,callouts,macros"]
183154--------------------------------------------------
184- include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health -response-task]
155+ include-tagged::{doc-tests-file}[{api} -response-task]
185156--------------------------------------------------
186157<1> Maximum wait time of all tasks in the queue
187158<2> Number of currently pending tasks
188159<3> Number of async fetches that are currently ongoing
189160
190161["source","java",subs="attributes,callouts,macros"]
191162--------------------------------------------------
192- include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health -response-indices]
163+ include-tagged::{doc-tests-file}[{api} -response-indices]
193164--------------------------------------------------
194165<1> Detailed information about indices in the cluster
195166
196167["source","java",subs="attributes,callouts,macros"]
197168--------------------------------------------------
198- include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health -response-index]
169+ include-tagged::{doc-tests-file}[{api} -response-index]
199170--------------------------------------------------
200171<1> Detailed information about a specific index
201172
202173["source","java",subs="attributes,callouts,macros"]
203174--------------------------------------------------
204- include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health -response-shard-details]
175+ include-tagged::{doc-tests-file}[{api} -response-shard-details]
205176--------------------------------------------------
206177<1> Detailed information about a specific shard
0 commit comments