Skip to content

Commit 3762635

Browse files
authored
Remove some uses of V_8_0_0 constant from server (#135738)
Since main (9.2) is only compatible back to 8.19 nodes, serialization logic checking for pre 8.19 isnot necessary. This commit removes some of that logic for the 8.0.0 constant from server.
1 parent c58a727 commit 3762635

19 files changed

+21
-218
lines changed

server/src/main/java/org/elasticsearch/action/DocWriteResponse.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
*/
99
package org.elasticsearch.action;
1010

11-
import org.elasticsearch.TransportVersions;
1211
import org.elasticsearch.action.bulk.IndexDocFailureStoreStatus;
1312
import org.elasticsearch.action.support.WriteRequest;
1413
import org.elasticsearch.action.support.WriteRequest.RefreshPolicy;
@@ -115,10 +114,6 @@ public DocWriteResponse(ShardId shardId, String id, long seqNo, long primaryTerm
115114
protected DocWriteResponse(ShardId shardId, StreamInput in) throws IOException {
116115
super(in);
117116
this.shardId = shardId;
118-
if (in.getTransportVersion().before(TransportVersions.V_8_0_0)) {
119-
String type = in.readString();
120-
assert MapperService.SINGLE_MAPPING_NAME.equals(type) : "Expected [_doc] but received [" + type + "]";
121-
}
122117
id = in.readString();
123118
version = in.readZLong();
124119
seqNo = in.readZLong();
@@ -134,10 +129,6 @@ protected DocWriteResponse(ShardId shardId, StreamInput in) throws IOException {
134129
protected DocWriteResponse(StreamInput in) throws IOException {
135130
super(in);
136131
shardId = new ShardId(in);
137-
if (in.getTransportVersion().before(TransportVersions.V_8_0_0)) {
138-
String type = in.readString();
139-
assert MapperService.SINGLE_MAPPING_NAME.equals(type) : "Expected [_doc] but received [" + type + "]";
140-
}
141132
id = in.readString();
142133
version = in.readZLong();
143134
seqNo = in.readZLong();
@@ -266,9 +257,6 @@ public void writeTo(StreamOutput out) throws IOException {
266257
}
267258

268259
private void writeWithoutShardId(StreamOutput out) throws IOException {
269-
if (out.getTransportVersion().before(TransportVersions.V_8_0_0)) {
270-
out.writeString(MapperService.SINGLE_MAPPING_NAME);
271-
}
272260
out.writeString(id);
273261
out.writeZLong(version);
274262
out.writeZLong(seqNo);

server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/AddVotingConfigExclusionsRequest.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
*/
99
package org.elasticsearch.action.admin.cluster.configuration;
1010

11-
import org.elasticsearch.TransportVersions;
1211
import org.elasticsearch.action.ActionRequestValidationException;
1312
import org.elasticsearch.action.support.master.MasterNodeRequest;
1413
import org.elasticsearch.cluster.ClusterState;
@@ -78,12 +77,6 @@ public AddVotingConfigExclusionsRequest(TimeValue masterNodeTimeout, String[] no
7877

7978
public AddVotingConfigExclusionsRequest(StreamInput in) throws IOException {
8079
super(in);
81-
if (in.getTransportVersion().before(TransportVersions.V_8_0_0)) {
82-
final String[] legacyNodeDescriptions = in.readStringArray();
83-
if (legacyNodeDescriptions.length > 0) {
84-
throw new IllegalArgumentException("legacy [node_name] field was deprecated and must be empty");
85-
}
86-
}
8780
nodeIds = in.readStringArray();
8881
nodeNames = in.readStringArray();
8982
timeout = in.readTimeValue();
@@ -191,9 +184,6 @@ public ActionRequestValidationException validate() {
191184
@Override
192185
public void writeTo(StreamOutput out) throws IOException {
193186
super.writeTo(out);
194-
if (out.getTransportVersion().before(TransportVersions.V_8_0_0)) {
195-
out.writeStringArray(Strings.EMPTY_ARRAY);
196-
}
197187
out.writeStringArray(nodeIds);
198188
out.writeStringArray(nodeNames);
199189
out.writeTimeValue(timeout);

server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/create/CreateSnapshotRequest.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
package org.elasticsearch.action.admin.cluster.snapshots.create;
1111

1212
import org.elasticsearch.ElasticsearchException;
13-
import org.elasticsearch.TransportVersion;
1413
import org.elasticsearch.TransportVersions;
1514
import org.elasticsearch.action.ActionRequestValidationException;
1615
import org.elasticsearch.action.IndicesRequest;
@@ -21,7 +20,6 @@
2120
import org.elasticsearch.common.bytes.BytesReference;
2221
import org.elasticsearch.common.io.stream.StreamInput;
2322
import org.elasticsearch.common.io.stream.StreamOutput;
24-
import org.elasticsearch.common.settings.Settings;
2523
import org.elasticsearch.core.Nullable;
2624
import org.elasticsearch.core.TimeValue;
2725
import org.elasticsearch.xcontent.ToXContentObject;
@@ -36,7 +34,6 @@
3634

3735
import static org.elasticsearch.action.ValidateActions.addValidationError;
3836
import static org.elasticsearch.common.Strings.EMPTY_ARRAY;
39-
import static org.elasticsearch.common.settings.Settings.readSettingsFromStream;
4037
import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeBooleanValue;
4138

4239
/**
@@ -58,8 +55,6 @@ public class CreateSnapshotRequest extends MasterNodeRequest<CreateSnapshotReque
5855
IndicesRequest.Replaceable,
5956
ToXContentObject {
6057

61-
public static final TransportVersion SETTINGS_IN_REQUEST_VERSION = TransportVersions.V_8_0_0;
62-
6358
public static final int MAXIMUM_METADATA_BYTES = 1024; // chosen arbitrarily
6459

6560
private String snapshot;
@@ -107,9 +102,6 @@ public CreateSnapshotRequest(StreamInput in) throws IOException {
107102
repository = in.readString();
108103
indices = in.readStringArray();
109104
indicesOptions = IndicesOptions.readIndicesOptions(in);
110-
if (in.getTransportVersion().before(SETTINGS_IN_REQUEST_VERSION)) {
111-
readSettingsFromStream(in);
112-
}
113105
featureStates = in.readStringArray();
114106
includeGlobalState = in.readBoolean();
115107
waitForCompletion = in.readBoolean();
@@ -125,9 +117,6 @@ public void writeTo(StreamOutput out) throws IOException {
125117
out.writeString(repository);
126118
out.writeStringArray(indices);
127119
indicesOptions.writeIndicesOptions(out);
128-
if (out.getTransportVersion().before(SETTINGS_IN_REQUEST_VERSION)) {
129-
Settings.EMPTY.writeTo(out);
130-
}
131120
out.writeStringArray(featureStates);
132121
out.writeBoolean(includeGlobalState);
133122
out.writeBoolean(waitForCompletion);

server/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequest.java

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,7 @@ public CreateIndexRequest(StreamInput in) throws IOException {
8787
cause = in.readString();
8888
index = in.readString();
8989
settings = readSettingsFromStream(in);
90-
if (in.getTransportVersion().before(TransportVersions.V_8_0_0)) {
91-
int size = in.readVInt();
92-
assert size <= 1 : "Expected to read 0 or 1 mappings, but received " + size;
93-
if (size == 1) {
94-
String type = in.readString();
95-
if (MapperService.SINGLE_MAPPING_NAME.equals(type) == false) {
96-
throw new IllegalArgumentException("Expected to receive mapping type of [_doc] but got [" + type + "]");
97-
}
98-
mappings = in.readString();
99-
}
100-
} else {
101-
mappings = in.readString();
102-
}
90+
mappings = in.readString();
10391
int aliasesSize = in.readVInt();
10492
for (int i = 0; i < aliasesSize; i++) {
10593
aliases.add(new Alias(in));
@@ -510,17 +498,7 @@ public void writeTo(StreamOutput out) throws IOException {
510498
out.writeString(cause);
511499
out.writeString(index);
512500
settings.writeTo(out);
513-
if (out.getTransportVersion().before(TransportVersions.V_8_0_0)) {
514-
if ("{}".equals(mappings)) {
515-
out.writeVInt(0);
516-
} else {
517-
out.writeVInt(1);
518-
out.writeString(MapperService.SINGLE_MAPPING_NAME);
519-
out.writeString(mappings);
520-
}
521-
} else {
522-
out.writeString(mappings);
523-
}
501+
out.writeString(mappings);
524502
out.writeCollection(aliases);
525503
waitForActiveShards.writeTo(out);
526504
out.writeString(origin);

server/src/main/java/org/elasticsearch/action/admin/indices/forcemerge/ForceMergeRequest.java

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
package org.elasticsearch.action.admin.indices.forcemerge;
1111

12-
import org.elasticsearch.TransportVersion;
13-
import org.elasticsearch.TransportVersions;
1412
import org.elasticsearch.action.ActionRequestValidationException;
1513
import org.elasticsearch.action.support.broadcast.BroadcastRequest;
1614
import org.elasticsearch.common.UUIDs;
@@ -48,8 +46,6 @@ public static final class Defaults {
4846
*/
4947
private boolean shouldStoreResult;
5048

51-
private static final TransportVersion FORCE_MERGE_UUID_SIMPLE_VERSION = TransportVersions.V_8_0_0;
52-
5349
/**
5450
* Force merge UUID to store in the live commit data of a shard under
5551
* {@link org.elasticsearch.index.engine.Engine#FORCE_MERGE_UUID_KEY} after force merging it.
@@ -71,12 +67,7 @@ public ForceMergeRequest(StreamInput in) throws IOException {
7167
maxNumSegments = in.readInt();
7268
onlyExpungeDeletes = in.readBoolean();
7369
flush = in.readBoolean();
74-
if (in.getTransportVersion().onOrAfter(FORCE_MERGE_UUID_SIMPLE_VERSION)) {
75-
forceMergeUUID = in.readString();
76-
} else {
77-
forceMergeUUID = in.readOptionalString();
78-
assert forceMergeUUID != null : "optional was just used as a BwC measure";
79-
}
70+
forceMergeUUID = in.readString();
8071
}
8172

8273
/**
@@ -167,11 +158,7 @@ public void writeTo(StreamOutput out) throws IOException {
167158
out.writeInt(maxNumSegments);
168159
out.writeBoolean(onlyExpungeDeletes);
169160
out.writeBoolean(flush);
170-
if (out.getTransportVersion().onOrAfter(FORCE_MERGE_UUID_SIMPLE_VERSION)) {
171-
out.writeString(forceMergeUUID);
172-
} else {
173-
out.writeOptionalString(forceMergeUUID);
174-
}
161+
out.writeString(forceMergeUUID);
175162
}
176163

177164
@Override

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,7 @@ public CommonStats(StreamInput in) throws IOException {
217217
translog = in.readOptionalWriteable(TranslogStats::new);
218218
requestCache = in.readOptionalWriteable(RequestCacheStats::new);
219219
recoveryStats = in.readOptionalWriteable(RecoveryStats::new);
220-
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_0_0)) {
221-
bulk = in.readOptionalWriteable(BulkStats::new);
222-
}
220+
bulk = in.readOptionalWriteable(BulkStats::new);
223221
shards = in.readOptionalWriteable(ShardCountStats::new);
224222
if (in.getTransportVersion().onOrAfter(VERSION_SUPPORTING_NODE_MAPPINGS)) {
225223
nodeMappings = in.readOptionalWriteable(NodeMappingStats::new);
@@ -250,9 +248,7 @@ public void writeTo(StreamOutput out) throws IOException {
250248
out.writeOptionalWriteable(translog);
251249
out.writeOptionalWriteable(requestCache);
252250
out.writeOptionalWriteable(recoveryStats);
253-
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_0_0)) {
254-
out.writeOptionalWriteable(bulk);
255-
}
251+
out.writeOptionalWriteable(bulk);
256252
out.writeOptionalWriteable(shards);
257253
if (out.getTransportVersion().onOrAfter(VERSION_SUPPORTING_NODE_MAPPINGS)) {
258254
out.writeOptionalWriteable(nodeMappings);

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
package org.elasticsearch.action.admin.indices.stats;
1111

12-
import org.elasticsearch.TransportVersions;
13-
import org.elasticsearch.common.Strings;
1412
import org.elasticsearch.common.io.stream.StreamInput;
1513
import org.elasticsearch.common.io.stream.StreamOutput;
1614
import org.elasticsearch.common.io.stream.Writeable;
@@ -56,9 +54,6 @@ public CommonStatsFlags(StreamInput in) throws IOException {
5654
flags.add(flag);
5755
}
5856
}
59-
if (in.getTransportVersion().before(TransportVersions.V_8_0_0)) {
60-
in.readStringArray();
61-
}
6257
groups = in.readStringArray();
6358
fieldDataFields = in.readStringArray();
6459
completionDataFields = in.readStringArray();
@@ -73,10 +68,6 @@ public void writeTo(StreamOutput out) throws IOException {
7368
longFlags |= (1 << flag.getIndex());
7469
}
7570
out.writeLong(longFlags);
76-
77-
if (out.getTransportVersion().before(TransportVersions.V_8_0_0)) {
78-
out.writeStringArrayNullable(Strings.EMPTY_ARRAY);
79-
}
8071
out.writeStringArrayNullable(groups);
8172
out.writeStringArrayNullable(fieldDataFields);
8273
out.writeStringArrayNullable(completionDataFields);

server/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import org.elasticsearch.common.io.stream.StreamInput;
2323
import org.elasticsearch.common.io.stream.StreamOutput;
2424
import org.elasticsearch.common.io.stream.Writeable;
25-
import org.elasticsearch.index.mapper.MapperService;
2625
import org.elasticsearch.index.seqno.SequenceNumbers;
2726
import org.elasticsearch.index.shard.ShardId;
2827
import org.elasticsearch.rest.RestStatus;
@@ -189,11 +188,6 @@ private Failure(
189188
*/
190189
public Failure(StreamInput in) throws IOException {
191190
index = in.readString();
192-
if (in.getTransportVersion().before(TransportVersions.V_8_0_0)) {
193-
in.readString();
194-
// can't make an assertion about type names here because too many tests still set their own
195-
// types bypassing various checks
196-
}
197191
id = in.readOptionalString();
198192
cause = in.readException();
199193
status = ExceptionsHelper.status(cause);
@@ -210,9 +204,6 @@ public Failure(StreamInput in) throws IOException {
210204
@Override
211205
public void writeTo(StreamOutput out) throws IOException {
212206
out.writeString(index);
213-
if (out.getTransportVersion().before(TransportVersions.V_8_0_0)) {
214-
out.writeString(MapperService.SINGLE_MAPPING_NAME);
215-
}
216207
out.writeOptionalString(id);
217208
out.writeException(cause);
218209
out.writeZLong(seqNo);

server/src/main/java/org/elasticsearch/action/delete/DeleteRequest.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
package org.elasticsearch.action.delete;
1111

1212
import org.apache.lucene.util.RamUsageEstimator;
13-
import org.elasticsearch.TransportVersions;
1413
import org.elasticsearch.action.ActionRequestValidationException;
1514
import org.elasticsearch.action.CompositeIndicesRequest;
1615
import org.elasticsearch.action.DocWriteRequest;
@@ -22,7 +21,6 @@
2221
import org.elasticsearch.common.lucene.uid.Versions;
2322
import org.elasticsearch.core.Nullable;
2423
import org.elasticsearch.index.VersionType;
25-
import org.elasticsearch.index.mapper.MapperService;
2624
import org.elasticsearch.index.shard.ShardId;
2725

2826
import java.io.IOException;
@@ -63,10 +61,6 @@ public DeleteRequest(StreamInput in) throws IOException {
6361

6462
public DeleteRequest(@Nullable ShardId shardId, StreamInput in) throws IOException {
6563
super(shardId, in);
66-
if (in.getTransportVersion().before(TransportVersions.V_8_0_0)) {
67-
String type = in.readString();
68-
assert MapperService.SINGLE_MAPPING_NAME.equals(type) : "Expected [_doc] but received [" + type + "]";
69-
}
7064
id = in.readString();
7165
routing = in.readOptionalString();
7266
version = in.readLong();
@@ -255,9 +249,6 @@ public void writeThin(StreamOutput out) throws IOException {
255249
}
256250

257251
private void writeBody(StreamOutput out) throws IOException {
258-
if (out.getTransportVersion().before(TransportVersions.V_8_0_0)) {
259-
out.writeString(MapperService.SINGLE_MAPPING_NAME);
260-
}
261252
out.writeString(id);
262253
out.writeOptionalString(routing());
263254
out.writeLong(version);

server/src/main/java/org/elasticsearch/action/explain/ExplainRequest.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@
99

1010
package org.elasticsearch.action.explain;
1111

12-
import org.elasticsearch.TransportVersions;
1312
import org.elasticsearch.action.ActionRequestValidationException;
1413
import org.elasticsearch.action.ValidateActions;
1514
import org.elasticsearch.action.support.single.shard.SingleShardRequest;
1615
import org.elasticsearch.common.Strings;
1716
import org.elasticsearch.common.io.stream.StreamInput;
1817
import org.elasticsearch.common.io.stream.StreamOutput;
19-
import org.elasticsearch.index.mapper.MapperService;
2018
import org.elasticsearch.index.query.QueryBuilder;
2119
import org.elasticsearch.search.fetch.subphase.FetchSourceContext;
2220
import org.elasticsearch.search.internal.AliasFilter;
@@ -55,10 +53,6 @@ public ExplainRequest(String index, String id) {
5553

5654
ExplainRequest(StreamInput in) throws IOException {
5755
super(in);
58-
if (in.getTransportVersion().before(TransportVersions.V_8_0_0)) {
59-
String type = in.readString();
60-
assert MapperService.SINGLE_MAPPING_NAME.equals(type);
61-
}
6256
id = in.readString();
6357
routing = in.readOptionalString();
6458
preference = in.readOptionalString();
@@ -161,9 +155,6 @@ public ActionRequestValidationException validate() {
161155
@Override
162156
public void writeTo(StreamOutput out) throws IOException {
163157
super.writeTo(out);
164-
if (out.getTransportVersion().before(TransportVersions.V_8_0_0)) {
165-
out.writeString(MapperService.SINGLE_MAPPING_NAME);
166-
}
167158
out.writeString(id);
168159
out.writeOptionalString(routing);
169160
out.writeOptionalString(preference);

0 commit comments

Comments
 (0)