Skip to content

Commit c72d5fd

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

File tree

8 files changed

+21
-100
lines changed

8 files changed

+21
-100
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/org/elasticsearch/TransportVersions.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ static TransportVersion def(int id) {
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);
202202
public static final TransportVersion INDEX_STATS_ADDITIONAL_FIELDS = def(8_793_00_0);
203+
public static final TransportVersion INDEX_STATS_ADDITIONAL_FIELDS_REVERT = def(8_794_00_0);
203204

204205
/*
205206
* STOP! READ THIS FIRST! No, really,

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

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222

2323
public class IndexStats implements Iterable<IndexShardStats> {
2424

25-
public static final NodeFeature TIER_CREATION_DATE = new NodeFeature("stats.tier_creation_date");
25+
// feature was effectively reverted but we still need to keep this constant around
26+
public static final NodeFeature REVERTED_TIER_CREATION_DATE = new NodeFeature("stats.tier_creation_date");
2627

2728
private final String index;
2829

@@ -32,27 +33,19 @@ public class IndexStats implements Iterable<IndexShardStats> {
3233

3334
private final IndexMetadata.State state;
3435

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

4138
public IndexStats(
4239
String index,
4340
String uuid,
4441
@Nullable ClusterHealthStatus health,
4542
@Nullable IndexMetadata.State state,
46-
@Nullable List<String> tierPreference,
47-
@Nullable Long creationDate,
4843
ShardStats[] shards
4944
) {
5045
this.index = index;
5146
this.uuid = uuid;
5247
this.health = health;
5348
this.state = state;
54-
this.tierPreference = tierPreference;
55-
this.creationDate = creationDate;
5649
this.shards = shards;
5750
}
5851

@@ -72,14 +65,6 @@ public IndexMetadata.State getState() {
7265
return state;
7366
}
7467

75-
public List<String> getTierPreference() {
76-
return tierPreference;
77-
}
78-
79-
public Long getCreationDate() {
80-
return creationDate;
81-
}
82-
8368
public ShardStats[] getShards() {
8469
return this.shards;
8570
}
@@ -148,24 +133,13 @@ public static class IndexStatsBuilder {
148133
private final String uuid;
149134
private final ClusterHealthStatus health;
150135
private final IndexMetadata.State state;
151-
private final List<String> tierPreference;
152-
private final Long creationDate;
153136
private final List<ShardStats> shards = new ArrayList<>();
154137

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-
) {
138+
public IndexStatsBuilder(String indexName, String uuid, @Nullable ClusterHealthStatus health, @Nullable IndexMetadata.State state) {
163139
this.indexName = indexName;
164140
this.uuid = uuid;
165141
this.health = health;
166142
this.state = state;
167-
this.tierPreference = tierPreference;
168-
this.creationDate = creationDate;
169143
}
170144

171145
public IndexStatsBuilder add(ShardStats shardStats) {
@@ -174,15 +148,7 @@ public IndexStatsBuilder add(ShardStats shardStats) {
174148
}
175149

176150
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-
);
151+
return new IndexStats(indexName, uuid, health, state, shards.toArray(new ShardStats[shards.size()]));
186152
}
187153
}
188154
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ public class IndicesStatsFeatures implements FeatureSpecification {
1818

1919
@Override
2020
public Set<NodeFeature> getFeatures() {
21-
return Set.of(IndexStats.TIER_CREATION_DATE);
21+
return Set.of(IndexStats.REVERTED_TIER_CREATION_DATE);
2222
}
2323
}

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

Lines changed: 13 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -47,34 +47,29 @@ 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.INDEX_STATS_ADDITIONAL_FIELDS_REVERT)) {
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);
60+
} else if (in.getTransportVersion().onOrAfter(TransportVersions.INDEX_STATS_ADDITIONAL_FIELDS)) {
61+
indexHealthMap = in.readMap(ClusterHealthStatus::readFrom);
62+
indexStateMap = in.readMap(IndexMetadata.State::readFrom);
63+
in.readMap(StreamInput::readStringCollectionAsList); // unused, reverted
64+
in.readMap(StreamInput::readLong); // unused, reverted
6665
} else if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_1_0)) {
6766
// Between 8.1 and INDEX_STATS_ADDITIONAL_FIELDS, we had a different format for the response
6867
// where we only had health and state available.
6968
indexHealthMap = in.readMap(ClusterHealthStatus::readFrom);
7069
indexStateMap = in.readMap(IndexMetadata.State::readFrom);
71-
indexTierPreferenceMap = Map.of();
72-
indexCreationDateMap = Map.of();
7370
} else {
7471
indexHealthMap = Map.of();
7572
indexStateMap = Map.of();
76-
indexTierPreferenceMap = Map.of();
77-
indexCreationDateMap = Map.of();
7873
}
7974
}
8075

@@ -94,8 +89,6 @@ public class IndicesStatsResponse extends ChunkedBroadcastResponse {
9489
Objects.requireNonNull(shards);
9590
Map<String, ClusterHealthStatus> indexHealthModifiableMap = new HashMap<>();
9691
Map<String, IndexMetadata.State> indexStateModifiableMap = new HashMap<>();
97-
Map<String, List<String>> indexTierPreferenceModifiableMap = new HashMap<>();
98-
Map<String, Long> indexCreationDateModifiableMap = new HashMap<>();
9992
for (ShardStats shard : shards) {
10093
Index index = shard.getShardRouting().index();
10194
IndexMetadata indexMetadata = metadata.index(index);
@@ -105,14 +98,10 @@ public class IndicesStatsResponse extends ChunkedBroadcastResponse {
10598
ignored -> new ClusterIndexHealth(indexMetadata, routingTable.index(index)).getStatus()
10699
);
107100
indexStateModifiableMap.computeIfAbsent(index.getName(), ignored -> indexMetadata.getState());
108-
indexTierPreferenceModifiableMap.computeIfAbsent(index.getName(), ignored -> indexMetadata.getTierPreference());
109-
indexCreationDateModifiableMap.computeIfAbsent(index.getName(), ignored -> indexMetadata.getCreationDate());
110101
}
111102
}
112103
indexHealthMap = unmodifiableMap(indexHealthModifiableMap);
113104
indexStateMap = unmodifiableMap(indexStateModifiableMap);
114-
indexTierPreferenceMap = unmodifiableMap(indexTierPreferenceModifiableMap);
115-
indexCreationDateMap = unmodifiableMap(indexCreationDateModifiableMap);
116105
}
117106

118107
public Map<ShardRouting, ShardStats> asMap() {
@@ -150,14 +139,7 @@ public Map<String, IndexStats> getIndices() {
150139
Index index = shard.getShardRouting().index();
151140
IndexStatsBuilder indexStatsBuilder = indexToIndexStatsBuilder.computeIfAbsent(
152141
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-
)
142+
k -> new IndexStatsBuilder(k, index.getUUID(), indexHealthMap.get(index.getName()), indexStateMap.get(index.getName()))
161143
);
162144
indexStatsBuilder.add(shard);
163145
}
@@ -202,12 +184,14 @@ public CommonStats getPrimaries() {
202184
public void writeTo(StreamOutput out) throws IOException {
203185
super.writeTo(out);
204186
out.writeArray(shards);
205-
if (out.getTransportVersion().onOrAfter(TransportVersions.INDEX_STATS_ADDITIONAL_FIELDS)) {
187+
if (out.getTransportVersion().onOrAfter(TransportVersions.INDEX_STATS_ADDITIONAL_FIELDS_REVERT)) {
206188
out.writeMap(indexHealthMap, StreamOutput::writeWriteable);
207189
out.writeMap(indexStateMap, StreamOutput::writeWriteable);
208-
out.writeMap(indexTierPreferenceMap, StreamOutput::writeStringCollection);
209-
out.writeMap(indexCreationDateMap, StreamOutput::writeLong);
210-
190+
} else if (out.getTransportVersion().onOrAfter(TransportVersions.INDEX_STATS_ADDITIONAL_FIELDS)) {
191+
out.writeMap(indexHealthMap, StreamOutput::writeWriteable);
192+
out.writeMap(indexStateMap, StreamOutput::writeWriteable);
193+
out.writeMap(Map.of(), StreamOutput::writeStringCollection);
194+
out.writeMap(Map.of(), StreamOutput::writeLong);
211195
} else if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_1_0)) {
212196
out.writeMap(indexHealthMap, StreamOutput::writeWriteable);
213197
out.writeMap(indexStateMap, StreamOutput::writeWriteable);
@@ -237,12 +221,6 @@ protected Iterator<ToXContent> customXContentChunks(ToXContent.Params params) {
237221
if (indexStats.getState() != null) {
238222
builder.field("status", indexStats.getState().toString().toLowerCase(Locale.ROOT));
239223
}
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-
}
246224
builder.startObject("primaries");
247225
indexStats.getPrimaries().toXContent(builder, p);
248226
builder.endObject();

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)