Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
fd3dde1
Add TransportVersion file
thecoop Jan 12, 2023
b75f0de
Update docs/changelog/92869.yaml
thecoop Jan 12, 2023
0bffdf2
Update for 8.6.1
thecoop Jan 12, 2023
591f740
Fix id numbers
thecoop Jan 12, 2023
719ff87
Delete docs/changelog/92869.yaml
thecoop Jan 12, 2023
5f0462e
Fix id numbers
thecoop Jan 12, 2023
0346113
Add initial methods to StreamInput and StreamOutput
thecoop Jan 13, 2023
3fcbd3b
test
pgomulka Jan 13, 2023
dc9ae45
remove compatibility test
pgomulka Jan 13, 2023
9689954
PR comments
thecoop Jan 16, 2023
c64e813
test cleanup
pgomulka Jan 16, 2023
7e9690a
cleanup
pgomulka Jan 16, 2023
064b1f2
Merge pull request #1 from pgomulka/transportversion
thecoop Jan 16, 2023
8b12530
More PR comments
thecoop Jan 18, 2023
6d3a1a4
Convert TcpTransport infrastructure to TransportVersion
thecoop Jan 16, 2023
f220765
Add isCompatible method
thecoop Jan 17, 2023
d7e919b
Update tests
thecoop Jan 17, 2023
7f865ad
Add full compatibility method to get things working
thecoop Jan 17, 2023
2b40f4b
Spread calculateMinimumCompatVersion around
thecoop Jan 17, 2023
ea1d729
More test fixes
thecoop Jan 17, 2023
4de6681
Splotless
thecoop Jan 17, 2023
e5db29d
Some hacks around TcpTransport.getVersion to make some tests pass
thecoop Jan 17, 2023
26b5ce7
Convert index-related code to TransportVersion
thecoop Jan 18, 2023
9c5d476
Merge branch 'main' into transportversion-tcptransport
thecoop Jan 19, 2023
205dd7d
Merge branch 'transportversion-tcptransport' into transportversion-in…
thecoop Jan 19, 2023
f884807
Merge remote-tracking branch 'upstream/main' into transportversion-in…
thecoop Jan 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

package org.elasticsearch.index.rankeval;

