From 5bd8e1399b193236ebd750a660e4d0585687aaa7 Mon Sep 17 00:00:00 2001 From: Luca Cavanna Date: Mon, 8 Mar 2021 12:45:32 +0100 Subject: [PATCH] Adjust compatibility and tests of runtime fields telemetry Runtime fields telemetry has been entirely moved to be part of cluster stats API in 7.x and master. This commit removes the backwards compatibility layer that was needed before such change was backported. --- .../test/cluster.stats/10_basic.yml | 8 ++--- .../admin/cluster/stats/MappingStats.java | 11 ++---- .../xpack/core/XPackClientPlugin.java | 4 +-- .../RuntimeFieldsFeatureSetUsage.java | 36 ------------------- 4 files changed, 7 insertions(+), 52 deletions(-) delete mode 100644 x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/runtimefields/RuntimeFieldsFeatureSetUsage.java diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.stats/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.stats/10_basic.yml index 307cba6664c0e..0655fe809536a 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.stats/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.stats/10_basic.yml @@ -86,8 +86,8 @@ --- "get cluster stats without runtime fields": - skip: - version: " - 7.99.99" - reason: "cluster stats includes runtime fields from 8.0 on" + version: " - 7.12.99" + reason: "cluster stats includes runtime fields from 7.13 on" - do: indices.create: index: sensor @@ -99,8 +99,8 @@ --- "Usage stats with script-less runtime fields": - skip: - version: " - 7.99.99" - reason: "cluster stats includes runtime fields from 8.0 on" + version: " - 7.12.99" + reason: "cluster stats includes runtime fields from 7.13 on" - do: indices.create: index: sensor diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/stats/MappingStats.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/stats/MappingStats.java index b7ee0908139ef..c4371c4bb3a57 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/stats/MappingStats.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/stats/MappingStats.java @@ -8,7 +8,6 @@ package org.elasticsearch.action.admin.cluster.stats; -import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.metadata.MappingMetadata; import org.elasticsearch.cluster.metadata.Metadata; @@ -139,19 +138,13 @@ private static int countOccurrences(String script, String keyword) { MappingStats(StreamInput in) throws IOException { fieldTypeStats = Collections.unmodifiableSet(new LinkedHashSet<>(in.readList(IndexFeatureStats::new))); - if (in.getVersion().onOrAfter(Version.V_8_0_0)) { - runtimeFieldTypeStats = Collections.unmodifiableSet(new LinkedHashSet<>(in.readList(RuntimeFieldStats::new))); - } else { - runtimeFieldTypeStats = Collections.emptySet(); - } + runtimeFieldTypeStats = Collections.unmodifiableSet(new LinkedHashSet<>(in.readList(RuntimeFieldStats::new))); } @Override public void writeTo(StreamOutput out) throws IOException { out.writeCollection(fieldTypeStats); - if (out.getVersion().onOrAfter(Version.V_8_0_0)) { - out.writeCollection(runtimeFieldTypeStats); - } + out.writeCollection(runtimeFieldTypeStats); } /** diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackClientPlugin.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackClientPlugin.java index ff3ccb7db8cb2..9c2fe80fcee21 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackClientPlugin.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackClientPlugin.java @@ -158,7 +158,6 @@ import org.elasticsearch.xpack.core.rollup.action.StopRollupJobAction; import org.elasticsearch.xpack.core.rollup.job.RollupJob; import org.elasticsearch.xpack.core.rollup.job.RollupJobStatus; -import org.elasticsearch.xpack.core.runtimefields.RuntimeFieldsFeatureSetUsage; import org.elasticsearch.xpack.core.search.action.GetAsyncSearchAction; import org.elasticsearch.xpack.core.search.action.SubmitAsyncSearchAction; import org.elasticsearch.xpack.core.searchablesnapshots.SearchableSnapshotFeatureSetUsage; @@ -535,8 +534,7 @@ public List getNamedWriteables() { // Data Streams new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, XPackField.DATA_STREAMS, DataStreamFeatureSetUsage::new), // Data Tiers - new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, XPackField.DATA_TIERS, DataTiersFeatureSetUsage::new), - new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, "runtime_fields", RuntimeFieldsFeatureSetUsage::new) + new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, XPackField.DATA_TIERS, DataTiersFeatureSetUsage::new) )); if (RollupV2.isEnabled()) { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/runtimefields/RuntimeFieldsFeatureSetUsage.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/runtimefields/RuntimeFieldsFeatureSetUsage.java deleted file mode 100644 index 7ae0e944cb51f..0000000000000 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/runtimefields/RuntimeFieldsFeatureSetUsage.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -package org.elasticsearch.xpack.core.runtimefields; - -import org.elasticsearch.Version; -import org.elasticsearch.action.admin.cluster.stats.RuntimeFieldStats; -import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.xpack.core.XPackFeatureSet; - -import java.io.IOException; -import java.util.Collections; - -public class RuntimeFieldsFeatureSetUsage extends XPackFeatureSet.Usage { - - public RuntimeFieldsFeatureSetUsage(StreamInput input) throws IOException { - super(input); - input.readList(RuntimeFieldStats::new); - } - - @Override - public void writeTo(StreamOutput out) throws IOException { - super.writeTo(out); - out.writeList(Collections.emptyList()); - } - - @Override - public Version getMinimalSupportedVersion() { - return Version.V_7_11_0; - } -}