Skip to content

Commit b8cdec8

Browse files
authored
Revert "Index stats enhancement: creation date and tier_preference (#116339)"
This reverts commit e0af123.
1 parent 4d33849 commit b8cdec8

File tree

10 files changed

+7
-135
lines changed

10 files changed

+7
-135
lines changed

docs/changelog/116339.yaml

Lines changed: 0 additions & 5 deletions
This file was deleted.

rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/indices.stats/16_creation_date_tier_preference.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

server/src/main/java/module-info.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,6 @@
419419

420420
provides org.elasticsearch.features.FeatureSpecification
421421
with
422-
org.elasticsearch.action.admin.indices.stats.IndicesStatsFeatures,
423422
org.elasticsearch.action.bulk.BulkFeatures,
424423
org.elasticsearch.features.FeatureInfrastructureFeatures,
425424
org.elasticsearch.health.HealthFeatures,

server/src/main/java/org/elasticsearch/TransportVersions.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ static TransportVersion def(int id) {
199199
public static final TransportVersion VERTEX_AI_INPUT_TYPE_ADDED = def(8_790_00_0);
200200
public static final TransportVersion SKIP_INNER_HITS_SEARCH_SOURCE = def(8_791_00_0);
201201
public static final TransportVersion QUERY_RULES_LIST_INCLUDES_TYPES = def(8_792_00_0);
202-
public static final TransportVersion INDEX_STATS_ADDITIONAL_FIELDS = def(8_793_00_0);
203202

204203
/*
205204
* STOP! READ THIS FIRST! No, really,

server/src/main/java/org/elasticsearch/action/admin/indices/stats/IndexStats.java

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import org.elasticsearch.cluster.health.ClusterHealthStatus;
1313
import org.elasticsearch.cluster.metadata.IndexMetadata;
1414
import org.elasticsearch.core.Nullable;
15-
import org.elasticsearch.features.NodeFeature;
1615

1716
import java.util.ArrayList;
1817
import java.util.HashMap;
@@ -22,8 +21,6 @@
2221

2322
public class IndexStats implements Iterable<IndexShardStats> {
2423

25-
public static final NodeFeature TIER_CREATION_DATE = new NodeFeature("stats.tier_creation_date");
26-
2724
private final String index;
2825

2926
private final String uuid;
@@ -32,27 +29,19 @@ public class IndexStats implements Iterable<IndexShardStats> {
3229

3330
private final IndexMetadata.State state;
3431

35-
private final List<String> tierPreference;
36-
37-
private final Long creationDate;
38-
3932
private final ShardStats shards[];
4033

4134
public IndexStats(
4235
String index,
4336
String uuid,
4437
@Nullable ClusterHealthStatus health,
4538
@Nullable IndexMetadata.State state,
46-
@Nullable List<String> tierPreference,
47-
@Nullable Long creationDate,
4839
ShardStats[] shards
4940
) {
5041
this.index = index;
5142
this.uuid = uuid;
5243
this.health = health;
5344
this.state = state;
54-
this.tierPreference = tierPreference;
55-
this.creationDate = creationDate;
5645
this.shards = shards;
5746
}
5847

@@ -72,14 +61,6 @@ public IndexMetadata.State getState() {
7261
return state;
7362
}
7463

75-
public List<String> getTierPreference() {
76-
return tierPreference;
77-
}
78-
79-
public Long getCreationDate() {
80-
return creationDate;
81-
}
82-
8364
public ShardStats[] getShards() {
8465
return this.shards;
8566
}
@@ -148,24 +129,13 @@ public static class IndexStatsBuilder {
148129
private final String uuid;
149130
private final ClusterHealthStatus health;
150131
private final IndexMetadata.State state;
151-
private final List<String> tierPreference;
152-
private final Long creationDate;
153132
private final List<ShardStats> shards = new ArrayList<>();
154133

155-
public IndexStatsBuilder(
156-
String indexName,
157-
String uuid,
158-
@Nullable ClusterHealthStatus health,
159-
@Nullable IndexMetadata.State state,
160-
@Nullable List<String> tierPreference,
161-
@Nullable Long creationDate
162-
) {
134+
public IndexStatsBuilder(String indexName, String uuid, @Nullable ClusterHealthStatus health, @Nullable IndexMetadata.State state) {
163135
this.indexName = indexName;
164136
this.uuid = uuid;
165137
this.health = health;
166138
this.state = state;
167-
this.tierPreference = tierPreference;
168-
this.creationDate = creationDate;
169139
}
170140

171141
public IndexStatsBuilder add(ShardStats shardStats) {
@@ -174,15 +144,7 @@ public IndexStatsBuilder add(ShardStats shardStats) {
174144
}
175145

176146
public IndexStats build() {
177-
return new IndexStats(
178-
indexName,
179-
uuid,
180-
health,
181-
state,
182-
tierPreference,
183-
creationDate,
184-
shards.toArray(new ShardStats[shards.size()])
185-
);
147+
return new IndexStats(indexName, uuid, health, state, shards.toArray(new ShardStats[shards.size()]));
186148
}
187149
}
188150
}

server/src/main/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsFeatures.java

Lines changed: 0 additions & 23 deletions
This file was deleted.

server/src/main/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsResponse.java

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -47,34 +47,19 @@ public class IndicesStatsResponse extends ChunkedBroadcastResponse {
4747

4848
private final Map<String, IndexMetadata.State> indexStateMap;
4949

50-
private final Map<String, List<String>> indexTierPreferenceMap;
51-
52-
private final Map<String, Long> indexCreationDateMap;
53-
5450
private final ShardStats[] shards;
5551

5652
private Map<ShardRouting, ShardStats> shardStatsMap;
5753

5854
IndicesStatsResponse(StreamInput in) throws IOException {
5955
super(in);
6056
shards = in.readArray(ShardStats::new, ShardStats[]::new);
61-
if (in.getTransportVersion().onOrAfter(TransportVersions.INDEX_STATS_ADDITIONAL_FIELDS)) {
57+
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_1_0)) {
6258
indexHealthMap = in.readMap(ClusterHealthStatus::readFrom);
6359
indexStateMap = in.readMap(IndexMetadata.State::readFrom);
64-
indexTierPreferenceMap = in.readMap(StreamInput::readStringCollectionAsList);
65-
indexCreationDateMap = in.readMap(StreamInput::readLong);
66-
} else if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_1_0)) {
67-
// Between 8.1 and INDEX_STATS_ADDITIONAL_FIELDS, we had a different format for the response
68-
// where we only had health and state available.
69-
indexHealthMap = in.readMap(ClusterHealthStatus::readFrom);
70-
indexStateMap = in.readMap(IndexMetadata.State::readFrom);
71-
indexTierPreferenceMap = Map.of();
72-
indexCreationDateMap = Map.of();
7360
} else {
7461
indexHealthMap = Map.of();
7562
indexStateMap = Map.of();
76-
indexTierPreferenceMap = Map.of();
77-
indexCreationDateMap = Map.of();
7863
}
7964
}
8065

@@ -94,8 +79,6 @@ public class IndicesStatsResponse extends ChunkedBroadcastResponse {
9479
Objects.requireNonNull(shards);
9580
Map<String, ClusterHealthStatus> indexHealthModifiableMap = new HashMap<>();
9681
Map<String, IndexMetadata.State> indexStateModifiableMap = new HashMap<>();
97-
Map<String, List<String>> indexTierPreferenceModifiableMap = new HashMap<>();
98-
Map<String, Long> indexCreationDateModifiableMap = new HashMap<>();
9982
for (ShardStats shard : shards) {
10083
Index index = shard.getShardRouting().index();
10184
IndexMetadata indexMetadata = metadata.index(index);
@@ -105,14 +88,10 @@ public class IndicesStatsResponse extends ChunkedBroadcastResponse {
10588
ignored -> new ClusterIndexHealth(indexMetadata, routingTable.index(index)).getStatus()
10689
);
10790
indexStateModifiableMap.computeIfAbsent(index.getName(), ignored -> indexMetadata.getState());
108-
indexTierPreferenceModifiableMap.computeIfAbsent(index.getName(), ignored -> indexMetadata.getTierPreference());
109-
indexCreationDateModifiableMap.computeIfAbsent(index.getName(), ignored -> indexMetadata.getCreationDate());
11091
}
11192
}
11293
indexHealthMap = unmodifiableMap(indexHealthModifiableMap);
11394
indexStateMap = unmodifiableMap(indexStateModifiableMap);
114-
indexTierPreferenceMap = unmodifiableMap(indexTierPreferenceModifiableMap);
115-
indexCreationDateMap = unmodifiableMap(indexCreationDateModifiableMap);
11695
}
11796

11897
public Map<ShardRouting, ShardStats> asMap() {
@@ -150,14 +129,7 @@ public Map<String, IndexStats> getIndices() {
150129
Index index = shard.getShardRouting().index();
151130
IndexStatsBuilder indexStatsBuilder = indexToIndexStatsBuilder.computeIfAbsent(
152131
index.getName(),
153-
k -> new IndexStatsBuilder(
154-
k,
155-
index.getUUID(),
156-
indexHealthMap.get(index.getName()),
157-
indexStateMap.get(index.getName()),
158-
indexTierPreferenceMap.get(index.getName()),
159-
indexCreationDateMap.get(index.getName())
160-
)
132+
k -> new IndexStatsBuilder(k, index.getUUID(), indexHealthMap.get(index.getName()), indexStateMap.get(index.getName()))
161133
);
162134
indexStatsBuilder.add(shard);
163135
}
@@ -202,13 +174,7 @@ public CommonStats getPrimaries() {
202174
public void writeTo(StreamOutput out) throws IOException {
203175
super.writeTo(out);
204176
out.writeArray(shards);
205-
if (out.getTransportVersion().onOrAfter(TransportVersions.INDEX_STATS_ADDITIONAL_FIELDS)) {
206-
out.writeMap(indexHealthMap, StreamOutput::writeWriteable);
207-
out.writeMap(indexStateMap, StreamOutput::writeWriteable);
208-
out.writeMap(indexTierPreferenceMap, StreamOutput::writeStringCollection);
209-
out.writeMap(indexCreationDateMap, StreamOutput::writeLong);
210-
211-
} else if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_1_0)) {
177+
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_1_0)) {
212178
out.writeMap(indexHealthMap, StreamOutput::writeWriteable);
213179
out.writeMap(indexStateMap, StreamOutput::writeWriteable);
214180
}
@@ -237,12 +203,6 @@ protected Iterator<ToXContent> customXContentChunks(ToXContent.Params params) {
237203
if (indexStats.getState() != null) {
238204
builder.field("status", indexStats.getState().toString().toLowerCase(Locale.ROOT));
239205
}
240-
if (indexStats.getTierPreference() != null) {
241-
builder.field("tier_preference", indexStats.getTierPreference());
242-
}
243-
if (indexStats.getCreationDate() != null) {
244-
builder.field("creation_date", indexStats.getCreationDate());
245-
}
246206
builder.startObject("primaries");
247207
indexStats.getPrimaries().toXContent(builder, p);
248208
builder.endObject();

server/src/main/resources/META-INF/services/org.elasticsearch.features.FeatureSpecification

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
# License v3.0 only", or the "Server Side Public License, v 1".
88
#
99

10-
org.elasticsearch.action.admin.indices.stats.IndicesStatsFeatures
1110
org.elasticsearch.action.bulk.BulkFeatures
1211
org.elasticsearch.features.FeatureInfrastructureFeatures
1312
org.elasticsearch.health.HealthFeatures

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/WaitForNoFollowersStepTests.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,7 @@ public void testNoShardStats() {
189189
shardStats[0] = sStats;
190190

191191
mockXPackInfo(true, true);
192-
mockIndexStatsCall(
193-
indexName,
194-
new IndexStats(indexName, "uuid", ClusterHealthStatus.GREEN, IndexMetadata.State.OPEN, null, null, shardStats)
195-
);
192+
mockIndexStatsCall(indexName, new IndexStats(indexName, "uuid", ClusterHealthStatus.GREEN, IndexMetadata.State.OPEN, shardStats));
196193

197194
final SetOnce<Boolean> conditionMetHolder = new SetOnce<>();
198195
final SetOnce<ToXContentObject> stepInfoHolder = new SetOnce<>();
@@ -292,7 +289,7 @@ private IndexStats randomIndexStats(boolean isLeaderIndex, int numOfShards) {
292289
for (int i = 0; i < numOfShards; i++) {
293290
shardStats[i] = randomShardStats(isLeaderIndex);
294291
}
295-
return new IndexStats(randomAlphaOfLength(5), randomAlphaOfLength(10), null, null, null, null, shardStats);
292+
return new IndexStats(randomAlphaOfLength(5), randomAlphaOfLength(10), null, null, shardStats);
296293
}
297294

298295
private ShardStats randomShardStats(boolean isLeaderIndex) {

x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/indices/IndicesStatsMonitoringDocTests.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ public void setUp() throws Exception {
5353
"dcvO5uZATE-EhIKc3tk9Bg",
5454
null,
5555
null,
56-
null,
57-
null,
5856
new ShardStats[] {
5957
// Primaries
6058
new ShardStats(mockShardRouting(true), mockShardPath(), mockCommonStats(), null, null, null, false, 0),

0 commit comments

Comments
 (0)