import org.elasticsearch.Version;
import org.elasticsearch.TransportVersion;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.IndicesRequest;
Expand Down Expand Up @@ -45,7 +45,7 @@ public RankEvalRequest(RankEvalSpec rankingEvaluationSpec, String[] indices) {
rankingEvaluationSpec = new RankEvalSpec(in);
indices = in.readStringArray();
indicesOptions = IndicesOptions.readIndicesOptions(in);
if (in.getVersion().onOrAfter(Version.V_7_6_0)) {
if (in.getTransportVersion().onOrAfter(TransportVersion.V_7_6_0)) {
searchType = SearchType.fromId(in.readByte());
}
}
Expand Down Expand Up @@ -126,7 +126,7 @@ public void writeTo(StreamOutput out) throws IOException {
rankingEvaluationSpec.writeTo(out);
out.writeStringArray(indices);
indicesOptions.writeIndicesOptions(out);
if (out.getVersion().onOrAfter(Version.V_7_6_0)) {
if (out.getTransportVersion().onOrAfter(TransportVersion.V_7_6_0)) {
out.writeByte(searchType.id());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public ClusterInfo(StreamInput in) throws IOException {
} else {
this.dataPath = in.readImmutableMap(nested -> NodeAndShard.from(new ShardRouting(nested)), StreamInput::readString);
}
if (in.getVersion().onOrAfter(StoreStats.RESERVED_BYTES_VERSION)) {
if (in.getTransportVersion().onOrAfter(StoreStats.RESERVED_BYTES_VERSION)) {
this.reservedSpace = in.readImmutableMap(NodeAndPath::new, ReservedSpace::new);
} else {
this.reservedSpace = Map.of();
Expand All @@ -117,7 +117,7 @@ public void writeTo(StreamOutput out) throws IOException {
} else {
out.writeMap(this.dataPath, (o, k) -> createFakeShardRoutingFromNodeAndShard(k).writeTo(o), StreamOutput::writeString);
}
if (out.getVersion().onOrAfter(StoreStats.RESERVED_BYTES_VERSION)) {
if (out.getTransportVersion().onOrAfter(StoreStats.RESERVED_BYTES_VERSION)) {
out.writeMap(this.reservedSpace);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.apache.lucene.search.SortedNumericSortField;
import org.apache.lucene.search.SortedSetSelector;
import org.apache.lucene.search.SortedSetSortField;
import org.elasticsearch.Version;
import org.elasticsearch.TransportVersion;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable;
Expand Down Expand Up @@ -52,7 +52,7 @@ public Segment(StreamInput in) throws IOException {
version = Lucene.parseVersionLenient(in.readOptionalString(), null);
compound = in.readOptionalBoolean();
mergeId = in.readOptionalString();
if (in.getVersion().before(Version.V_8_0_0)) {
if (in.getTransportVersion().before(TransportVersion.V_8_0_0)) {
in.readLong(); // memoryInBytes
}
if (in.readBoolean()) {
Expand Down Expand Up @@ -159,7 +159,7 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeOptionalString(version.toString());
out.writeOptionalBoolean(compound);
out.writeOptionalString(mergeId);
if (out.getVersion().before(Version.V_8_0_0)) {
if (out.getTransportVersion().before(TransportVersion.V_8_0_0)) {
out.writeLong(0); // memoryInBytes
}

Expand Down Expand Up @@ -252,7 +252,7 @@ private static void writeSegmentSort(StreamOutput out, Sort sort) throws IOExcep
o.writeBoolean(((SortedNumericSortField) field).getSelector() == SortedNumericSelector.Type.MAX);
o.writeBoolean(field.getReverse());
} else if (field.getType().equals(SortField.Type.STRING)) {
if (o.getVersion().before(Version.V_8_5_0)) {
if (o.getTransportVersion().before(TransportVersion.V_8_5_0)) {
// The closest supported version before 8.5.0 was SortedSet fields, so we mimic that
o.writeByte(SORT_STRING_SET);
o.writeOptionalBoolean(field.getMissingValue() == null ? null : field.getMissingValue() == SortField.STRING_FIRST);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

package org.elasticsearch.index.engine;

import org.elasticsearch.Version;
import org.elasticsearch.TransportVersion;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
Expand Down Expand Up @@ -39,7 +39,7 @@ public SegmentsStats() {

public SegmentsStats(StreamInput in) throws IOException {
count = in.readVLong();
if (in.getVersion().before(Version.V_8_0_0)) {
if (in.getTransportVersion().before(TransportVersion.V_8_0_0)) {
in.readLong(); // memoryInBytes
in.readLong(); // termsMemoryInBytes
in.readLong(); // storedFieldsMemoryInBytes
Expand Down Expand Up @@ -220,7 +220,7 @@ static final class Fields {
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeVLong(count);
if (out.getVersion().before(Version.V_8_0_0)) {
if (out.getTransportVersion().before(TransportVersion.V_8_0_0)) {
out.writeLong(0L); // memoryInBytes
out.writeLong(0L); // termsMemoryInBytes
out.writeLong(0L); // storedFieldsMemoryInBytes
Expand Down Expand Up @@ -250,7 +250,7 @@ public static class FileStats implements Writeable, ToXContentFragment {
private final long max;

FileStats(StreamInput in) throws IOException {
if (in.getVersion().onOrAfter(Version.V_7_13_0)) {
if (in.getTransportVersion().onOrAfter(TransportVersion.V_7_13_0)) {
this.ext = in.readString();
this.total = in.readVLong();
this.count = in.readVLong();
Expand Down Expand Up @@ -295,7 +295,7 @@ public long getMax() {

@Override
public void writeTo(StreamOutput out) throws IOException {
if (out.getVersion().onOrAfter(Version.V_7_13_0)) {
if (out.getTransportVersion().onOrAfter(TransportVersion.V_7_13_0)) {
out.writeString(ext);
out.writeVLong(total);
out.writeVLong(count);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
package org.elasticsearch.index.get;

import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.Version;
import org.elasticsearch.TransportVersion;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.compress.CompressorFactory;
Expand Down Expand Up @@ -66,7 +66,7 @@ public class GetResult implements Writeable, Iterable<DocumentField>, ToXContent

public GetResult(StreamInput in) throws IOException {
index = in.readString();
if (in.getVersion().before(Version.V_8_0_0)) {
if (in.getTransportVersion().before(TransportVersion.V_8_0_0)) {
in.readOptionalString();
}
id = in.readString();
Expand Down Expand Up @@ -386,7 +386,7 @@ public static GetResult fromXContent(XContentParser parser) throws IOException {
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeString(index);
if (out.getVersion().before(Version.V_8_0_0)) {
if (out.getTransportVersion().before(TransportVersion.V_8_0_0)) {
out.writeOptionalString(MapperService.SINGLE_MAPPING_NAME);
}
out.writeString(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.apache.lucene.search.MatchNoDocsQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.util.SetOnce;
import org.elasticsearch.Version;
import org.elasticsearch.TransportVersion;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.get.GetRequest;
import org.elasticsearch.client.internal.Client;
Expand Down Expand Up @@ -141,7 +141,7 @@ protected AbstractGeometryQueryBuilder(StreamInput in) throws IOException {
} else {
shape = null;
indexedShapeId = in.readOptionalString();
if (in.getVersion().before(Version.V_8_0_0)) {
if (in.getTransportVersion().before(TransportVersion.V_8_0_0)) {
String type = in.readOptionalString();
assert MapperService.SINGLE_MAPPING_NAME.equals(type) : "Expected type [_doc], got [" + type + "]";
}
Expand All @@ -166,7 +166,7 @@ protected void doWriteTo(StreamOutput out) throws IOException {
GeometryIO.writeGeometry(out, shape);
} else {
out.writeOptionalString(indexedShapeId);
if (out.getVersion().before(Version.V_8_0_0)) {
if (out.getTransportVersion().before(TransportVersion.V_8_0_0)) {
out.writeOptionalString(MapperService.SINGLE_MAPPING_NAME);
}
out.writeOptionalString(indexedShapeIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.apache.lucene.search.MatchNoDocsQuery;
import org.apache.lucene.search.Query;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.TransportVersion;
import org.elasticsearch.Version;
import org.elasticsearch.common.Numbers;
import org.elasticsearch.common.ParsingException;
Expand Down Expand Up @@ -76,7 +77,7 @@ public GeoBoundingBoxQueryBuilder(StreamInput in) throws IOException {
super(in);
fieldName = in.readString();
geoBoundingBox = new GeoBoundingBox(in);
if (in.getVersion().before(Version.V_8_0_0)) {
if (in.getTransportVersion().before(TransportVersion.V_8_0_0)) {
in.readVInt(); // ignore value
}
validationMethod = GeoValidationMethod.readFromStream(in);
Expand All @@ -87,7 +88,7 @@ public GeoBoundingBoxQueryBuilder(StreamInput in) throws IOException {
protected void doWriteTo(StreamOutput out) throws IOException {
out.writeString(fieldName);
geoBoundingBox.writeTo(out);
if (out.getVersion().before(Version.V_8_0_0)) {
if (out.getTransportVersion().before(TransportVersion.V_8_0_0)) {
out.writeVInt(0);
}
validationMethod.writeTo(out);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
package org.elasticsearch.index.query;

import org.apache.lucene.search.Query;
import org.elasticsearch.TransportVersion;
import org.elasticsearch.Version;
import org.elasticsearch.common.ParsingException;
import org.elasticsearch.common.Strings;
Expand Down Expand Up @@ -53,7 +54,7 @@ public IdsQueryBuilder() {
*/
public IdsQueryBuilder(StreamInput in) throws IOException {
super(in);
if (in.getVersion().before(Version.V_8_0_0)) {
if (in.getTransportVersion().before(TransportVersion.V_8_0_0)) {
// types no longer relevant so ignore
String[] types = in.readStringArray();
if (types.length > 0) {
Expand All @@ -65,7 +66,7 @@ public IdsQueryBuilder(StreamInput in) throws IOException {

@Override
protected void doWriteTo(StreamOutput out) throws IOException {
if (out.getVersion().before(Version.V_8_0_0)) {
if (out.getTransportVersion().before(TransportVersion.V_8_0_0)) {
// types not supported so send an empty array to previous versions
out.writeStringArray(Strings.EMPTY_ARRAY);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
package org.elasticsearch.index.query;

import org.elasticsearch.Version;
import org.elasticsearch.TransportVersion;
import org.elasticsearch.common.ParsingException;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.io.stream.StreamInput;
Expand Down Expand Up @@ -189,7 +189,7 @@ public InnerHitBuilder(StreamInput in) throws IOException {
highlightBuilder = in.readOptionalWriteable(HighlightBuilder::new);
this.innerCollapseBuilder = in.readOptionalWriteable(CollapseBuilder::new);

if (in.getVersion().onOrAfter(Version.V_7_10_0)) {
if (in.getTransportVersion().onOrAfter(TransportVersion.V_7_10_0)) {
if (in.readBoolean()) {
fetchFields = in.readList(FieldAndFormat::new);
}
Expand Down Expand Up @@ -229,7 +229,7 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeOptionalWriteable(highlightBuilder);
out.writeOptionalWriteable(innerCollapseBuilder);

if (out.getVersion().onOrAfter(Version.V_7_10_0)) {
if (out.getTransportVersion().onOrAfter(TransportVersion.V_7_10_0)) {
out.writeBoolean(fetchFields != null);
if (fetchFields != null) {
out.writeList(fetchFields);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.apache.lucene.queries.intervals.Intervals;
import org.apache.lucene.queries.intervals.IntervalsSource;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.Version;
import org.elasticsearch.TransportVersion;
import org.elasticsearch.common.ParsingException;
import org.elasticsearch.common.io.stream.NamedWriteable;
import org.elasticsearch.common.io.stream.StreamInput;
Expand Down Expand Up @@ -120,7 +120,7 @@ public Match(StreamInput in) throws IOException {
this.ordered = in.readBoolean();
this.analyzer = in.readOptionalString();
this.filter = in.readOptionalWriteable(IntervalFilter::new);
if (in.getVersion().onOrAfter(Version.V_7_2_0)) {
if (in.getTransportVersion().onOrAfter(TransportVersion.V_7_2_0)) {
this.useField = in.readOptionalString();
} else {
this.useField = null;
Expand Down Expand Up @@ -204,7 +204,7 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeBoolean(ordered);
out.writeOptionalString(analyzer);
out.writeOptionalWriteable(filter);
if (out.getVersion().onOrAfter(Version.V_7_2_0)) {
if (out.getTransportVersion().onOrAfter(TransportVersion.V_7_2_0)) {
out.writeOptionalString(useField);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import org.apache.lucene.search.FuzzyQuery;
import org.apache.lucene.search.Query;
import org.elasticsearch.TransportVersion;
import org.elasticsearch.Version;
import org.elasticsearch.common.ParsingException;
import org.elasticsearch.common.io.stream.StreamInput;
Expand Down Expand Up @@ -64,7 +65,7 @@ public MatchPhrasePrefixQueryBuilder(StreamInput in) throws IOException {
slop = in.readVInt();
maxExpansions = in.readVInt();
analyzer = in.readOptionalString();
if (in.getVersion().onOrAfter(Version.V_7_10_0)) {
if (in.getTransportVersion().onOrAfter(TransportVersion.V_7_10_0)) {
this.zeroTermsQuery = ZeroTermsQueryOption.readFromStream(in);
}
}
Expand All @@ -76,7 +77,7 @@ protected void doWriteTo(StreamOutput out) throws IOException {
out.writeVInt(slop);
out.writeVInt(maxExpansions);
out.writeOptionalString(analyzer);
if (out.getVersion().onOrAfter(Version.V_7_10_0)) {
if (out.getTransportVersion().onOrAfter(TransportVersion.V_7_10_0)) {
zeroTermsQuery.writeTo(out);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.apache.lucene.analysis.core.KeywordAnalyzer;
import org.apache.lucene.search.FuzzyQuery;
import org.apache.lucene.search.Query;
import org.elasticsearch.TransportVersion;
import org.elasticsearch.Version;
import org.elasticsearch.common.ParsingException;
import org.elasticsearch.common.io.stream.StreamInput;
Expand Down Expand Up @@ -117,7 +118,7 @@ public MatchQueryBuilder(StreamInput in) throws IOException {
fuzzyRewrite = in.readOptionalString();
fuzziness = in.readOptionalWriteable(Fuzziness::new);
// cutoff_frequency has been removed
if (in.getVersion().before(Version.V_8_0_0)) {
if (in.getTransportVersion().before(TransportVersion.V_8_0_0)) {
in.readOptionalFloat();
}
autoGenerateSynonymsPhraseQuery = in.readBoolean();
Expand All @@ -139,7 +140,7 @@ protected void doWriteTo(StreamOutput out) throws IOException {
out.writeOptionalString(fuzzyRewrite);
out.writeOptionalWriteable(fuzziness);
// cutoff_frequency has been removed
if (out.getVersion().before(Version.V_8_0_0)) {
if (out.getTransportVersion().before(TransportVersion.V_8_0_0)) {
out.writeOptionalFloat(null);
}
out.writeBoolean(autoGenerateSynonymsPhraseQuery);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.apache.lucene.search.Query;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.TransportVersion;
import org.elasticsearch.Version;
import org.elasticsearch.action.RoutingMissingException;
import org.elasticsearch.action.termvectors.MultiTermVectorsItemResponse;
Expand Down Expand Up @@ -206,7 +207,7 @@ public Item(@Nullable String index, XContentBuilder doc) {
@SuppressWarnings("unchecked")
Item(StreamInput in) throws IOException {
index = in.readOptionalString();
if (in.getVersion().before(Version.V_8_0_0)) {
if (in.getTransportVersion().before(TransportVersion.V_8_0_0)) {
// types no longer relevant so ignore
String type = in.readOptionalString();
if (type != null) {
Expand All @@ -229,7 +230,7 @@ public Item(@Nullable String index, XContentBuilder doc) {
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeOptionalString(index);
if (out.getVersion().before(Version.V_8_0_0)) {
if (out.getTransportVersion().before(TransportVersion.V_8_0_0)) {
// types not supported so send an empty array to previous versions
out.writeOptionalString(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.apache.lucene.search.FuzzyQuery;
import org.apache.lucene.search.Query;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.TransportVersion;
import org.elasticsearch.Version;
import org.elasticsearch.common.ParsingException;
import org.elasticsearch.common.Strings;
Expand Down Expand Up @@ -223,7 +224,7 @@ public MultiMatchQueryBuilder(StreamInput in) throws IOException {
fuzzyRewrite = in.readOptionalString();
tieBreaker = in.readOptionalFloat();
lenient = in.readOptionalBoolean();
if (in.getVersion().before(Version.V_8_0_0)) {
if (in.getTransportVersion().before(TransportVersion.V_8_0_0)) {
in.readOptionalFloat();
}
zeroTermsQuery = ZeroTermsQueryOption.readFromStream(in);
Expand All @@ -246,7 +247,7 @@ protected void doWriteTo(StreamOutput out) throws IOException {
out.writeOptionalString(fuzzyRewrite);
out.writeOptionalFloat(tieBreaker);
out.writeOptionalBoolean(lenient);
if (out.getVersion().before(Version.V_8_0_0)) {
if (out.getTransportVersion().before(TransportVersion.V_8_0_0)) {
out.writeOptionalFloat(null);
}
zeroTermsQuery.writeTo(out);
Expand Down
Loading