@@ -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 ();
0 commit comments