Skip to content

Commit

Permalink
REST hl client: cluster health to default to cluster level
Browse files Browse the repository at this point in the history
With elastic#29331 we added support for the cluster health API to the
high-level REST client. The transport client does not support the level
parameter, and it always returns all the info needed for shards level
rendering. We have maintained that behaviour when adding support for
cluster health to the high-level REST client, to ease migration, but the
correct thing to do is to default the high-level REST client to
`cluster` level, which is the same default as when going through the
Elasticsearch REST layer.
  • Loading branch information
javanna committed Jun 12, 2018
1 parent d5e8a5c commit ed7ef64
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ public void testClusterHealthYellowClusterLevel() throws IOException {
createIndex("index2", Settings.EMPTY);
ClusterHealthRequest request = new ClusterHealthRequest();
request.timeout("5s");
request.level(ClusterHealthRequest.Level.CLUSTER);
ClusterHealthResponse response = execute(request, highLevelClient().cluster()::health, highLevelClient().cluster()::healthAsync);

assertYellowShards(response);
Expand Down Expand Up @@ -173,6 +172,7 @@ public void testClusterHealthYellowSpecificIndex() throws IOException {
createIndex("index", Settings.EMPTY);
createIndex("index2", Settings.EMPTY);
ClusterHealthRequest request = new ClusterHealthRequest("index");
request.level(ClusterHealthRequest.Level.SHARDS);
request.timeout("5s");
ClusterHealthResponse response = execute(request, highLevelClient().cluster()::health, highLevelClient().cluster()::healthAsync);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1568,7 +1568,7 @@ public void testClusterHealth() {
healthRequest.level(level);
expectedParams.put("level", level.name().toLowerCase(Locale.ROOT));
} else {
expectedParams.put("level", "shards");
expectedParams.put("level", "cluster");
}
if (randomBoolean()) {
Priority priority = randomFrom(Priority.values());
Expand Down
1 change: 1 addition & 0 deletions docs/java-rest/high-level/cluster/health.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health-request-wai
include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health-request-level]
--------------------------------------------------
<1> The level of detail of the returned health information. Accepts a `ClusterHealthRequest.Level` value.
Default value is `cluster`.

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ public class ClusterHealthRequest extends MasterNodeReadRequest<ClusterHealthReq
private Priority waitForEvents = null;
/**
* Only used by the high-level REST Client. Controls the details level of the health information returned.
* The default value is 'shards' so it is backward compatible with the transport client behaviour.
* The default value is 'cluster'.
*/
private Level level = Level.SHARDS;
private Level level = Level.CLUSTER;

public ClusterHealthRequest() {
}
Expand Down Expand Up @@ -250,8 +250,7 @@ public Priority waitForEvents() {

/**
* Set the level of detail for the health information to be returned.
* Only used by the high-level REST Client
* The default value is 'shards' so it is backward compatible with the transport client behaviour.
* Only used by the high-level REST Client.
*/
public void level(Level level) {
this.level = Objects.requireNonNull(level, "level must not be null");
Expand All @@ -260,7 +259,6 @@ public void level(Level level) {
/**
* Get the level of detail for the health information to be returned.
* Only used by the high-level REST Client.
* The default value is 'shards' so it is backward compatible with the transport client behaviour.
*/
public Level level() {
return level;
Expand Down

0 comments on commit ed7ef64

Please sign in to comment.