Revert "Add usage stats for frozen indices (#44286)"

This reverts commit 5e73c49ec8.
This commit is contained in:
Yannick Welsch 2019-07-15 21:41:25 +02:00
parent 7b68bfb4e6
commit a848fc9bf4
8 changed files with 3 additions and 240 deletions

View File

@ -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)
);
}

View File

@ -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() {}

View File

@ -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;
}

View File

@ -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<String, Object> nativeCodeInfo() {
return null;
}
@Override
public void usage(ActionListener<Usage> 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));
}
}

View File

@ -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);
}
}

View File

@ -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<FrozenIndicesFeatureSetUsage> {
@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<FrozenIndicesFeatureSetUsage> instanceReader() {
return FrozenIndicesFeatureSetUsage::new;
}
}

View File

@ -52,7 +52,7 @@ setup:
# unfreeze index
- do:
indices.unfreeze:
indices.freeze:
index: test
wait_for_active_shards: 1
- is_true: acknowledged

View File

@ -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 }