Skip to content

Commit

Permalink
Constants for TransportVersion currently live alongeside the class de…
Browse files Browse the repository at this point in the history
…finition. This has been fine since there was only one set of constants. However, to support serverless, some constants will need to be defined elsewhere.

This commit moves the existing constants to a new holder class, TransportVersions. It is almost entirely mechanical, using IntelliJ move members. The only non mechanical part was slightly shifting how CURRENT is found, defining a LATEST in TransportVersions that is automatically calculated (since we already have it, no need to manually define it).
  • Loading branch information
rjernst committed Sep 6, 2023
1 parent 077aaf5 commit ea00d67
Show file tree
Hide file tree
Showing 750 changed files with 2,693 additions and 2,203 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
package org.elasticsearch.client.analytics;

import org.elasticsearch.TransportVersion;
import org.elasticsearch.TransportVersions;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.index.query.QueryRewriteContext;
Expand Down Expand Up @@ -125,6 +126,6 @@ public boolean equals(Object obj) {

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

import org.elasticsearch.TransportVersion;
import org.elasticsearch.TransportVersions;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.index.query.QueryRewriteContext;
Expand Down Expand Up @@ -102,6 +103,6 @@ protected AggregationBuilder shallowCopy(Builder factoriesBuilder, Map<String, O

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

import org.apache.lucene.search.IndexSearcher;
import org.elasticsearch.TransportVersion;
import org.elasticsearch.TransportVersions;
import org.elasticsearch.aggregations.bucket.adjacency.AdjacencyMatrixAggregator.KeyedFilter;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
Expand Down Expand Up @@ -262,6 +263,6 @@ public String getType() {

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

import org.elasticsearch.TransportVersion;
import org.elasticsearch.TransportVersions;
import org.elasticsearch.common.Rounding;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
Expand Down Expand Up @@ -122,15 +123,15 @@ public AutoDateHistogramAggregationBuilder(String name) {
public AutoDateHistogramAggregationBuilder(StreamInput in) throws IOException {
super(in);
numBuckets = in.readVInt();
if (in.getTransportVersion().onOrAfter(TransportVersion.V_7_3_0)) {
if (in.getTransportVersion().onOrAfter(TransportVersions.V_7_3_0)) {
minimumIntervalExpression = in.readOptionalString();
}
}

@Override
protected void innerWriteTo(StreamOutput out) throws IOException {
out.writeVInt(numBuckets);
if (out.getTransportVersion().onOrAfter(TransportVersion.V_7_3_0)) {
if (out.getTransportVersion().onOrAfter(TransportVersions.V_7_3_0)) {
out.writeOptionalString(minimumIntervalExpression);
}
}
Expand Down Expand Up @@ -268,7 +269,7 @@ public boolean equals(Object obj) {

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

public static class RoundingInfo implements Writeable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
package org.elasticsearch.aggregations.bucket.histogram;

import org.apache.lucene.util.PriorityQueue;
import org.elasticsearch.TransportVersion;
import org.elasticsearch.TransportVersions;
import org.elasticsearch.aggregations.bucket.histogram.AutoDateHistogramAggregationBuilder.RoundingInfo;
import org.elasticsearch.common.Rounding;
import org.elasticsearch.common.io.stream.StreamInput;
Expand Down Expand Up @@ -226,7 +226,7 @@ public InternalAutoDateHistogram(StreamInput in) throws IOException {
format = in.readNamedWriteable(DocValueFormat.class);
buckets = in.readCollectionAsList(stream -> new Bucket(stream, format));
this.targetBuckets = in.readVInt();
if (in.getTransportVersion().onOrAfter(TransportVersion.V_8_3_0)) {
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_3_0)) {
bucketInnerInterval = in.readVLong();
} else {
bucketInnerInterval = 1; // Calculated on merge.
Expand All @@ -239,7 +239,7 @@ protected void doWriteTo(StreamOutput out) throws IOException {
out.writeNamedWriteable(format);
out.writeCollection(buckets);
out.writeVInt(targetBuckets);
if (out.getTransportVersion().onOrAfter(TransportVersion.V_8_3_0)) {
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_3_0)) {
out.writeVLong(bucketInnerInterval);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
package org.elasticsearch.aggregations.bucket.timeseries;

import org.elasticsearch.TransportVersion;
import org.elasticsearch.TransportVersions;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.search.aggregations.AbstractAggregationBuilder;
Expand Down Expand Up @@ -161,6 +162,6 @@ public int hashCode() {

@Override
public TransportVersion getMinimalSupportedVersion() {
return TransportVersion.V_8_1_0;
return TransportVersions.V_8_1_0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package org.elasticsearch.aggregations.metric;

import org.elasticsearch.TransportVersion;
import org.elasticsearch.TransportVersions;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.search.MultiValueMode;
Expand Down Expand Up @@ -55,14 +56,14 @@ public boolean supportsSampling() {
*/
public MatrixStatsAggregationBuilder(StreamInput in) throws IOException {
super(in);
if (in.getTransportVersion().onOrAfter(TransportVersion.V_8_7_0)) {
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_7_0)) {
multiValueMode = MultiValueMode.readMultiValueModeFrom(in);
}
}

@Override
protected void innerWriteTo(StreamOutput out) throws IOException {
if (out.getTransportVersion().onOrAfter(TransportVersion.V_8_7_0)) {
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_7_0)) {
multiValueMode.writeTo(out);
}
}
Expand Down Expand Up @@ -99,6 +100,6 @@ public String getType() {

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

import org.elasticsearch.TransportVersion;
import org.elasticsearch.TransportVersions;
import org.elasticsearch.common.ParsingException;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
Expand Down Expand Up @@ -215,6 +216,6 @@ public String getWriteableName() {

@Override
public TransportVersion getMinimalSupportedVersion() {
return TransportVersion.ZERO;
return TransportVersions.ZERO;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package org.elasticsearch.aggregations.pipeline;

import org.elasticsearch.TransportVersion;
import org.elasticsearch.TransportVersions;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.search.aggregations.pipeline.AbstractPipelineAggregationBuilder;
Expand Down Expand Up @@ -194,6 +195,6 @@ public String getWriteableName() {

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

import org.elasticsearch.TransportVersion;
import org.elasticsearch.TransportVersions;
import org.elasticsearch.common.ParsingException;
import org.elasticsearch.common.Rounding;
import org.elasticsearch.common.io.stream.StreamInput;
Expand Down Expand Up @@ -257,6 +258,6 @@ public String getWriteableName() {

@Override
public TransportVersion getMinimalSupportedVersion() {
return TransportVersion.V_7_4_0;
return TransportVersions.V_7_4_0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
package org.elasticsearch.aggregations.pipeline;

import org.elasticsearch.TransportVersion;
import org.elasticsearch.TransportVersions;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
Expand Down Expand Up @@ -240,6 +241,6 @@ public String getWriteableName() {

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

import org.elasticsearch.TransportVersion;
import org.elasticsearch.TransportVersions;
import org.elasticsearch.aggregations.bucket.AggregationMultiBucketAggregationTestCase;
import org.elasticsearch.aggregations.bucket.histogram.AutoDateHistogramAggregationBuilder.RoundingInfo;
import org.elasticsearch.aggregations.bucket.histogram.InternalAutoDateHistogram.BucketInfo;
Expand Down Expand Up @@ -477,8 +478,8 @@ public void testSerializationPre830() throws IOException {
);
TransportVersion version = TransportVersionUtils.randomVersionBetween(
random(),
TransportVersion.MINIMUM_COMPATIBLE,
TransportVersionUtils.getPreviousVersion(TransportVersion.V_8_3_0)
TransportVersions.MINIMUM_COMPATIBLE,
TransportVersionUtils.getPreviousVersion(TransportVersions.V_8_3_0)
);
InternalAutoDateHistogram deserialized = copyInstance(instance, version);
assertEquals(1, deserialized.getBucketInnerInterval());
Expand All @@ -504,7 +505,7 @@ public void testReadFromPre830() throws IOException {
+ "AAyAAAAZAF5BHllYXIAAARib29sAQAAAAAAAAAKZAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
);
try (StreamInput in = new NamedWriteableAwareStreamInput(new BytesArray(bytes).streamInput(), getNamedWriteableRegistry())) {
in.setTransportVersion(TransportVersion.V_8_2_0);
in.setTransportVersion(TransportVersions.V_8_2_0);
InternalAutoDateHistogram deserialized = new InternalAutoDateHistogram(in);
assertEquals("name", deserialized.getName());
assertEquals(1, deserialized.getBucketInnerInterval());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
package org.elasticsearch.ingest.common;

import org.elasticsearch.TransportVersion;
import org.elasticsearch.TransportVersions;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionRequestValidationException;
Expand Down Expand Up @@ -61,7 +61,7 @@ public Request(boolean sorted, String ecsCompatibility) {
Request(StreamInput in) throws IOException {
super(in);
this.sorted = in.readBoolean();
this.ecsCompatibility = in.getTransportVersion().onOrAfter(TransportVersion.V_8_0_0)
this.ecsCompatibility = in.getTransportVersion().onOrAfter(TransportVersions.V_8_0_0)
? in.readString()
: GrokProcessor.DEFAULT_ECS_COMPATIBILITY_MODE;
}
Expand All @@ -75,7 +75,7 @@ public ActionRequestValidationException validate() {
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeBoolean(sorted);
if (out.getTransportVersion().onOrAfter(TransportVersion.V_8_0_0)) {
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_0_0)) {
out.writeString(ecsCompatibility);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
package org.elasticsearch.ingest.geoip;

import org.elasticsearch.TransportVersion;
import org.elasticsearch.TransportVersions;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.persistent.PersistentTaskParams;
Expand Down Expand Up @@ -42,7 +43,7 @@ public String getWriteableName() {

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

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
package org.elasticsearch.ingest.geoip;

import org.elasticsearch.TransportVersion;
import org.elasticsearch.TransportVersions;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.VersionedNamedWriteable;
Expand Down Expand Up @@ -122,7 +123,7 @@ public String getWriteableName() {

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

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

package org.elasticsearch.ingest.geoip.stats;

import org.elasticsearch.TransportVersion;
import org.elasticsearch.TransportVersions;
import org.elasticsearch.action.ActionType;
import org.elasticsearch.action.FailedNodeException;
import org.elasticsearch.action.support.nodes.BaseNodeResponse;
Expand Down Expand Up @@ -166,7 +166,7 @@ protected NodeResponse(StreamInput in) throws IOException {
stats = in.readBoolean() ? new GeoIpDownloaderStats(in) : null;
databases = in.readCollectionAsImmutableSet(StreamInput::readString);
filesInTemp = in.readCollectionAsImmutableSet(StreamInput::readString);
configDatabases = in.getTransportVersion().onOrAfter(TransportVersion.V_8_0_0)
configDatabases = in.getTransportVersion().onOrAfter(TransportVersions.V_8_0_0)
? in.readCollectionAsImmutableSet(StreamInput::readString)
: null;
}
Expand Down Expand Up @@ -210,7 +210,7 @@ public void writeTo(StreamOutput out) throws IOException {
}
out.writeStringCollection(databases);
out.writeStringCollection(filesInTemp);
if (out.getTransportVersion().onOrAfter(TransportVersion.V_8_0_0)) {
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_0_0)) {
out.writeStringCollection(configDatabases);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

package org.elasticsearch.script.mustache;

import org.elasticsearch.TransportVersion;
import org.elasticsearch.TransportVersions;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.common.Strings;
Expand Down Expand Up @@ -206,7 +206,7 @@ public void testCCSCheckCompatibility() throws Exception {
"[fail_before_current_version] was released first in version %s, failed compatibility "
+ "check trying to send it to node with version %s",
FailBeforeCurrentVersionQueryBuilder.FUTURE_VERSION,
TransportVersion.MINIMUM_CCS_VERSION
TransportVersions.MINIMUM_CCS_VERSION
);
String actualCause = ex.getCause().getMessage();
assertEquals(expectedCause, actualCause);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.TransportVersion;
import org.elasticsearch.TransportVersions;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.action.search.MultiSearchResponse;
import org.elasticsearch.common.Strings;
Expand Down Expand Up @@ -102,7 +102,7 @@ public String toString() {
MultiSearchTemplateResponse(StreamInput in) throws IOException {
super(in);
items = in.readArray(Item::new, Item[]::new);
if (in.getTransportVersion().onOrAfter(TransportVersion.V_7_0_0)) {
if (in.getTransportVersion().onOrAfter(TransportVersions.V_7_0_0)) {
tookInMillis = in.readVLong();
} else {
tookInMillis = -1L;
Expand Down Expand Up @@ -136,7 +136,7 @@ public TimeValue getTook() {
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeArray(items);
if (out.getTransportVersion().onOrAfter(TransportVersion.V_7_0_0)) {
if (out.getTransportVersion().onOrAfter(TransportVersions.V_7_0_0)) {
out.writeVLong(tookInMillis);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.apache.lucene.search.MatchNoDocsQuery;
import org.apache.lucene.search.Query;
import org.elasticsearch.TransportVersion;
import org.elasticsearch.TransportVersions;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.index.mapper.MappedFieldType;
Expand Down Expand Up @@ -414,6 +415,6 @@ protected int doHashCode() {

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

0 comments on commit ea00d67

Please sign in to comment.