Skip to content
This repository was archived by the owner on Sep 10, 2019. It is now read-only.

Commit d35a9c2

Browse files
committed
Adding tests for cluster APIs and more documentation
1 parent d0ede5a commit d35a9c2

File tree

2 files changed

+657
-148
lines changed

2 files changed

+657
-148
lines changed

src/main/groovy/org/elasticsearch/groovy/client/ClusterAdminClientExtensions.groovy

Lines changed: 108 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,15 @@ class ClusterAdminClientExtensions extends AbstractClientExtensions {
8484

8585
/**
8686
* Get the health of the cluster.
87+
* <p>
88+
* The Health API can be useful for infrastructure checkups (aka health checkups, hence the API's name). It can
89+
* be used to determine the cluster health right now or, often more usefully, it can block until it observes a
90+
* specific state of interest (e.g., a degraded state):
91+
* <pre>
92+
* ClusterHealthResponse response = client.admin.cluster.healthSync {
93+
* waitForStatus ClusterHealthStatus.YELLOW
94+
* }
95+
* </pre>
8796
*
8897
* @param self The {@code this} reference for the {@link ClusterAdminClient}.
8998
* @param requestClosure The map-like closure that configures the {@link ClusterHealthRequest}.
@@ -96,6 +105,15 @@ class ClusterAdminClientExtensions extends AbstractClientExtensions {
96105

97106
/**
98107
* Get the health of the cluster.
108+
* <p>
109+
* The Health API can be useful for infrastructure checkups (aka health checkups, hence the API's name). It can
110+
* be used to determine the cluster health right now or, often more usefully, it can block until it observes a
111+
* specific state of interest (e.g., a degraded state):
112+
* <pre>
113+
* ClusterHealthResponse response = client.admin.cluster.health {
114+
* waitForStatus ClusterHealthStatus.YELLOW
115+
* }.actionGet()
116+
* </pre>
99117
*
100118
* @param self The {@code this} reference for the {@link ClusterAdminClient}.
101119
* @param requestClosure The map-like closure that configures the {@link ClusterHealthRequest}.
@@ -108,6 +126,15 @@ class ClusterAdminClientExtensions extends AbstractClientExtensions {
108126

109127
/**
110128
* Get the health of the cluster.
129+
* <p>
130+
* The Health API can be useful for infrastructure checkups (aka health checkups, hence the API's name). It can
131+
* be used to determine the cluster health right now or, often more usefully, it can block until it observes a
132+
* specific state of interest (e.g., a degraded state):
133+
* <pre>
134+
* ClusterHealthResponse response = client.admin.cluster.healthAsync {
135+
* waitForStatus ClusterHealthStatus.YELLOW
136+
* }.actionGet()
137+
* </pre>
111138
*
112139
* @param self The {@code this} reference for the {@link ClusterAdminClient}.
113140
* @param requestClosure The map-like closure that configures the {@link ClusterHealthRequest}.
@@ -276,6 +303,10 @@ class ClusterAdminClientExtensions extends AbstractClientExtensions {
276303

277304
/**
278305
* Get the nodes info of the cluster.
306+
* <p>
307+
* NodesInfoResponse response = clusterAdminClient.nodesInfoSync {
308+
* all() // collect all info possible
309+
* }
279310
*
280311
* @param self The {@code this} reference for the {@link ClusterAdminClient}.
281312
* @param requestClosure The map-like closure that configures the {@link NodesInfoRequest}.
@@ -288,6 +319,10 @@ class ClusterAdminClientExtensions extends AbstractClientExtensions {
288319

289320
/**
290321
* Get the nodes info of the cluster.
322+
* <p>
323+
* NodesInfoResponse response = clusterAdminClient.nodesInfo {
324+
* all() // collect all info possible
325+
* }.actionGet()
291326
*
292327
* @param self The {@code this} reference for the {@link ClusterAdminClient}.
293328
* @param requestClosure The map-like closure that configures the {@link NodesInfoRequest}.
@@ -300,6 +335,10 @@ class ClusterAdminClientExtensions extends AbstractClientExtensions {
300335

301336
/**
302337
* Get the nodes info of the cluster.
338+
* <p>
339+
* NodesInfoResponse response = clusterAdminClient.nodesInfoAsync {
340+
* all() // collect all info possible
341+
* }.actionGet()
303342
*
304343
* @param self The {@code this} reference for the {@link ClusterAdminClient}.
305344
* @param requestClosure The map-like closure that configures the {@link NodesInfoRequest}.
@@ -312,6 +351,11 @@ class ClusterAdminClientExtensions extends AbstractClientExtensions {
312351

313352
/**
314353
* Get the nodes stats of the cluster.
354+
* <pre>
355+
* NodesStatsResponse response = clusterAdminClient.nodesStatsSync {
356+
* all() // collect all stats possible
357+
* }
358+
* </pre>
315359
*
316360
* @param self The {@code this} reference for the {@link ClusterAdminClient}.
317361
* @param requestClosure The map-like closure that configures the {@link NodesStatsRequest}.
@@ -324,6 +368,11 @@ class ClusterAdminClientExtensions extends AbstractClientExtensions {
324368

325369
/**
326370
* Get the nodes stats of the cluster.
371+
* <pre>
372+
* NodesStatsResponse response = clusterAdminClient.nodesStats {
373+
* all() // collect all stats possible
374+
* }.actionGet()
375+
* </pre>
327376
*
328377
* @param self The {@code this} reference for the {@link ClusterAdminClient}.
329378
* @param requestClosure The map-like closure that configures the {@link NodesStatsRequest}.
@@ -336,6 +385,11 @@ class ClusterAdminClientExtensions extends AbstractClientExtensions {
336385

337386
/**
338387
* Get the nodes stats of the cluster.
388+
* <pre>
389+
* NodesStatsResponse response = clusterAdminClient.nodesStatsAsync {
390+
* all() // collect all stats possible
391+
* }.actionGet()
392+
* </pre>
339393
*
340394
* @param self The {@code this} reference for the {@link ClusterAdminClient}.
341395
* @param requestClosure The map-like closure that configures the {@link NodesStatsRequest}.
@@ -350,7 +404,12 @@ class ClusterAdminClientExtensions extends AbstractClientExtensions {
350404
* Get the hot threads details from nodes in the cluster.
351405
* <p>
352406
* This is particularly useful when you feel the need to debug activity on the cluster, so this can be requested
353-
* and logged.
407+
* and logged. To get a reasonable number of threads (above the conservative default), you might do something like:
408+
* <pre>
409+
* NodesHotThreadsResponse response = client.admin.cluster.nodesHotThreads {
410+
* threads 500
411+
* }.actionGet()
412+
* </pre>
354413
*
355414
* @param self The {@code this} reference for the {@link ClusterAdminClient}.
356415
* @param requestClosure The map-like closure that configures the {@link NodesHotThreadsRequest}.
@@ -365,7 +424,12 @@ class ClusterAdminClientExtensions extends AbstractClientExtensions {
365424
* Get the hot threads details from nodes in the cluster.
366425
* <p>
367426
* This is particularly useful when you feel the need to debug activity on the cluster, so this can be requested
368-
* and logged.
427+
* and logged. To get a reasonable number of threads (above the conservative default), you might do something like:
428+
* <pre>
429+
* NodesHotThreadsResponse response = client.admin.cluster.nodesHotThreads {
430+
* threads 500
431+
* }.actionGet()
432+
* </pre>
369433
*
370434
* @param self The {@code this} reference for the {@link ClusterAdminClient}.
371435
* @param requestClosure The map-like closure that configures the {@link NodesHotThreadsRequest}.
@@ -381,7 +445,12 @@ class ClusterAdminClientExtensions extends AbstractClientExtensions {
381445
* Get the hot threads details from nodes in the cluster.
382446
* <p>
383447
* This is particularly useful when you feel the need to debug activity on the cluster, so this can be requested
384-
* and logged.
448+
* and logged. To get a reasonable number of threads (above the conservative default), you might do something like:
449+
* <pre>
450+
* NodesHotThreadsResponse response = client.admin.cluster.nodesHotThreads {
451+
* threads 500
452+
* }.actionGet()
453+
* </pre>
385454
*
386455
* @param self The {@code this} reference for the {@link ClusterAdminClient}.
387456
* @param requestClosure The map-like closure that configures the {@link NodesHotThreadsRequest}.
@@ -635,6 +704,11 @@ class ClusterAdminClientExtensions extends AbstractClientExtensions {
635704

636705
/**
637706
* Get snapshots from a repository.
707+
* <pre>
708+
* GetSnapshotsResponse response = clusterAdminClient.getSnapshotsSync {
709+
* repository "my-repo-name"
710+
* }
711+
* </pre>
638712
*
639713
* @param self The {@code this} reference for the {@link ClusterAdminClient}.
640714
* @param requestClosure The map-like closure that configures the {@link GetSnapshotsRequest}.
@@ -648,6 +722,11 @@ class ClusterAdminClientExtensions extends AbstractClientExtensions {
648722

649723
/**
650724
* Get snapshots from a repository.
725+
* <pre>
726+
* GetSnapshotsResponse response = clusterAdminClient.getSnapshots {
727+
* repository "my-repo-name"
728+
* }.actionGet()
729+
* </pre>
651730
*
652731
* @param self The {@code this} reference for the {@link ClusterAdminClient}.
653732
* @param requestClosure The map-like closure that configures the {@link GetSnapshotsRequest}.
@@ -662,6 +741,11 @@ class ClusterAdminClientExtensions extends AbstractClientExtensions {
662741

663742
/**
664743
* Get snapshots from a repository.
744+
* <pre>
745+
* GetSnapshotsResponse response = clusterAdminClient.getSnapshotsAsync {
746+
* repository "my-repo-name"
747+
* }.actionGet()
748+
* </pre>
665749
*
666750
* @param self The {@code this} reference for the {@link ClusterAdminClient}.
667751
* @param requestClosure The map-like closure that configures the {@link GetSnapshotsRequest}.
@@ -769,6 +853,13 @@ class ClusterAdminClientExtensions extends AbstractClientExtensions {
769853
* Get a list of pending cluster tasks that are scheduled to be executed.
770854
* <p>
771855
* This includes operations that update the cluster state (e.g., a create index operation).
856+
* <pre>
857+
* PendingClusterTasksResponse response = client.admin.cluster.pendingClusterTasksSync {
858+
* // There are currently no parameters for the request
859+
* }
860+
* </pre>
861+
* This is particularly useful when attempting to understand why a cluster's master is showing slow responses.
862+
* Specifically, it's useful to check this if the cluster's {@link #health} is yellow or red.
772863
*
773864
* @param self The {@code this} reference for the {@link ClusterAdminClient}.
774865
* @param requestClosure The map-like closure that configures the {@link PendingClusterTasksRequest}.
@@ -783,6 +874,13 @@ class ClusterAdminClientExtensions extends AbstractClientExtensions {
783874
* Get a list of pending cluster tasks that are scheduled to be executed.
784875
* <p>
785876
* This includes operations that update the cluster state (e.g., a create index operation).
877+
* <pre>
878+
* PendingClusterTasksResponse response = client.admin.cluster.pendingClusterTasks {
879+
* // There are currently no parameters for the request
880+
* }.actionGet()
881+
* </pre>
882+
* This is particularly useful when attempting to understand why a cluster's master is showing slow responses.
883+
* Specifically, it's useful to check this if the cluster's {@link #health} is yellow or red.
786884
*
787885
* @param self The {@code this} reference for the {@link ClusterAdminClient}.
788886
* @param requestClosure The map-like closure that configures the {@link PendingClusterTasksRequest}.
@@ -798,6 +896,13 @@ class ClusterAdminClientExtensions extends AbstractClientExtensions {
798896
* Get a list of pending cluster tasks that are scheduled to be executed.
799897
* <p>
800898
* This includes operations that update the cluster state (e.g., a create index operation).
899+
* <pre>
900+
* PendingClusterTasksResponse response = client.admin.cluster.pendingClusterTasksAsync {
901+
* // There are currently no parameters for the request
902+
* }.actionGet()
903+
* </pre>
904+
* This is particularly useful when attempting to understand why a cluster's master is showing slow responses.
905+
* Specifically, it's useful to check this if the cluster's {@link #health} is yellow or red.
801906
*
802907
* @param self The {@code this} reference for the {@link ClusterAdminClient}.
803908
* @param requestClosure The map-like closure that configures the {@link PendingClusterTasksRequest}.

0 commit comments

Comments
 (0)