Remove the suggest metric from stats APIs (#29635)

This metric previously existed for backwards compatibility reasons
although the suggest stats were folded into search stats. This metric
was deprecated in 6.3.0 and this commit removes them for 7.0.0.
This commit is contained in:
Jason Tedor 2018-04-24 19:03:48 -04:00 committed by GitHub
parent 25e45a765c
commit 2c3e71f116
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 12 additions and 58 deletions

View File

@ -12,6 +12,8 @@
<<write-thread-pool-fallback, Removed `thread_pool.bulk.*` settings and <<write-thread-pool-fallback, Removed `thread_pool.bulk.*` settings and
`es.thread_pool.write.use_bulk_as_display_name` system property>> ({pull}29609[#29609]) `es.thread_pool.write.use_bulk_as_display_name` system property>> ({pull}29609[#29609])
<<remove-suggest-metric, Removed `suggest` metric on stats APIs>> ({pull}29635[#29635])
=== Breaking Java Changes === Breaking Java Changes
=== Deprecations === Deprecations

View File

@ -22,7 +22,14 @@ The following parameters starting with underscore have been removed:
Instead of these removed parameters, use their non camel case equivalents without Instead of these removed parameters, use their non camel case equivalents without
starting underscore, e.g. use `version_type` instead of `_version_type` or `versionType`. starting underscore, e.g. use `version_type` instead of `_version_type` or `versionType`.
==== The parameter `fields` deprecated in 6.x has been removed from Bulk request ==== The parameter `fields` deprecated in 6.x has been removed from Bulk request
and Update request. The Update API returns `400 - Bad request` if request contains and Update request. The Update API returns `400 - Bad request` if request contains
unknown parameters (instead of ignored in the previous version). unknown parameters (instead of ignored in the previous version).
[[remove-suggest-metric]]
==== Remove support for `suggest` metric/index metric in indices stats and nodes stats APIs
Previously, `suggest` stats were folded into `search` stats. Support for the
`suggest` metric on the indices stats and nodes stats APIs remained for
backwards compatibility. Backwards support for the `suggest` metric was
deprecated in 6.3.0 and now removed in 7.0.0.

View File

@ -152,9 +152,6 @@ public class CommonStats implements Writeable, ToXContentFragment {
case Translog: case Translog:
translog = new TranslogStats(); translog = new TranslogStats();
break; break;
case Suggest:
// skip
break;
case RequestCache: case RequestCache:
requestCache = new RequestCacheStats(); requestCache = new RequestCacheStats();
break; break;
@ -213,9 +210,6 @@ public class CommonStats implements Writeable, ToXContentFragment {
case Translog: case Translog:
translog = indexShard.translogStats(); translog = indexShard.translogStats();
break; break;
case Suggest:
// skip
break;
case RequestCache: case RequestCache:
requestCache = indexShard.requestCache().stats(); requestCache = indexShard.requestCache().stats();
break; break;

View File

@ -221,7 +221,7 @@ public class CommonStatsFlags implements Writeable, Cloneable {
Completion("completion", 11), Completion("completion", 11),
Segments("segments", 12), Segments("segments", 12),
Translog("translog", 13), Translog("translog", 13),
Suggest("suggest", 14), // unused // 14 was previously used for Suggest
RequestCache("request_cache", 15), RequestCache("request_cache", 15),
Recovery("recovery", 16); Recovery("recovery", 16);

View File

@ -229,15 +229,6 @@ public class IndicesStatsRequest extends BroadcastRequest<IndicesStatsRequest> {
return flags.isSet(Flag.Translog); return flags.isSet(Flag.Translog);
} }
public IndicesStatsRequest suggest(boolean suggest) {
flags.set(Flag.Suggest, suggest);
return this;
}
public boolean suggest() {
return flags.isSet(Flag.Suggest);
}
public IndicesStatsRequest requestCache(boolean requestCache) { public IndicesStatsRequest requestCache(boolean requestCache) {
flags.set(Flag.RequestCache, requestCache); flags.set(Flag.RequestCache, requestCache);
return this; return this;

View File

@ -148,9 +148,6 @@ public class TransportIndicesStatsAction extends TransportBroadcastByNodeAction<
if (request.translog()) { if (request.translog()) {
flags.set(CommonStatsFlags.Flag.Translog); flags.set(CommonStatsFlags.Flag.Translog);
} }
if (request.suggest()) {
flags.set(CommonStatsFlags.Flag.Suggest);
}
if (request.requestCache()) { if (request.requestCache()) {
flags.set(CommonStatsFlags.Flag.RequestCache); flags.set(CommonStatsFlags.Flag.RequestCache);
} }

View File

@ -146,10 +146,6 @@ public class RestNodesStatsAction extends BaseRestHandler {
for (final String indexMetric : indexMetrics) { for (final String indexMetric : indexMetrics) {
final Consumer<CommonStatsFlags> handler = FLAGS.get(indexMetric); final Consumer<CommonStatsFlags> handler = FLAGS.get(indexMetric);
if (handler != null) { if (handler != null) {
if ("suggest".equals(indexMetric)) {
deprecationLogger.deprecated(
"the suggest index metric is deprecated on the nodes stats API [" + request.uri() + "]");
}
handler.accept(flags); handler.accept(flags);
} else { } else {
invalidIndexMetrics.add(indexMetric); invalidIndexMetrics.add(indexMetric);

View File

@ -62,7 +62,6 @@ public class RestIndicesStatsAction extends BaseRestHandler {
metrics.put("store", r -> r.store(true)); metrics.put("store", r -> r.store(true));
metrics.put("indexing", r -> r.indexing(true)); metrics.put("indexing", r -> r.indexing(true));
metrics.put("search", r -> r.search(true)); metrics.put("search", r -> r.search(true));
metrics.put("suggest", r -> r.search(true));
metrics.put("get", r -> r.get(true)); metrics.put("get", r -> r.get(true));
metrics.put("merge", r -> r.merge(true)); metrics.put("merge", r -> r.merge(true));
metrics.put("refresh", r -> r.refresh(true)); metrics.put("refresh", r -> r.refresh(true));
@ -102,9 +101,6 @@ public class RestIndicesStatsAction extends BaseRestHandler {
for (final String metric : metrics) { for (final String metric : metrics) {
final Consumer<IndicesStatsRequest> consumer = METRICS.get(metric); final Consumer<IndicesStatsRequest> consumer = METRICS.get(metric);
if (consumer != null) { if (consumer != null) {
if ("suggest".equals(metric)) {
deprecationLogger.deprecated("the suggest metric is deprecated on the indices stats API [" + request.uri() + "]");
}
consumer.accept(indicesStatsRequest); consumer.accept(indicesStatsRequest);
} else { } else {
invalidMetrics.add(metric); invalidMetrics.add(metric);

View File

@ -589,10 +589,6 @@ public class IndexStatsIT extends ESIntegTestCase {
IndicesStatsResponse stats = builder.execute().actionGet(); IndicesStatsResponse stats = builder.execute().actionGet();
for (Flag flag : values) { for (Flag flag : values) {
if (flag == Flag.Suggest) {
// suggest flag is unused
continue;
}
assertThat(isSet(flag, stats.getPrimaries()), equalTo(false)); assertThat(isSet(flag, stats.getPrimaries()), equalTo(false));
assertThat(isSet(flag, stats.getTotal()), equalTo(false)); assertThat(isSet(flag, stats.getTotal()), equalTo(false));
} }
@ -628,10 +624,6 @@ public class IndexStatsIT extends ESIntegTestCase {
} }
for (Flag flag : EnumSet.complementOf(flags)) { // check the complement for (Flag flag : EnumSet.complementOf(flags)) { // check the complement
if (flag == Flag.Suggest) {
// suggest flag is unused
continue;
}
assertThat(isSet(flag, stats.getPrimaries()), equalTo(false)); assertThat(isSet(flag, stats.getPrimaries()), equalTo(false));
assertThat(isSet(flag, stats.getTotal()), equalTo(false)); assertThat(isSet(flag, stats.getTotal()), equalTo(false));
} }
@ -684,7 +676,7 @@ public class IndexStatsIT extends ESIntegTestCase {
public void testFlagOrdinalOrder() { public void testFlagOrdinalOrder() {
Flag[] flags = new Flag[]{Flag.Store, Flag.Indexing, Flag.Get, Flag.Search, Flag.Merge, Flag.Flush, Flag.Refresh, Flag[] flags = new Flag[]{Flag.Store, Flag.Indexing, Flag.Get, Flag.Search, Flag.Merge, Flag.Flush, Flag.Refresh,
Flag.QueryCache, Flag.FieldData, Flag.Docs, Flag.Warmer, Flag.Completion, Flag.Segments, Flag.QueryCache, Flag.FieldData, Flag.Docs, Flag.Warmer, Flag.Completion, Flag.Segments,
Flag.Translog, Flag.Suggest, Flag.RequestCache, Flag.Recovery}; Flag.Translog, Flag.RequestCache, Flag.Recovery};
assertThat(flags.length, equalTo(Flag.values().length)); assertThat(flags.length, equalTo(Flag.values().length));
for (int i = 0; i < flags.length; i++) { for (int i = 0; i < flags.length; i++) {
@ -935,8 +927,6 @@ public class IndexStatsIT extends ESIntegTestCase {
case Translog: case Translog:
builder.setTranslog(set); builder.setTranslog(set);
break; break;
case Suggest: // unused
break;
case RequestCache: case RequestCache:
builder.setRequestCache(set); builder.setRequestCache(set);
break; break;
@ -979,8 +969,6 @@ public class IndexStatsIT extends ESIntegTestCase {
return response.getSegments() != null; return response.getSegments() != null;
case Translog: case Translog:
return response.getTranslog() != null; return response.getTranslog() != null;
case Suggest: // unused
return true;
case RequestCache: case RequestCache:
return response.getRequestCache() != null; return response.getRequestCache() != null;
case Recovery: case Recovery:

View File

@ -148,14 +148,4 @@ public class RestNodesStatsActionTests extends ESTestCase {
containsString("request [/_nodes/stats] contains index metrics [" + indexMetric + "] but all stats requested"))); containsString("request [/_nodes/stats] contains index metrics [" + indexMetric + "] but all stats requested")));
} }
public void testSuggestIsDeprecated() throws IOException {
final Map<String, String> params =
Stream.of(Tuple.tuple("metric", "indices"), Tuple.tuple("index_metric", "suggest"))
.collect(Collectors.toMap(Tuple::v1, Tuple::v2));
final RestRequest request =
new FakeRestRequest.Builder(xContentRegistry()).withPath("/_nodes/stats").withParams(params).build();
action.prepareRequest(request, mock(NodeClient.class));
assertWarnings("the suggest index metric is deprecated on the nodes stats API [/_nodes/stats]" );
}
} }

View File

@ -84,11 +84,4 @@ public class RestIndicesStatsActionTests extends ESTestCase {
assertThat(e, hasToString(containsString("request [/_stats] contains _all and individual metrics [_all," + metric + "]"))); assertThat(e, hasToString(containsString("request [/_stats] contains _all and individual metrics [_all," + metric + "]")));
} }
public void testSuggestIsDeprecated() throws IOException {
final Map<String, String> params = Collections.singletonMap("metric", "suggest");
final RestRequest request = new FakeRestRequest.Builder(xContentRegistry()).withPath("/_stats").withParams(params).build();
action.prepareRequest(request, mock(NodeClient.class));
assertWarnings("the suggest metric is deprecated on the indices stats API [/_stats]");
}
} }