-
Notifications
You must be signed in to change notification settings - Fork 25.9k
Revert "Index stats enhancement: creation date and tier_preference (#116339)" #116959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
DaveCTurner
merged 2 commits into
elastic:main
from
DaveCTurner:2024/11/18/revert-116339
Nov 18, 2024
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
...lRestTest/resources/rest-api-spec/test/indices.stats/16_creation_date_tier_preference.yml
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,34 +47,29 @@ public class IndicesStatsResponse extends ChunkedBroadcastResponse { | |
|
|
||
| private final Map<String, IndexMetadata.State> indexStateMap; | ||
|
|
||
| private final Map<String, List<String>> indexTierPreferenceMap; | ||
|
|
||
| private final Map<String, Long> indexCreationDateMap; | ||
|
|
||
| private final ShardStats[] shards; | ||
|
|
||
| private Map<ShardRouting, ShardStats> shardStatsMap; | ||
|
|
||
| IndicesStatsResponse(StreamInput in) throws IOException { | ||
| super(in); | ||
| shards = in.readArray(ShardStats::new, ShardStats[]::new); | ||
| if (in.getTransportVersion().onOrAfter(TransportVersions.INDEX_STATS_ADDITIONAL_FIELDS)) { | ||
| if (in.getTransportVersion().onOrAfter(TransportVersions.INDEX_STATS_ADDITIONAL_FIELDS_REVERT)) { | ||
| indexHealthMap = in.readMap(ClusterHealthStatus::readFrom); | ||
| indexStateMap = in.readMap(IndexMetadata.State::readFrom); | ||
| indexTierPreferenceMap = in.readMap(StreamInput::readStringCollectionAsList); | ||
| indexCreationDateMap = in.readMap(StreamInput::readLong); | ||
| } else if (in.getTransportVersion().onOrAfter(TransportVersions.INDEX_STATS_ADDITIONAL_FIELDS)) { | ||
| indexHealthMap = in.readMap(ClusterHealthStatus::readFrom); | ||
| indexStateMap = in.readMap(IndexMetadata.State::readFrom); | ||
| in.readMap(StreamInput::readStringCollectionAsList); // unused, reverted | ||
| in.readMap(StreamInput::readLong); // unused, reverted | ||
| } else if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_1_0)) { | ||
| // Between 8.1 and INDEX_STATS_ADDITIONAL_FIELDS, we had a different format for the response | ||
| // where we only had health and state available. | ||
| indexHealthMap = in.readMap(ClusterHealthStatus::readFrom); | ||
| indexStateMap = in.readMap(IndexMetadata.State::readFrom); | ||
| indexTierPreferenceMap = Map.of(); | ||
| indexCreationDateMap = Map.of(); | ||
| } else { | ||
| indexHealthMap = Map.of(); | ||
| indexStateMap = Map.of(); | ||
| indexTierPreferenceMap = Map.of(); | ||
| indexCreationDateMap = Map.of(); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -94,8 +89,6 @@ public class IndicesStatsResponse extends ChunkedBroadcastResponse { | |
| Objects.requireNonNull(shards); | ||
| Map<String, ClusterHealthStatus> indexHealthModifiableMap = new HashMap<>(); | ||
| Map<String, IndexMetadata.State> indexStateModifiableMap = new HashMap<>(); | ||
| Map<String, List<String>> indexTierPreferenceModifiableMap = new HashMap<>(); | ||
| Map<String, Long> indexCreationDateModifiableMap = new HashMap<>(); | ||
| for (ShardStats shard : shards) { | ||
| Index index = shard.getShardRouting().index(); | ||
| IndexMetadata indexMetadata = metadata.index(index); | ||
|
|
@@ -105,14 +98,10 @@ public class IndicesStatsResponse extends ChunkedBroadcastResponse { | |
| ignored -> new ClusterIndexHealth(indexMetadata, routingTable.index(index)).getStatus() | ||
| ); | ||
| indexStateModifiableMap.computeIfAbsent(index.getName(), ignored -> indexMetadata.getState()); | ||
| indexTierPreferenceModifiableMap.computeIfAbsent(index.getName(), ignored -> indexMetadata.getTierPreference()); | ||
| indexCreationDateModifiableMap.computeIfAbsent(index.getName(), ignored -> indexMetadata.getCreationDate()); | ||
| } | ||
| } | ||
| indexHealthMap = unmodifiableMap(indexHealthModifiableMap); | ||
| indexStateMap = unmodifiableMap(indexStateModifiableMap); | ||
| indexTierPreferenceMap = unmodifiableMap(indexTierPreferenceModifiableMap); | ||
| indexCreationDateMap = unmodifiableMap(indexCreationDateModifiableMap); | ||
| } | ||
|
|
||
| public Map<ShardRouting, ShardStats> asMap() { | ||
|
|
@@ -150,14 +139,7 @@ public Map<String, IndexStats> getIndices() { | |
| Index index = shard.getShardRouting().index(); | ||
| IndexStatsBuilder indexStatsBuilder = indexToIndexStatsBuilder.computeIfAbsent( | ||
| index.getName(), | ||
| k -> new IndexStatsBuilder( | ||
| k, | ||
| index.getUUID(), | ||
| indexHealthMap.get(index.getName()), | ||
| indexStateMap.get(index.getName()), | ||
| indexTierPreferenceMap.get(index.getName()), | ||
| indexCreationDateMap.get(index.getName()) | ||
| ) | ||
| k -> new IndexStatsBuilder(k, index.getUUID(), indexHealthMap.get(index.getName()), indexStateMap.get(index.getName())) | ||
| ); | ||
| indexStatsBuilder.add(shard); | ||
| } | ||
|
|
@@ -202,12 +184,14 @@ public CommonStats getPrimaries() { | |
| public void writeTo(StreamOutput out) throws IOException { | ||
| super.writeTo(out); | ||
| out.writeArray(shards); | ||
| if (out.getTransportVersion().onOrAfter(TransportVersions.INDEX_STATS_ADDITIONAL_FIELDS)) { | ||
| if (out.getTransportVersion().onOrAfter(TransportVersions.INDEX_STATS_ADDITIONAL_FIELDS_REVERT)) { | ||
| out.writeMap(indexHealthMap, StreamOutput::writeWriteable); | ||
| out.writeMap(indexStateMap, StreamOutput::writeWriteable); | ||
| out.writeMap(indexTierPreferenceMap, StreamOutput::writeStringCollection); | ||
| out.writeMap(indexCreationDateMap, StreamOutput::writeLong); | ||
|
|
||
| } else if (out.getTransportVersion().onOrAfter(TransportVersions.INDEX_STATS_ADDITIONAL_FIELDS)) { | ||
| out.writeMap(indexHealthMap, StreamOutput::writeWriteable); | ||
| out.writeMap(indexStateMap, StreamOutput::writeWriteable); | ||
| out.writeMap(Map.of(), StreamOutput::writeStringCollection); | ||
| out.writeMap(Map.of(), StreamOutput::writeLong); | ||
| } else if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_1_0)) { | ||
| out.writeMap(indexHealthMap, StreamOutput::writeWriteable); | ||
| out.writeMap(indexStateMap, StreamOutput::writeWriteable); | ||
|
|
@@ -237,12 +221,6 @@ protected Iterator<ToXContent> customXContentChunks(ToXContent.Params params) { | |
| if (indexStats.getState() != null) { | ||
| builder.field("status", indexStats.getState().toString().toLowerCase(Locale.ROOT)); | ||
| } | ||
| if (indexStats.getTierPreference() != null) { | ||
| builder.field("tier_preference", indexStats.getTierPreference()); | ||
| } | ||
| if (indexStats.getCreationDate() != null) { | ||
| builder.field("creation_date", indexStats.getCreationDate()); | ||
| } | ||
|
Comment on lines
-240
to
-245
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this is ok, I don't think any clients could have been expecting these fields yet and they were optional anyway so we can remove them without ceremony. |
||
| builder.startObject("primaries"); | ||
| indexStats.getPrimaries().toXContent(builder, p); | ||
| builder.endObject(); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add some kind of check to be able to eventually remove these?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah eventually all these transport versions get collapsed into a release-version-named one (see e.g.
org.elasticsearch.TransportVersions#V_8_15_2) and then this branch will be dead code: