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 61186a17384..138f8cac48d 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 @@ -58,7 +58,6 @@ import org.elasticsearch.xpack.core.dataframe.transforms.SyncConfig; import org.elasticsearch.xpack.core.dataframe.transforms.TimeSyncConfig; import org.elasticsearch.xpack.core.deprecation.DeprecationInfoAction; import org.elasticsearch.xpack.core.flattened.FlattenedFeatureSetUsage; -import org.elasticsearch.xpack.core.frozen.FrozenIndicesFeatureSetUsage; import org.elasticsearch.xpack.core.graph.GraphFeatureSetUsage; import org.elasticsearch.xpack.core.graph.action.GraphExploreAction; import org.elasticsearch.xpack.core.indexlifecycle.AllocateAction; @@ -522,9 +521,7 @@ public class XPackClientPlugin extends Plugin implements ActionPlugin, NetworkPl // Vectors new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, XPackField.VECTORS, VectorsFeatureSetUsage::new), // Voting Only Node - new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, XPackField.VOTING_ONLY, VotingOnlyNodeFeatureSetUsage::new), - // Frozen indices - new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, XPackField.FROZEN_INDICES, FrozenIndicesFeatureSetUsage::new) + new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, XPackField.VOTING_ONLY, VotingOnlyNodeFeatureSetUsage::new) ); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackField.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackField.java index b3f6f2fbd36..351606e3218 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackField.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackField.java @@ -43,8 +43,6 @@ public final class XPackField { public static final String VECTORS = "vectors"; /** Name constant for the voting-only-node feature. */ public static final String VOTING_ONLY = "voting_only"; - /** Name constant for the frozen index feature. */ - public static final String FROZEN_INDICES = "frozen_indices"; private XPackField() {} diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackPlugin.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackPlugin.java index 7ef0c0351ec..525ddc949cd 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackPlugin.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackPlugin.java @@ -10,9 +10,9 @@ import org.apache.logging.log4j.Logger; import org.apache.lucene.util.SetOnce; import org.elasticsearch.SpecialPermission; import org.elasticsearch.Version; +import org.elasticsearch.action.ActionType; import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionResponse; -import org.elasticsearch.action.ActionType; import org.elasticsearch.action.support.ActionFilter; import org.elasticsearch.client.Client; import org.elasticsearch.client.transport.TransportClient; @@ -63,7 +63,6 @@ import org.elasticsearch.xpack.core.action.TransportXPackInfoAction; import org.elasticsearch.xpack.core.action.TransportXPackUsageAction; import org.elasticsearch.xpack.core.action.XPackInfoAction; import org.elasticsearch.xpack.core.action.XPackUsageAction; -import org.elasticsearch.xpack.core.frozen.FrozenIndicesFeatureSet; import org.elasticsearch.xpack.core.ml.MlMetadata; import org.elasticsearch.xpack.core.rest.action.RestFreezeIndexAction; import org.elasticsearch.xpack.core.rest.action.RestReloadAnalyzersAction; @@ -243,7 +242,6 @@ public class XPackPlugin extends XPackClientPlugin implements ExtensiblePlugin, if (transportClientMode) { modules.add(b -> b.bind(XPackLicenseState.class).toProvider(Providers.of(null))); - modules.add(b -> bindFeatureSet(b, FrozenIndicesFeatureSet.class)); } return modules; } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/frozen/FrozenIndicesFeatureSet.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/frozen/FrozenIndicesFeatureSet.java deleted file mode 100644 index a1ae0da4d2a..00000000000 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/frozen/FrozenIndicesFeatureSet.java +++ /dev/null @@ -1,57 +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; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.xpack.core.frozen; - -import org.elasticsearch.action.ActionListener; -import org.elasticsearch.cluster.metadata.IndexMetaData; -import org.elasticsearch.cluster.service.ClusterService; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.index.engine.FrozenEngine; -import org.elasticsearch.xpack.core.XPackFeatureSet; -import org.elasticsearch.xpack.core.XPackField; - -import java.util.Map; - -public class FrozenIndicesFeatureSet implements XPackFeatureSet { - - private final ClusterService clusterService; - - @Inject - public FrozenIndicesFeatureSet(ClusterService clusterService) { - this.clusterService = clusterService; - } - - @Override - public String name() { - return XPackField.FROZEN_INDICES; - } - - @Override - public boolean available() { - return true; - } - - @Override - public boolean enabled() { - return true; - } - - @Override - public Map nativeCodeInfo() { - return null; - } - - @Override - public void usage(ActionListener listener) { - int numFrozenIndices = 0; - for (IndexMetaData indexMetaData : clusterService.state().metaData()) { - if (FrozenEngine.INDEX_FROZEN.get(indexMetaData.getSettings())) { - numFrozenIndices++; - } - } - listener.onResponse(new FrozenIndicesFeatureSetUsage(true, true, numFrozenIndices)); - } -} diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/frozen/FrozenIndicesFeatureSetUsage.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/frozen/FrozenIndicesFeatureSetUsage.java deleted file mode 100644 index cc556330497..00000000000 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/frozen/FrozenIndicesFeatureSetUsage.java +++ /dev/null @@ -1,65 +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; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.xpack.core.frozen; - -import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.xpack.core.XPackFeatureSet; -import org.elasticsearch.xpack.core.XPackField; - -import java.io.IOException; -import java.util.Objects; - -public class FrozenIndicesFeatureSetUsage extends XPackFeatureSet.Usage { - - private final int numberOfFrozenIndices; - - public FrozenIndicesFeatureSetUsage(StreamInput input) throws IOException { - super(input); - numberOfFrozenIndices = input.readVInt(); - } - - @Override - public void writeTo(StreamOutput out) throws IOException { - super.writeTo(out); - out.writeVInt(numberOfFrozenIndices); - } - - public FrozenIndicesFeatureSetUsage(boolean available, boolean enabled, int numberOfFrozenIndices) { - super(XPackField.FROZEN_INDICES, available, enabled); - this.numberOfFrozenIndices = numberOfFrozenIndices; - } - - @Override - protected void innerXContent(XContentBuilder builder, Params params) throws IOException { - super.innerXContent(builder, params); - builder.field("indices_count", numberOfFrozenIndices); - } - - public int getNumberOfFrozenIndices() { - return numberOfFrozenIndices; - } - - @Override - public int hashCode() { - return Objects.hash(available, enabled, numberOfFrozenIndices); - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - FrozenIndicesFeatureSetUsage other = (FrozenIndicesFeatureSetUsage) obj; - return Objects.equals(available, other.available) && - Objects.equals(enabled, other.enabled) && - Objects.equals(numberOfFrozenIndices, other.numberOfFrozenIndices); - } -} diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/frozen/FrozenIndicesFeatureSetUsageTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/frozen/FrozenIndicesFeatureSetUsageTests.java deleted file mode 100644 index 34f7757fa2f..00000000000 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/frozen/FrozenIndicesFeatureSetUsageTests.java +++ /dev/null @@ -1,48 +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; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.xpack.core.frozen; - -import org.elasticsearch.common.io.stream.Writeable; -import org.elasticsearch.test.AbstractWireSerializingTestCase; - -import java.io.IOException; - -public class FrozenIndicesFeatureSetUsageTests extends AbstractWireSerializingTestCase { - - @Override - protected FrozenIndicesFeatureSetUsage createTestInstance() { - boolean available = randomBoolean(); - boolean enabled = randomBoolean(); - return new FrozenIndicesFeatureSetUsage(available, enabled, randomIntBetween(0, 100000)); - } - - @Override - protected FrozenIndicesFeatureSetUsage mutateInstance(FrozenIndicesFeatureSetUsage instance) throws IOException { - boolean available = instance.available(); - boolean enabled = instance.enabled(); - int numFrozenIndices = instance.getNumberOfFrozenIndices(); - switch (between(0, 2)) { - case 0: - available = available == false; - break; - case 1: - enabled = enabled == false; - break; - case 2: - numFrozenIndices = randomValueOtherThan(numFrozenIndices, () -> randomIntBetween(0, 100000)); - break; - default: - throw new AssertionError("Illegal randomisation branch"); - } - return new FrozenIndicesFeatureSetUsage(available, enabled, numFrozenIndices); - } - - @Override - protected Writeable.Reader instanceReader() { - return FrozenIndicesFeatureSetUsage::new; - } - -} diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/indices.freeze/20_stats.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/indices.freeze/20_stats.yml index e73c7793022..8c6cb329d0b 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/indices.freeze/20_stats.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/indices.freeze/20_stats.yml @@ -52,7 +52,7 @@ setup: # unfreeze index - do: - indices.unfreeze: + indices.freeze: index: test wait_for_active_shards: 1 - is_true: acknowledged diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/indices.freeze/30_usage.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/indices.freeze/30_usage.yml deleted file mode 100644 index 9135c19f679..00000000000 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/indices.freeze/30_usage.yml +++ /dev/null @@ -1,60 +0,0 @@ ---- -setup: - - do: - indices.create: - index: test - - do: - cluster.health: - wait_for_no_initializing_shards: true - ---- -"Usage stats on frozen indices": - - skip: - version: " - 7.9.99" - reason: "frozen indices have usage stats starting in version 8.0.0" - - - do: - index: - index: test - id: 1 - body: { "foo": "bar" } - - - do: - index: - index: test - id: 2 - body: { "foo": "bar" } - - - do: - index: - index: test - id: 3 - body: { "foo": "bar" } - - - do: {xpack.usage: {}} - - match: { frozen_indices.available: true } - - match: { frozen_indices.enabled: true } - - match: { frozen_indices.indices_count: 0 } - - # freeze index - - do: - indices.freeze: - index: test - - is_true: acknowledged - - - - do: {xpack.usage: {}} - - match: { frozen_indices.available: true } - - match: { frozen_indices.enabled: true } - - match: { frozen_indices.indices_count: 1 } - - # unfreeze index - - do: - indices.unfreeze: - index: test - - is_true: acknowledged - - - do: {xpack.usage: {}} - - match: { frozen_indices.available: true } - - match: { frozen_indices.enabled: true } - - match: { frozen_indices.indices_count: 0 }