Skip to content

Commit d847dfc

Browse files
authored
Reapply "Remove most remaining uses of V_8_0_0 transport version" (#139082)
This reverts commit 135aa59.
1 parent 4eace8a commit d847dfc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+43
-474
lines changed

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

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

1212
import org.elasticsearch.ElasticsearchException;
13-
import org.elasticsearch.TransportVersions;
1413
import org.elasticsearch.common.io.stream.StreamInput;
1514
import org.elasticsearch.common.io.stream.StreamOutput;
16-
import org.elasticsearch.index.mapper.MapperService;
1715
import org.elasticsearch.rest.RestStatus;
1816

1917
import java.io.IOException;
@@ -42,18 +40,12 @@ public RestStatus status() {
4240

4341
public RoutingMissingException(StreamInput in) throws IOException {
4442
super(in);
45-
if (in.getTransportVersion().before(TransportVersions.V_8_0_0)) {
46-
in.readString();
47-
}
4843
id = in.readString();
4944
}
5045

5146
@Override
5247
protected void writeTo(StreamOutput out, Writer<Throwable> nestedExceptionsWriter) throws IOException {
5348
super.writeTo(out, nestedExceptionsWriter);
54-
if (out.getTransportVersion().before(TransportVersions.V_8_0_0)) {
55-
out.writeString(MapperService.SINGLE_MAPPING_NAME);
56-
}
5749
out.writeString(id);
5850
}
5951
}

server/src/main/java/org/elasticsearch/action/admin/indices/get/GetIndexRequest.java

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

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

12-
import org.elasticsearch.TransportVersions;
1312
import org.elasticsearch.action.ActionRequestValidationException;
1413
import org.elasticsearch.action.IndicesRequest;
1514
import org.elasticsearch.action.support.IndicesOptions;
@@ -113,9 +112,6 @@ public GetIndexRequest(TimeValue masterTimeout) {
113112
public GetIndexRequest(StreamInput in) throws IOException {
114113
super(in);
115114
indices = in.readStringArray();
116-
if (in.getTransportVersion().before(TransportVersions.V_8_0_0)) {
117-
in.readStringArray();
118-
}
119115
indicesOptions = IndicesOptions.readIndicesOptions(in);
120116
features = in.readArray(i -> Feature.fromId(i.readByte()), Feature[]::new);
121117
humanReadable = in.readBoolean();

server/src/main/java/org/elasticsearch/action/admin/indices/get/GetIndexResponse.java

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

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

12-
import org.elasticsearch.TransportVersions;
1312
import org.elasticsearch.action.ActionResponse;
1413
import org.elasticsearch.cluster.metadata.AliasMetadata;
1514
import org.elasticsearch.cluster.metadata.MappingMetadata;
@@ -20,7 +19,6 @@
2019
import org.elasticsearch.common.settings.Settings;
2120
import org.elasticsearch.common.xcontent.ChunkedToXContentObject;
2221
import org.elasticsearch.core.UpdateForV10;
23-
import org.elasticsearch.index.mapper.MapperService;
2422
import org.elasticsearch.xcontent.ToXContent;
2523

2624
import java.io.IOException;
@@ -77,18 +75,10 @@ public GetIndexResponse(
7775
@UpdateForV10(owner = UpdateForV10.Owner.DATA_MANAGEMENT)
7876
GetIndexResponse(StreamInput in) throws IOException {
7977
this.indices = in.readStringArray();
80-
mappings = in.readImmutableOpenMap(StreamInput::readString, in.getTransportVersion().before(TransportVersions.V_8_0_0) ? i -> {
81-
int numMappings = i.readVInt();
82-
assert numMappings == 0 || numMappings == 1 : "Expected 0 or 1 mappings but got " + numMappings;
83-
if (numMappings == 1) {
84-
String type = i.readString();
85-
assert MapperService.SINGLE_MAPPING_NAME.equals(type) : "Expected [_doc] but got [" + type + "]";
86-
return new MappingMetadata(i);
87-
} else {
88-
return MappingMetadata.EMPTY_MAPPINGS;
89-
}
90-
} : i -> i.readBoolean() ? new MappingMetadata(i) : MappingMetadata.EMPTY_MAPPINGS);
91-
78+
mappings = in.readImmutableOpenMap(
79+
StreamInput::readString,
80+
i -> i.readBoolean() ? new MappingMetadata(i) : MappingMetadata.EMPTY_MAPPINGS
81+
);
9282
aliases = in.readImmutableOpenMap(StreamInput::readString, i -> i.readCollectionAsList(AliasMetadata::new));
9383
settings = in.readImmutableOpenMap(StreamInput::readString, Settings::readSettingsFromStream);
9484
defaultSettings = in.readImmutableOpenMap(StreamInput::readString, Settings::readSettingsFromStream);

server/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/GetFieldMappingsIndexRequest.java

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

1010
package org.elasticsearch.action.admin.indices.mapping.get;
1111

12-
import org.elasticsearch.TransportVersions;
1312
import org.elasticsearch.action.ActionRequestValidationException;
1413
import org.elasticsearch.action.OriginalIndices;
1514
import org.elasticsearch.action.support.IndicesOptions;
1615
import org.elasticsearch.action.support.single.shard.SingleShardRequest;
17-
import org.elasticsearch.common.Strings;
1816
import org.elasticsearch.common.io.stream.StreamInput;
1917
import org.elasticsearch.common.io.stream.StreamOutput;
2018

@@ -29,14 +27,8 @@ public class GetFieldMappingsIndexRequest extends SingleShardRequest<GetFieldMap
2927

3028
GetFieldMappingsIndexRequest(StreamInput in) throws IOException {
3129
super(in);
32-
if (in.getTransportVersion().before(TransportVersions.V_8_0_0)) {
33-
in.readStringArray(); // former types array
34-
}
3530
fields = in.readStringArray();
3631
includeDefaults = in.readBoolean();
37-
if (in.getTransportVersion().before(TransportVersions.V_8_0_0)) {
38-
in.readBoolean(); // former probablySingleField boolean
39-
}
4032
originalIndices = OriginalIndices.readOriginalIndices(in);
4133
}
4234

@@ -74,14 +66,8 @@ public IndicesOptions indicesOptions() {
7466
@Override
7567
public void writeTo(StreamOutput out) throws IOException {
7668
super.writeTo(out);
77-
if (out.getTransportVersion().before(TransportVersions.V_8_0_0)) {
78-
out.writeStringArray(Strings.EMPTY_ARRAY);
79-
}
8069
out.writeStringArray(fields);
8170
out.writeBoolean(includeDefaults);
82-
if (out.getTransportVersion().before(TransportVersions.V_8_0_0)) {
83-
out.writeBoolean(false);
84-
}
8571
OriginalIndices.writeOriginalIndices(originalIndices, out);
8672
}
8773

server/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/GetFieldMappingsRequest.java

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

1010
package org.elasticsearch.action.admin.indices.mapping.get;
1111

12-
import org.elasticsearch.TransportVersions;
1312
import org.elasticsearch.action.ActionRequestValidationException;
1413
import org.elasticsearch.action.IndicesRequest;
1514
import org.elasticsearch.action.LegacyActionRequest;
@@ -19,7 +18,6 @@
1918
import org.elasticsearch.common.io.stream.StreamOutput;
2019

2120
import java.io.IOException;
22-
import java.util.Arrays;
2321

2422
/**
2523
* Request the mappings of specific fields
@@ -42,18 +40,7 @@ public GetFieldMappingsRequest() {}
4240
public GetFieldMappingsRequest(StreamInput in) throws IOException {
4341
super(in);
4442
indices = in.readStringArray();
45-
if (in.getTransportVersion().before(TransportVersions.V_8_0_0)) {
46-
String[] types = in.readStringArray();
47-
if (types != Strings.EMPTY_ARRAY) {
48-
throw new IllegalArgumentException("Expected empty type array but received [" + Arrays.toString(types) + "]");
49-
}
50-
51-
}
5243
indicesOptions = IndicesOptions.readIndicesOptions(in);
53-
// Consume the deprecated local parameter
54-
if (in.getTransportVersion().before(TransportVersions.V_8_0_0)) {
55-
in.readBoolean();
56-
}
5744
fields = in.readStringArray();
5845
includeDefaults = in.readBoolean();
5946
}
@@ -117,13 +104,7 @@ public ActionRequestValidationException validate() {
117104
public void writeTo(StreamOutput out) throws IOException {
118105
super.writeTo(out);
119106
out.writeStringArray(indices);
120-
if (out.getTransportVersion().before(TransportVersions.V_8_0_0)) {
121-
out.writeStringArray(Strings.EMPTY_ARRAY);
122-
}
123107
indicesOptions.writeIndicesOptions(out);
124-
if (out.getTransportVersion().before(TransportVersions.V_8_0_0)) {
125-
out.writeBoolean(true);
126-
}
127108
out.writeStringArray(fields);
128109
out.writeBoolean(includeDefaults);
129110
}

server/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/GetFieldMappingsResponse.java

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

1010
package org.elasticsearch.action.admin.indices.mapping.get;
1111

12-
import org.elasticsearch.TransportVersions;
1312
import org.elasticsearch.action.ActionResponse;
1413
import org.elasticsearch.common.bytes.BytesReference;
1514
import org.elasticsearch.common.io.stream.StreamInput;
1615
import org.elasticsearch.common.io.stream.StreamOutput;
1716
import org.elasticsearch.common.xcontent.XContentHelper;
1817
import org.elasticsearch.index.mapper.Mapper;
19-
import org.elasticsearch.index.mapper.MapperService;
2018
import org.elasticsearch.xcontent.ParseField;
2119
import org.elasticsearch.xcontent.ToXContentFragment;
2220
import org.elasticsearch.xcontent.ToXContentObject;
@@ -25,7 +23,6 @@
2523

2624
import java.io.IOException;
2725
import java.io.InputStream;
28-
import java.util.Collections;
2926
import java.util.Map;
3027
import java.util.Objects;
3128

@@ -46,17 +43,9 @@ public class GetFieldMappingsResponse extends ActionResponse implements ToXConte
4643
}
4744

4845
GetFieldMappingsResponse(StreamInput in) throws IOException {
49-
mappings = in.readImmutableMap(mapIn -> {
50-
if (mapIn.getTransportVersion().before(TransportVersions.V_8_0_0)) {
51-
int typesSize = mapIn.readVInt();
52-
assert typesSize == 1 || typesSize == 0 : "Expected 0 or 1 types but got " + typesSize;
53-
if (typesSize == 0) {
54-
return Collections.emptyMap();
55-
}
56-
mapIn.readString(); // type
57-
}
58-
return mapIn.readImmutableMap(inpt -> new FieldMappingMetadata(inpt.readString(), inpt.readBytesReference()));
59-
});
46+
mappings = in.readImmutableMap(
47+
mapIn -> mapIn.readImmutableMap(inpt -> new FieldMappingMetadata(inpt.readString(), inpt.readBytesReference()))
48+
);
6049
}
6150

6251
/** returns the retrieved field mapping. The return map keys are index, field (as specified in the request). */
@@ -134,10 +123,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
134123
@Override
135124
public void writeTo(StreamOutput out) throws IOException {
136125
out.writeMap(mappings, (outpt, map) -> {
137-
if (outpt.getTransportVersion().before(TransportVersions.V_8_0_0)) {
138-
outpt.writeVInt(1);
139-
outpt.writeString(MapperService.SINGLE_MAPPING_NAME);
140-
}
141126
outpt.writeMap(map, (o, v) -> {
142127
o.writeString(v.fullName());
143128
o.writeBytesReference(v.source);

server/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/GetMappingsRequest.java

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

1010
package org.elasticsearch.action.admin.indices.mapping.get;
1111

12-
import org.elasticsearch.TransportVersions;
1312
import org.elasticsearch.action.ActionRequestValidationException;
1413
import org.elasticsearch.action.IndicesRequest;
1514
import org.elasticsearch.action.support.IndicesOptions;
@@ -43,9 +42,6 @@ public GetMappingsRequest(TimeValue masterTimeout) {
4342
public GetMappingsRequest(StreamInput in) throws IOException {
4443
super(in);
4544
indices = in.readStringArray();
46-
if (in.getTransportVersion().before(TransportVersions.V_8_0_0)) {
47-
in.readStringArray();
48-
}
4945
indicesOptions = IndicesOptions.readIndicesOptions(in);
5046
}
5147

server/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequest.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.indices.mapping.put;
1111

1212
import org.elasticsearch.ElasticsearchGenerationException;
13-
import org.elasticsearch.TransportVersions;
1413
import org.elasticsearch.action.ActionRequestValidationException;
1514
import org.elasticsearch.action.IndicesRequest;
1615
import org.elasticsearch.action.support.IndicesOptions;
@@ -24,7 +23,6 @@
2423
import org.elasticsearch.common.util.CollectionUtils;
2524
import org.elasticsearch.common.xcontent.XContentHelper;
2625
import org.elasticsearch.index.Index;
27-
import org.elasticsearch.index.mapper.MapperService;
2826
import org.elasticsearch.xcontent.XContentBuilder;
2927
import org.elasticsearch.xcontent.XContentFactory;
3028
import org.elasticsearch.xcontent.XContentType;
@@ -97,12 +95,6 @@ public PutMappingRequest(StreamInput in) throws IOException {
9795
super(in);
9896
indices = in.readStringArray();
9997
indicesOptions = IndicesOptions.readIndicesOptions(in);
100-
if (in.getTransportVersion().before(TransportVersions.V_8_0_0)) {
101-
String type = in.readOptionalString();
102-
if (MapperService.SINGLE_MAPPING_NAME.equals(type) == false) {
103-
throw new IllegalArgumentException("Expected type [_doc] but received [" + type + "]");
104-
}
105-
}
10698
source = in.readString();
10799
concreteIndex = in.readOptionalWriteable(Index::new);
108100
origin = in.readOptionalString();
@@ -330,9 +322,6 @@ public void writeTo(StreamOutput out) throws IOException {
330322
super.writeTo(out);
331323
out.writeStringArrayNullable(indices);
332324
indicesOptions.writeIndicesOptions(out);
333-
if (out.getTransportVersion().before(TransportVersions.V_8_0_0)) {
334-
out.writeOptionalString(MapperService.SINGLE_MAPPING_NAME);
335-
}
336325
out.writeString(source);
337326
out.writeOptionalWriteable(concreteIndex);
338327
out.writeOptionalString(origin);

server/src/main/java/org/elasticsearch/action/admin/indices/segments/IndicesSegmentsRequest.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ public IndicesSegmentsRequest() {
3131

3232
public IndicesSegmentsRequest(StreamInput in) throws IOException {
3333
super(in);
34-
if (in.getTransportVersion().before(TransportVersions.V_8_0_0)) {
35-
in.readBoolean(); // old 'verbose' option, since removed
36-
}
3734
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_15_0)) {
3835
this.includeVectorFormatsInfo = in.readBoolean();
3936
}
@@ -56,9 +53,6 @@ public boolean isIncludeVectorFormatsInfo() {
5653
@Override
5754
public void writeTo(StreamOutput out) throws IOException {
5855
super.writeTo(out);
59-
if (out.getTransportVersion().before(TransportVersions.V_8_0_0)) {
60-
out.writeBoolean(false);
61-
}
6256
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_15_0)) {
6357
out.writeBoolean(includeVectorFormatsInfo);
6458
}

server/src/main/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateRequest.java

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
import org.elasticsearch.ElasticsearchGenerationException;
1212
import org.elasticsearch.ElasticsearchParseException;
13-
import org.elasticsearch.TransportVersions;
1413
import org.elasticsearch.action.ActionRequestValidationException;
1514
import org.elasticsearch.action.IndicesRequest;
1615
import org.elasticsearch.action.admin.indices.alias.Alias;
@@ -77,15 +76,7 @@ public PutIndexTemplateRequest(StreamInput in) throws IOException {
7776
order = in.readInt();
7877
create = in.readBoolean();
7978
settings = readSettingsFromStream(in);
80-
if (in.getTransportVersion().before(TransportVersions.V_8_0_0)) {
81-
int size = in.readVInt();
82-
for (int i = 0; i < size; i++) {
83-
in.readString(); // type - cannot assert on _doc because 7x allows arbitrary type names
84-
this.mappings = in.readString();
85-
}
86-
} else {
87-
this.mappings = in.readOptionalString();
88-
}
79+
mappings = in.readOptionalString();
8980
int aliasesSize = in.readVInt();
9081
for (int i = 0; i < aliasesSize; i++) {
9182
aliases.add(new Alias(in));
@@ -450,15 +441,7 @@ public void writeTo(StreamOutput out) throws IOException {
450441
out.writeInt(order);
451442
out.writeBoolean(create);
452443
settings.writeTo(out);
453-
if (out.getTransportVersion().before(TransportVersions.V_8_0_0)) {
454-
out.writeVInt(mappings == null ? 0 : 1);
455-
if (mappings != null) {
456-
out.writeString(MapperService.SINGLE_MAPPING_NAME);
457-
out.writeString(mappings);
458-
}
459-
} else {
460-
out.writeOptionalString(mappings);
461-
}
444+
out.writeOptionalString(mappings);
462445
out.writeCollection(aliases);
463446
out.writeOptionalVInt(version);
464447
}

0 commit comments

Comments
 (0)