Skip to content

Commit

Permalink
Remove 7.2 transport versions (elastic#118434)
Browse files Browse the repository at this point in the history
  • Loading branch information
thecoop authored Dec 11, 2024
1 parent b7d109c commit a054bbc
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 170 deletions.
2 changes: 0 additions & 2 deletions server/src/main/java/org/elasticsearch/TransportVersions.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ static TransportVersion def(int id) {
@UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA) // remove the transport versions with which v9 will not need to interact
public static final TransportVersion ZERO = def(0);
public static final TransportVersion V_7_0_0 = def(7_00_00_99);
public static final TransportVersion V_7_2_0 = def(7_02_00_99);
public static final TransportVersion V_7_2_1 = def(7_02_01_99);
public static final TransportVersion V_7_3_0 = def(7_03_00_99);
public static final TransportVersion V_7_4_0 = def(7_04_00_99);
public static final TransportVersion V_7_5_0 = def(7_05_00_99);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1618,11 +1618,7 @@ private static class IndexMetadataDiff implements Diff<IndexMetadata> {
version = in.readLong();
mappingVersion = in.readVLong();
settingsVersion = in.readVLong();
if (in.getTransportVersion().onOrAfter(TransportVersions.V_7_2_0)) {
aliasesVersion = in.readVLong();
} else {
aliasesVersion = 1;
}
aliasesVersion = in.readVLong();
state = State.fromId(in.readByte());
if (in.getTransportVersion().onOrAfter(SETTING_DIFF_VERSION)) {
settings = null;
Expand Down Expand Up @@ -1688,9 +1684,7 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeLong(version);
out.writeVLong(mappingVersion);
out.writeVLong(settingsVersion);
if (out.getTransportVersion().onOrAfter(TransportVersions.V_7_2_0)) {
out.writeVLong(aliasesVersion);
}
out.writeVLong(aliasesVersion);
out.writeByte(state.id);
assert settings != null
: "settings should always be non-null since this instance is not expected to have been read from another node";
Expand Down Expand Up @@ -1776,9 +1770,7 @@ public static IndexMetadata readFrom(StreamInput in, @Nullable Function<String,
builder.version(in.readLong());
builder.mappingVersion(in.readVLong());
builder.settingsVersion(in.readVLong());
if (in.getTransportVersion().onOrAfter(TransportVersions.V_7_2_0)) {
builder.aliasesVersion(in.readVLong());
}
builder.aliasesVersion(in.readVLong());
builder.setRoutingNumShards(in.readInt());
builder.state(State.fromId(in.readByte()));
builder.settings(readSettingsFromStream(in));
Expand Down Expand Up @@ -1848,9 +1840,7 @@ public void writeTo(StreamOutput out, boolean mappingsAsHash) throws IOException
out.writeLong(version);
out.writeVLong(mappingVersion);
out.writeVLong(settingsVersion);
if (out.getTransportVersion().onOrAfter(TransportVersions.V_7_2_0)) {
out.writeVLong(aliasesVersion);
}
out.writeVLong(aliasesVersion);
out.writeInt(routingNumShards);
out.writeByte(state.id());
settings.writeTo(out);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,6 @@ public String toString() {

@Override
public TransportVersion getMinimalSupportedVersion() {
return TransportVersions.V_7_2_0;
return TransportVersions.ZERO;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,7 @@ public Match(StreamInput in) throws IOException {
this.ordered = in.readBoolean();
this.analyzer = in.readOptionalString();
this.filter = in.readOptionalWriteable(IntervalFilter::new);
if (in.getTransportVersion().onOrAfter(TransportVersions.V_7_2_0)) {
this.useField = in.readOptionalString();
} else {
this.useField = null;
}
this.useField = in.readOptionalString();
}

private static IntervalsSource intervals(
Expand Down Expand Up @@ -213,9 +209,7 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeBoolean(ordered);
out.writeOptionalString(analyzer);
out.writeOptionalWriteable(filter);
if (out.getTransportVersion().onOrAfter(TransportVersions.V_7_2_0)) {
out.writeOptionalString(useField);
}
out.writeOptionalString(useField);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,6 @@ public String getWriteableName() {

@Override
public TransportVersion getMinimalSupportedVersion() {
return TransportVersions.V_7_2_0;
return TransportVersions.ZERO;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

package org.elasticsearch.index.refresh;

import org.elasticsearch.TransportVersions;
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 @@ -40,21 +39,17 @@ public RefreshStats() {}
public RefreshStats(StreamInput in) throws IOException {
total = in.readVLong();
totalTimeInMillis = in.readVLong();
if (in.getTransportVersion().onOrAfter(TransportVersions.V_7_2_0)) {
externalTotal = in.readVLong();
externalTotalTimeInMillis = in.readVLong();
}
externalTotal = in.readVLong();
externalTotalTimeInMillis = in.readVLong();
listeners = in.readVInt();
}

@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeVLong(total);
out.writeVLong(totalTimeInMillis);
if (out.getTransportVersion().onOrAfter(TransportVersions.V_7_2_0)) {
out.writeVLong(externalTotal);
out.writeVLong(externalTotalTimeInMillis);
}
out.writeVLong(externalTotal);
out.writeVLong(externalTotalTimeInMillis);
out.writeVInt(listeners);
}

Expand Down
42 changes: 21 additions & 21 deletions server/src/test/java/org/elasticsearch/TransportVersionTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,27 @@
public class TransportVersionTests extends ESTestCase {

public void testVersionComparison() {
TransportVersion V_7_2_0 = TransportVersions.V_7_2_0;
TransportVersion V_8_0_0 = TransportVersions.V_8_0_0;
assertThat(V_7_2_0.before(V_8_0_0), is(true));
assertThat(V_7_2_0.before(V_7_2_0), is(false));
assertThat(V_8_0_0.before(V_7_2_0), is(false));

assertThat(V_7_2_0.onOrBefore(V_8_0_0), is(true));
assertThat(V_7_2_0.onOrBefore(V_7_2_0), is(true));
assertThat(V_8_0_0.onOrBefore(V_7_2_0), is(false));

assertThat(V_7_2_0.after(V_8_0_0), is(false));
assertThat(V_7_2_0.after(V_7_2_0), is(false));
assertThat(V_8_0_0.after(V_7_2_0), is(true));

assertThat(V_7_2_0.onOrAfter(V_8_0_0), is(false));
assertThat(V_7_2_0.onOrAfter(V_7_2_0), is(true));
assertThat(V_8_0_0.onOrAfter(V_7_2_0), is(true));

assertThat(V_7_2_0, is(lessThan(V_8_0_0)));
assertThat(V_7_2_0.compareTo(V_7_2_0), is(0));
assertThat(V_8_0_0, is(greaterThan(V_7_2_0)));
TransportVersion V_8_2_0 = TransportVersions.V_8_2_0;
TransportVersion V_8_16_0 = TransportVersions.V_8_16_0;
assertThat(V_8_2_0.before(V_8_16_0), is(true));
assertThat(V_8_2_0.before(V_8_2_0), is(false));
assertThat(V_8_16_0.before(V_8_2_0), is(false));

assertThat(V_8_2_0.onOrBefore(V_8_16_0), is(true));
assertThat(V_8_2_0.onOrBefore(V_8_2_0), is(true));
assertThat(V_8_16_0.onOrBefore(V_8_2_0), is(false));

assertThat(V_8_2_0.after(V_8_16_0), is(false));
assertThat(V_8_2_0.after(V_8_2_0), is(false));
assertThat(V_8_16_0.after(V_8_2_0), is(true));

assertThat(V_8_2_0.onOrAfter(V_8_16_0), is(false));
assertThat(V_8_2_0.onOrAfter(V_8_2_0), is(true));
assertThat(V_8_16_0.onOrAfter(V_8_2_0), is(true));

assertThat(V_8_2_0, is(lessThan(V_8_16_0)));
assertThat(V_8_2_0.compareTo(V_8_2_0), is(0));
assertThat(V_8_16_0, is(greaterThan(V_8_2_0)));
}

public static class CorrectFakeVersion {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,7 @@ public void testBwcSerialization() throws Exception {
|| request.indicesOptions().expandWildcardsHidden()) {
assertEquals(request.indicesOptions(), indicesOptions);
}
if (in.getTransportVersion().onOrAfter(TransportVersions.V_7_2_0)) {
assertEquals(request.waitForActiveShards(), ActiveShardCount.readFrom(in));
} else {
assertEquals(0, in.available());
}
assertEquals(request.waitForActiveShards(), ActiveShardCount.readFrom(in));
}
}
}
Expand All @@ -85,9 +81,7 @@ public void testBwcSerialization() throws Exception {
out.writeTimeValue(sample.ackTimeout());
out.writeStringArray(sample.indices());
sample.indicesOptions().writeIndicesOptions(out);
if (out.getTransportVersion().onOrAfter(TransportVersions.V_7_2_0)) {
sample.waitForActiveShards().writeTo(out);
}
sample.waitForActiveShards().writeTo(out);

final CloseIndexRequest deserializedRequest;
try (StreamInput in = out.bytes().streamInput()) {
Expand All @@ -105,11 +99,7 @@ public void testBwcSerialization() throws Exception {
if (out.getTransportVersion().onOrAfter(TransportVersions.V_7_7_0) || sample.indicesOptions().expandWildcardsHidden()) {
assertEquals(sample.indicesOptions(), deserializedRequest.indicesOptions());
}
if (out.getTransportVersion().onOrAfter(TransportVersions.V_7_2_0)) {
assertEquals(sample.waitForActiveShards(), deserializedRequest.waitForActiveShards());
} else {
assertEquals(ActiveShardCount.NONE, deserializedRequest.waitForActiveShards());
}
assertEquals(sample.waitForActiveShards(), deserializedRequest.waitForActiveShards());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,13 @@
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.store.Directory;
import org.elasticsearch.TransportVersions;
import org.elasticsearch.action.termvectors.TermVectorsRequest.Flag;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.io.stream.InputStreamStreamInput;
import org.elasticsearch.common.io.stream.OutputStreamStreamOutput;
import org.elasticsearch.core.RestApiVersion;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.rest.action.document.RestTermVectorsAction;
import org.elasticsearch.tasks.TaskId;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.StreamsUtils;
import org.elasticsearch.xcontent.XContentParser;
Expand Down Expand Up @@ -247,52 +244,6 @@ public void testStreamRequest() throws IOException {
}
}

public void testStreamRequestLegacyVersion() throws IOException {
for (int i = 0; i < 10; i++) {
TermVectorsRequest request = new TermVectorsRequest("index", "id");
request.offsets(random().nextBoolean());
request.fieldStatistics(random().nextBoolean());
request.payloads(random().nextBoolean());
request.positions(random().nextBoolean());
request.termStatistics(random().nextBoolean());
String pref = random().nextBoolean() ? "somePreference" : null;
request.preference(pref);
request.doc(new BytesArray("{}"), randomBoolean(), XContentType.JSON);

// write using older version which contains types
ByteArrayOutputStream outBuffer = new ByteArrayOutputStream();
OutputStreamStreamOutput out = new OutputStreamStreamOutput(outBuffer);
out.setTransportVersion(TransportVersions.V_7_2_0);
request.writeTo(out);

// First check the type on the stream was written as "_doc" by manually parsing the stream until the type
ByteArrayInputStream esInBuffer = new ByteArrayInputStream(outBuffer.toByteArray());
InputStreamStreamInput esBuffer = new InputStreamStreamInput(esInBuffer);
TaskId.readFromStream(esBuffer);
if (esBuffer.readBoolean()) {
new ShardId(esBuffer);
}
esBuffer.readOptionalString();
assertThat(esBuffer.readString(), equalTo("_doc"));

// now read the stream as normal to check it is parsed correct if received from an older node
esInBuffer = new ByteArrayInputStream(outBuffer.toByteArray());
esBuffer = new InputStreamStreamInput(esInBuffer);
esBuffer.setTransportVersion(TransportVersions.V_7_2_0);
TermVectorsRequest req2 = new TermVectorsRequest(esBuffer);

assertThat(request.offsets(), equalTo(req2.offsets()));
assertThat(request.fieldStatistics(), equalTo(req2.fieldStatistics()));
assertThat(request.payloads(), equalTo(req2.payloads()));
assertThat(request.positions(), equalTo(req2.positions()));
assertThat(request.termStatistics(), equalTo(req2.termStatistics()));
assertThat(request.preference(), equalTo(pref));
assertThat(request.routing(), equalTo(null));
assertEquals(new BytesArray("{}"), request.doc());
assertEquals(XContentType.JSON, request.xContentType());
}
}

public void testMultiParser() throws Exception {
byte[] bytes = StreamsUtils.copyToBytesFromClasspath("/org/elasticsearch/action/termvectors/multiRequest1.json");
try (XContentParser parser = createParser(JsonXContent.jsonXContent, bytes)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/
package org.elasticsearch.xpack.core.security.action.rolemapping;

import org.elasticsearch.TransportVersions;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.support.WriteRequest;
Expand Down Expand Up @@ -48,9 +47,7 @@ public PutRoleMappingRequest(StreamInput in) throws IOException {
this.name = in.readString();
this.enabled = in.readBoolean();
this.roles = in.readStringCollectionAsList();
if (in.getTransportVersion().onOrAfter(TransportVersions.V_7_2_0)) {
this.roleTemplates = in.readCollectionAsList(TemplateRoleName::new);
}
this.roleTemplates = in.readCollectionAsList(TemplateRoleName::new);
this.rules = ExpressionParser.readExpression(in);
this.metadata = in.readGenericMap();
this.refreshPolicy = RefreshPolicy.readFrom(in);
Expand Down Expand Up @@ -165,9 +162,7 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeString(name);
out.writeBoolean(enabled);
out.writeStringCollection(roles);
if (out.getTransportVersion().onOrAfter(TransportVersions.V_7_2_0)) {
out.writeCollection(roleTemplates);
}
out.writeCollection(roleTemplates);
ExpressionParser.writeExpression(rules, out);
out.writeGenericMap(metadata);
refreshPolicy.writeTo(out);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@

package org.elasticsearch.xpack.core.transform.transforms.pivot;

import org.elasticsearch.TransportVersions;
import org.elasticsearch.common.Rounding;
import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.Writeable.Reader;
import org.elasticsearch.common.time.DateFormatter;
import org.elasticsearch.common.time.DateFormatters;
Expand All @@ -19,7 +16,6 @@
import org.elasticsearch.test.AbstractXContentSerializingTestCase;
import org.elasticsearch.xcontent.XContentParser;
import org.elasticsearch.xpack.core.transform.TransformConfigVersion;
import org.elasticsearch.xpack.core.transform.utils.TransformConfigVersionUtils;

import java.io.IOException;
import java.time.ZoneOffset;
Expand Down Expand Up @@ -96,23 +92,6 @@ public static DateHistogramGroupSource randomDateHistogramGroupSource(
return dateHistogramGroupSource;
}

public void testBackwardsSerialization72() throws IOException {
// version 7.7 introduced scripts, so test before that
DateHistogramGroupSource groupSource = randomDateHistogramGroupSource(
TransformConfigVersionUtils.randomVersionBetween(random(), TransformConfigVersion.V_7_3_0, TransformConfigVersion.V_7_6_2)
);

try (BytesStreamOutput output = new BytesStreamOutput()) {
output.setTransportVersion(TransportVersions.V_7_2_0);
groupSource.writeTo(output);
try (StreamInput in = output.bytes().streamInput()) {
in.setTransportVersion(TransportVersions.V_7_2_0);
DateHistogramGroupSource streamedGroupSource = new DateHistogramGroupSource(in);
assertEquals(groupSource, streamedGroupSource);
}
}
}

@Override
protected DateHistogramGroupSource doParseInstance(XContentParser parser) throws IOException {
return DateHistogramGroupSource.fromXContent(parser, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,9 @@

package org.elasticsearch.xpack.security.authc;

import org.elasticsearch.TransportVersion;
import org.elasticsearch.TransportVersions;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.io.stream.ByteBufferStreamInput;
import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.test.AbstractWireSerializingTestCase;
import org.elasticsearch.test.TransportVersionUtils;
import org.elasticsearch.xpack.core.XPackClientPlugin;
import org.elasticsearch.xpack.core.security.authc.support.mapper.ExpressionRoleMapping;
import org.elasticsearch.xpack.core.security.authz.RoleMappingMetadata;
Expand Down Expand Up @@ -60,21 +52,6 @@ protected NamedWriteableRegistry getNamedWriteableRegistry() {
return new NamedWriteableRegistry(new XPackClientPlugin().getNamedWriteables());
}

public void testSerializationBWC() throws IOException {
RoleMappingMetadata original = new RoleMappingMetadata(randomSet(0, 3, () -> randomRoleMapping(true)));
TransportVersion version = TransportVersionUtils.randomVersionBetween(random(), TransportVersions.V_7_2_0, null);
BytesStreamOutput output = new BytesStreamOutput();
output.setTransportVersion(version);
original.writeTo(output);
StreamInput streamInput = new NamedWriteableAwareStreamInput(
ByteBufferStreamInput.wrap(BytesReference.toBytes(output.bytes())),
new NamedWriteableRegistry(new XPackClientPlugin().getNamedWriteables())
);
streamInput.setTransportVersion(version);
RoleMappingMetadata deserialized = new RoleMappingMetadata(streamInput);
assertEquals(original, deserialized);
}

public void testEquals() {
Set<ExpressionRoleMapping> roleMappings1 = randomSet(0, 3, () -> randomRoleMapping(true));
Set<ExpressionRoleMapping> roleMappings2 = randomSet(0, 3, () -> randomRoleMapping(true));
Expand Down
Loading

0 comments on commit a054bbc

Please sign in to comment.