From 2317fdf943f02257612b1bad7bc4cc4366a24cec Mon Sep 17 00:00:00 2001 From: Keith Massey Date: Wed, 6 Oct 2021 19:53:12 -0500 Subject: [PATCH] Changing name of shards field in node/stats api to shard_stats #78531 (#78806) If the _nodes/stats API received a level=shards request parameter, then the response would have two "shards" fields, which would cause problems with json parsers. This commit renames the "shards" field that currently only contains "total_count" to "shard_stats". Relates #78311 #75433 #78531 --- docs/reference/cluster/nodes-stats.asciidoc | 4 +-- rest-api-spec/build.gradle | 2 ++ .../rest-api-spec/api/nodes.stats.json | 4 +-- .../test/nodes.stats/11_indices_metrics.yml | 36 +++++++++---------- .../admin/indices/stats/CommonStatsFlags.java | 2 +- .../index/shard/ShardCountStats.java | 2 +- 6 files changed, 26 insertions(+), 24 deletions(-) diff --git a/docs/reference/cluster/nodes-stats.asciidoc b/docs/reference/cluster/nodes-stats.asciidoc index 614e0534ad15e..8acb8f15aa0a7 100644 --- a/docs/reference/cluster/nodes-stats.asciidoc +++ b/docs/reference/cluster/nodes-stats.asciidoc @@ -960,11 +960,11 @@ Time in milliseconds recovery operations were delayed due to throttling. ======= -`shards`:: +`shards_stats`:: (object) Contains statistics about all shards assigned to the node. + -.Properties of `shards` +.Properties of `shard_stats` [%collapsible%open] ======= `total_count`:: diff --git a/rest-api-spec/build.gradle b/rest-api-spec/build.gradle index 39e8b8014d522..537118b9fdbdc 100644 --- a/rest-api-spec/build.gradle +++ b/rest-api-spec/build.gradle @@ -1,3 +1,5 @@ + + apply plugin: 'elasticsearch.build' apply plugin: 'elasticsearch.publish' apply plugin: 'elasticsearch.rest-resources' diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/nodes.stats.json b/rest-api-spec/src/main/resources/rest-api-spec/api/nodes.stats.json index 338b4fa42a6e5..1352707c769da 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/nodes.stats.json +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/nodes.stats.json @@ -128,7 +128,7 @@ "store", "warmer", "suggest", - "shards" + "shard_stats" ], "description":"Limit the information returned for `indices` metric to the specific index metrics. Isn't used if `indices` (or `all`) metric isn't specified." } @@ -177,7 +177,7 @@ "store", "warmer", "suggest", - "shards" + "shard_stats" ], "description":"Limit the information returned for `indices` metric to the specific index metrics. Isn't used if `indices` (or `all`) metric isn't specified." }, diff --git a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/nodes.stats/11_indices_metrics.yml b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/nodes.stats/11_indices_metrics.yml index b233e9ed8890c..06d429b68387e 100644 --- a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/nodes.stats/11_indices_metrics.yml +++ b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/nodes.stats/11_indices_metrics.yml @@ -109,7 +109,7 @@ - is_false: nodes.$node_id.indices.segments - is_false: nodes.$node_id.indices.translog - is_false: nodes.$node_id.indices.recovery - - is_false: nodes.$node_id.indices.shards + - is_false: nodes.$node_id.indices.shard_stats --- "Metric - multi": @@ -167,7 +167,7 @@ - is_false: nodes.$node_id.indices.segments - is_false: nodes.$node_id.indices.translog - is_true: nodes.$node_id.indices.recovery - - is_false: nodes.$node_id.indices.shards + - is_false: nodes.$node_id.indices.shard_stats --- "Metric - _all include_segment_file_sizes": @@ -225,7 +225,7 @@ - is_true: nodes.$node_id.indices.segments - is_false: nodes.$node_id.indices.translog - is_false: nodes.$node_id.indices.recovery - - is_false: nodes.$node_id.indices.shards + - is_false: nodes.$node_id.indices.shard_stats - is_true: nodes.$node_id.indices.segments.file_sizes --- @@ -257,7 +257,7 @@ - is_true: nodes.$node_id.indices.segments - is_false: nodes.$node_id.indices.translog - is_false: nodes.$node_id.indices.recovery - - is_false: nodes.$node_id.indices.shards + - is_false: nodes.$node_id.indices.shard_stats --- "Metric - _all include_unloaded_segments": @@ -321,11 +321,11 @@ # null and cannot be tested here --- -"Metric - blank for indices shards": +"Metric - blank for indices shard_stats": - skip: features: [arbitrary_key] - version: " - 7.14.99" - reason: "total shard count added in version 7.15.0" + version: " - 7.15.0" + reason: "total shard count added in version 7.15.0, and fixed in 7.15.1" - do: nodes.info: {} - set: @@ -334,15 +334,15 @@ - do: nodes.stats: {} - - is_true: nodes.$node_id.indices.shards - - match: { nodes.$node_id.indices.shards.total_count: 0 } + - is_true: nodes.$node_id.indices.shard_stats + - match: { nodes.$node_id.indices.shard_stats.total_count: 0 } --- -"Metric - _all for indices shards": +"Metric - _all for indices shard_stats": - skip: features: [arbitrary_key] - version: " - 7.14.99" - reason: "total shard count added in version 7.15.0" + version: " - 7.15.0" + reason: "total shard count added in version 7.15.0, and fixed in 7.15.1" - do: nodes.info: {} - set: @@ -351,17 +351,17 @@ - do: nodes.stats: { metric: _all } - - is_true: nodes.$node_id.indices.shards - - match: { nodes.$node_id.indices.shards.total_count: 0 } + - is_true: nodes.$node_id.indices.shard_stats + - match: { nodes.$node_id.indices.shard_stats.total_count: 0 } --- -"indices shards total count test": +"indices shard_stats total count test": - skip: features: ["allowed_warnings", arbitrary_key] - version: " - 7.14.99" - reason: "total shard count added in version 7.15.0" + version: " - 7.15.0" + reason: "total shard count added in version 7.15.0, and fixed in 7.15.1" - do: indices.create: @@ -387,4 +387,4 @@ - do: nodes.stats: { metric: _all } - - gte: { nodes.$node_id.indices.shards.total_count: 1 } + - gte: { nodes.$node_id.indices.shard_stats.total_count: 1 } diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/stats/CommonStatsFlags.java b/server/src/main/java/org/elasticsearch/action/admin/indices/stats/CommonStatsFlags.java index 1cafb0d673a98..147649baaac28 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/stats/CommonStatsFlags.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/stats/CommonStatsFlags.java @@ -232,7 +232,7 @@ public enum Flag { // 14 was previously used for Suggest RequestCache("request_cache", 15), Recovery("recovery", 16), - Shards("shards", 18); + Shards("shard_stats", 18); private final String restName; private final int index; diff --git a/server/src/main/java/org/elasticsearch/index/shard/ShardCountStats.java b/server/src/main/java/org/elasticsearch/index/shard/ShardCountStats.java index 5ea65c35691ea..fe02534d9bf7d 100644 --- a/server/src/main/java/org/elasticsearch/index/shard/ShardCountStats.java +++ b/server/src/main/java/org/elasticsearch/index/shard/ShardCountStats.java @@ -56,7 +56,7 @@ public void writeTo(StreamOutput out) throws IOException { } static final class Fields { - static final String SHARDS = "shards"; + static final String SHARDS = "shard_stats"; static final String TOTAL_COUNT = "total_count"; }