Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 0 additions & 3 deletions server/src/main/java/org/elasticsearch/TransportVersions.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ static TransportVersion def(int id) {
public static final TransportVersion V_7_8_1 = def(7_08_01_99);
public static final TransportVersion V_7_9_0 = def(7_09_00_99);
public static final TransportVersion V_7_10_0 = def(7_10_00_99);
public static final TransportVersion V_7_17_0 = def(7_17_00_99);
public static final TransportVersion V_7_17_1 = def(7_17_01_99);
public static final TransportVersion V_7_17_8 = def(7_17_08_99);
public static final TransportVersion V_8_0_0 = def(8_00_00_99);
public static final TransportVersion V_8_1_0 = def(8_01_00_99);
public static final TransportVersion V_8_2_0 = def(8_02_00_99);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,6 @@ public void writeTo(StreamOutput out) throws IOException {
if (out.getTransportVersion().before(TransportVersions.V_8_2_0)) {
// no compatible version cares about the shard ID, we can just make one up
FAKE_SHARD_ID.writeTo(out);

// NB only checked this for versions back to 7.17.0, we are assuming that we don't use this with earlier versions:
assert out.getTransportVersion().onOrAfter(TransportVersions.V_7_17_0) : out.getTransportVersion();
}
metadataSnapshot.writeTo(out);
out.writeCollection(peerRecoveryRetentionLeases);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,9 @@ private static String generateKey(BytesRef from, BytesRef to, DocValueFormat for
}

private static Bucket createFromStream(StreamInput in, DocValueFormat format) throws IOException {
// NOTE: the key is required in version == 8.0.0 and version <= 7.17.0,
// NOTE: the key is required in version == 8.0.0,
// while it is optional for all subsequent versions.
String key = in.getTransportVersion().equals(TransportVersions.V_8_0_0) ? in.readString()
: in.getTransportVersion().onOrAfter(TransportVersions.V_7_17_1) ? in.readOptionalString()
: in.readString();
String key = in.getTransportVersion().equals(TransportVersions.V_8_0_0) ? in.readString() : in.readOptionalString();
BytesRef from = in.readOptional(StreamInput::readBytesRef);
BytesRef to = in.readOptional(StreamInput::readBytesRef);
long docCount = in.readLong();
Expand All @@ -75,10 +73,8 @@ private static Bucket createFromStream(StreamInput in, DocValueFormat format) th
public void writeTo(StreamOutput out) throws IOException {
if (out.getTransportVersion().equals(TransportVersions.V_8_0_0)) {
out.writeString(key == null ? generateKey(from, to, format) : key);
} else if (out.getTransportVersion().onOrAfter(TransportVersions.V_7_17_1)) {
out.writeOptionalString(key);
} else {
out.writeString(key == null ? generateKey(from, to, format) : key);
out.writeOptionalString(key);
}
out.writeOptional(StreamOutput::writeBytesRef, from);
out.writeOptional(StreamOutput::writeBytesRef, to);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,23 +138,17 @@ private static String generateKey(double from, double to, DocValueFormat format)

@Override
public void writeTo(StreamOutput out) throws IOException {
// NOTE: the key is required in version == 8.0.0 and version <= 7.17.0,
// NOTE: the key is required in version == 8.0.0,
// while it is optional for all subsequent versions.
if (out.getTransportVersion().equals(TransportVersions.V_8_0_0)) {
out.writeString(key == null ? generateKey(from, to, format) : key);
} else if (out.getTransportVersion().onOrAfter(TransportVersions.V_7_17_1)) {
out.writeOptionalString(key);
} else {
out.writeString(key == null ? generateKey(from, to, format) : key);
out.writeOptionalString(key);
}
out.writeDouble(from);
if (out.getTransportVersion().onOrAfter(TransportVersions.V_7_17_0)) {
out.writeOptionalDouble(from);
}
out.writeOptionalDouble(from);
out.writeDouble(to);
if (out.getTransportVersion().onOrAfter(TransportVersions.V_7_17_0)) {
out.writeOptionalDouble(to);
}
out.writeOptionalDouble(to);
out.writeVLong(docCount);
aggregations.writeTo(out);
}
Expand Down Expand Up @@ -236,28 +230,22 @@ public InternalRange(StreamInput in) throws IOException {
int size = in.readVInt();
List<B> ranges = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
// NOTE: the key is required in version == 8.0.0 and version <= 7.17.0,
// NOTE: the key is required in version == 8.0.0,
// while it is optional for all subsequent versions.
final String key = in.getTransportVersion().equals(TransportVersions.V_8_0_0) ? in.readString()
: in.getTransportVersion().onOrAfter(TransportVersions.V_7_17_1) ? in.readOptionalString()
: in.readString();
final String key = in.getTransportVersion().equals(TransportVersions.V_8_0_0) ? in.readString() : in.readOptionalString();
double from = in.readDouble();
if (in.getTransportVersion().onOrAfter(TransportVersions.V_7_17_0)) {
final Double originalFrom = in.readOptionalDouble();
if (originalFrom != null) {
from = originalFrom;
} else {
from = Double.NEGATIVE_INFINITY;
}
final Double originalFrom = in.readOptionalDouble();
if (originalFrom != null) {
from = originalFrom;
} else {
from = Double.NEGATIVE_INFINITY;
}
double to = in.readDouble();
if (in.getTransportVersion().onOrAfter(TransportVersions.V_7_17_0)) {
final Double originalTo = in.readOptionalDouble();
if (originalTo != null) {
to = originalTo;
} else {
to = Double.POSITIVE_INFINITY;
}
final Double originalTo = in.readOptionalDouble();
if (originalTo != null) {
to = originalTo;
} else {
to = Double.POSITIVE_INFINITY;
}
long docCount = in.readVLong();
InternalAggregations aggregations = InternalAggregations.readFrom(in);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import org.apache.lucene.search.ScoreMode;
import org.apache.lucene.search.ScorerSupplier;
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 @@ -176,8 +175,8 @@ public Range(StreamInput in) throws IOException {
toAsStr = in.readOptionalString();
from = in.readDouble();
to = in.readDouble();
originalFrom = in.getTransportVersion().onOrAfter(TransportVersions.V_7_17_0) ? in.readOptionalDouble() : Double.valueOf(from);
originalTo = in.getTransportVersion().onOrAfter(TransportVersions.V_7_17_0) ? in.readOptionalDouble() : Double.valueOf(to);
originalFrom = in.readOptionalDouble();
originalTo = in.readOptionalDouble();
}

@Override
Expand All @@ -187,10 +186,8 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeOptionalString(toAsStr);
out.writeDouble(from);
out.writeDouble(to);
if (out.getTransportVersion().onOrAfter(TransportVersions.V_7_17_0)) {
out.writeOptionalDouble(originalFrom);
out.writeOptionalDouble(originalTo);
}
out.writeOptionalDouble(originalFrom);
out.writeOptionalDouble(originalTo);
}

public double getFrom() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public String getWriteableName() {

@Override
public TransportVersion getMinimalSupportedVersion() {
return TransportVersions.V_7_17_0;
return TransportVersions.ZERO;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void testSerializationWithRemoteIndicesThrowsOnUnsupportedVersions() thro
);
final TransportVersion version = TransportVersionUtils.randomVersionBetween(
random(),
TransportVersions.V_7_17_0,
TransportVersions.V_8_0_0,
versionBeforeAdvancedRemoteClusterSecurity
);
out.setTransportVersion(version);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void testWriteToWithCrossClusterAccessThrowsOnUnsupportedVersion() throws
final BytesStreamOutput out = new BytesStreamOutput();
final TransportVersion version = TransportVersionUtils.randomVersionBetween(
random(),
TransportVersions.V_7_17_0,
TransportVersions.V_8_0_0,
TransportVersionUtils.getPreviousVersion(RemoteClusterPortSettings.TRANSPORT_VERSION_ADVANCED_REMOTE_CLUSTER_SECURITY)
);
out.setTransportVersion(version);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ public void testMaybeRewriteForOlderVersionWithCrossClusterAccessThrowsOnUnsuppo
);
final TransportVersion version = TransportVersionUtils.randomVersionBetween(
random(),
TransportVersions.V_7_17_0, // the minimum compatible version of 8.x
TransportVersions.V_8_0_0,
versionBeforeCrossClusterAccessRealm
);

Expand Down Expand Up @@ -958,7 +958,7 @@ public void testCopyWithFilteredMetadataFields() {
public void testMaybeRewriteForOlderVersionErasesDomainForVersionsBeforeDomains() {
final TransportVersion olderVersion = TransportVersionUtils.randomVersionBetween(
random(),
TransportVersions.V_7_17_0,
TransportVersions.V_8_0_0,
TransportVersionUtils.getPreviousVersion(Authentication.VERSION_REALM_DOMAINS)
);
final Authentication authentication = AuthenticationTestHelper.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ public void testSerializationWithRemoteIndicesWithElderVersion() throws IOExcept
final TransportVersion versionBeforeRemoteIndices = TransportVersionUtils.getPreviousVersion(TransportVersions.V_8_8_0);
final TransportVersion version = TransportVersionUtils.randomVersionBetween(
random(),
TransportVersions.V_7_17_0,
TransportVersions.V_8_0_0,
versionBeforeRemoteIndices
);
final BytesStreamOutput output = new BytesStreamOutput();
Expand Down Expand Up @@ -702,7 +702,7 @@ public void testSerializationWithRemoteClusterWithElderVersion() throws IOExcept
final TransportVersion versionBeforeRemoteCluster = TransportVersionUtils.getPreviousVersion(ROLE_REMOTE_CLUSTER_PRIVS);
final TransportVersion version = TransportVersionUtils.randomVersionBetween(
random(),
TransportVersions.V_7_17_0,
TransportVersions.V_8_0_0,
versionBeforeRemoteCluster
);
final BytesStreamOutput output = new BytesStreamOutput();
Expand Down Expand Up @@ -753,7 +753,7 @@ public void testSerializationWithWorkflowsRestrictionAndUnsupportedVersions() th
final TransportVersion versionBeforeWorkflowsRestriction = TransportVersionUtils.getPreviousVersion(WORKFLOWS_RESTRICTION_VERSION);
final TransportVersion version = TransportVersionUtils.randomVersionBetween(
random(),
TransportVersions.V_7_17_0,
TransportVersions.V_8_0_0,
versionBeforeWorkflowsRestriction
);
final BytesStreamOutput output = new BytesStreamOutput();
Expand Down Expand Up @@ -848,7 +848,7 @@ public void testSerializationWithDescriptionAndUnsupportedVersions() throws IOEx
final TransportVersion versionBeforeRoleDescription = TransportVersionUtils.getPreviousVersion(SECURITY_ROLE_DESCRIPTION);
final TransportVersion version = TransportVersionUtils.randomVersionBetween(
random(),
TransportVersions.V_7_17_0,
TransportVersions.V_8_0_0,
versionBeforeRoleDescription
);
final BytesStreamOutput output = new BytesStreamOutput();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,7 @@ public EqlSearchRequest(StreamInput in) throws IOException {
this.waitForCompletionTimeout = in.readOptionalTimeValue();
this.keepAlive = in.readOptionalTimeValue();
this.keepOnCompletion = in.readBoolean();
if (in.getTransportVersion().onOrAfter(TransportVersions.V_7_17_8)) {
resultPosition = in.readString();
}
resultPosition = in.readString();
if (in.readBoolean()) {
fetchFields = in.readCollectionAsList(FieldAndFormat::new);
}
Expand Down Expand Up @@ -484,9 +482,7 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeOptionalTimeValue(waitForCompletionTimeout);
out.writeOptionalTimeValue(keepAlive);
out.writeBoolean(keepOnCompletion);
if (out.getTransportVersion().onOrAfter(TransportVersions.V_7_17_8)) {
out.writeString(resultPosition);
}
out.writeString(resultPosition);
out.writeBoolean(fetchFields != null);
if (fetchFields != null) {
out.writeCollection(fetchFields);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ protected EqlSearchRequest mutateInstanceForVersion(EqlSearchRequest instance, T
mutatedInstance.keepOnCompletion(instance.keepOnCompletion());
mutatedInstance.fetchFields(instance.fetchFields());
mutatedInstance.runtimeMappings(instance.runtimeMappings());
mutatedInstance.resultPosition(version.onOrAfter(TransportVersions.V_7_17_8) ? instance.resultPosition() : "tail");
mutatedInstance.resultPosition(instance.resultPosition());
mutatedInstance.maxSamplesPerKey(version.onOrAfter(TransportVersions.V_8_7_0) ? instance.maxSamplesPerKey() : 1);
mutatedInstance.allowPartialSearchResults(
version.onOrAfter(TransportVersions.EQL_ALLOW_PARTIAL_SEARCH_RESULTS) ? instance.allowPartialSearchResults() : false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ public <T extends TransportResponse> void sendRequest(
);
final TransportVersion version = TransportVersionUtils.randomVersionBetween(
random(),
TransportVersions.V_7_17_0,
TransportVersions.V_8_0_0,
versionBeforeCrossClusterAccessRealm
);
when(connection.getTransportVersion()).thenReturn(version);
Expand Down