Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

package org.elasticsearch.script.mustache;

import org.elasticsearch.TransportVersions;
import org.elasticsearch.TransportVersion;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.common.Strings;
Expand Down Expand Up @@ -210,7 +210,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.toReleaseVersion(),
TransportVersions.MINIMUM_CCS_VERSION.toReleaseVersion()
TransportVersion.minimumCCSVersion().toReleaseVersion()
);
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,6 @@
package org.elasticsearch.search.msearch;

import org.elasticsearch.TransportVersion;
import org.elasticsearch.TransportVersions;
import org.elasticsearch.action.search.MultiSearchRequest;
import org.elasticsearch.action.search.MultiSearchResponse.Item;
import org.elasticsearch.common.settings.Settings;
Expand Down Expand Up @@ -93,7 +92,7 @@ public void testSimpleMultiSearchMoreRequests() throws Exception {
* TransportVersions.MINIMUM_CCS_VERSION works
*/
public void testCCSCheckCompatibility() throws Exception {
TransportVersion transportVersion = TransportVersionUtils.getNextVersion(TransportVersions.MINIMUM_CCS_VERSION, true);
TransportVersion transportVersion = TransportVersionUtils.getNextVersion(TransportVersion.minimumCCSVersion(), true);
createIndex("test");
ensureGreen();
prepareIndex("test").setId("1").setSource("field", "xxx").get();
Expand Down
16 changes: 14 additions & 2 deletions server/src/main/java/org/elasticsearch/TransportVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
* numbers. So the minimum compatible version is hard-coded as the transport version used by the highest minor release of the previous
* major version. {@link TransportVersions#MINIMUM_COMPATIBLE} should be updated appropriately whenever a major release happens.
* <p>
* The earliest CCS compatible version is hardcoded at {@link TransportVersions#MINIMUM_CCS_VERSION}, as the transport version used by the
* previous minor release. This should be updated appropriately whenever a minor release happens.
* The earliest CCS compatible version is hardcoded at {@link TransportVersion.VersionsHolder#MINIMUM_CCS_VERSION}, as the transport version
* used by the previous minor release. This should be updated appropriately whenever a minor release happens.
*
* <h2>Scope of usefulness of {@link TransportVersion}</h2>
* {@link TransportVersion} is a property of the transport connection between a pair of nodes, and should not be used as an indication of
Expand Down Expand Up @@ -274,6 +274,14 @@ public static TransportVersion current() {
return VersionsHolder.CURRENT;
}

/**
* Reference to the minimum transport version that can be used with CCS.
* This should be the transport version used by the previous minor release.
*/
public static TransportVersion minimumCCSVersion() {
return VersionsHolder.MINIMUM_CCS_VERSION;
}

/**
* Sorted list of all defined transport versions
*/
Expand Down Expand Up @@ -422,7 +430,9 @@ private static class VersionsHolder {
private static final Map<Integer, TransportVersion> ALL_VERSIONS_BY_ID;
private static final Map<String, TransportVersion> ALL_VERSIONS_BY_NAME;
private static final IntFunction<String> VERSION_LOOKUP_BY_RELEASE;

private static final TransportVersion CURRENT;
private static final TransportVersion MINIMUM_CCS_VERSION;

static {
// collect all the transport versions from server and es modules/plugins (defined in server)
Expand Down Expand Up @@ -460,7 +470,9 @@ private static class VersionsHolder {
ALL_VERSIONS = Collections.unmodifiableList(allVersions);
ALL_VERSIONS_BY_ID = ALL_VERSIONS.stream().collect(Collectors.toUnmodifiableMap(TransportVersion::id, Function.identity()));
ALL_VERSIONS_BY_NAME = Collections.unmodifiableMap(allVersionsByName);

CURRENT = ALL_VERSIONS.getLast();
MINIMUM_CCS_VERSION = ALL_VERSIONS_BY_ID.get(9112006);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a comment here that this is temporary? we need to move this to a resource file, but we'll need a new concept

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try to separate this specific issue out into a separate pr.

}

private static List<TransportVersion> addTransportVersions(Collection<TransportVersion> addFrom, List<TransportVersion> addTo) {
Expand Down
28 changes: 0 additions & 28 deletions server/src/main/java/org/elasticsearch/TransportVersions.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ static TransportVersion def(int id) {
public static final TransportVersion ML_INFERENCE_COHERE_API_VERSION_8_19 = def(8_841_0_60);
public static final TransportVersion ESQL_DOCUMENTS_FOUND_AND_VALUES_LOADED_8_19 = def(8_841_0_61);
public static final TransportVersion ESQL_PROFILE_INCLUDE_PLAN_8_19 = def(8_841_0_62);
public static final TransportVersion ESQL_FIXED_INDEX_LIKE_8_19 = def(8_841_0_64);
public static final TransportVersion INITIAL_ELASTICSEARCH_8_19_1 = def(8_841_0_65);
public static final TransportVersion INITIAL_ELASTICSEARCH_8_19_2 = def(8_841_0_66);
public static final TransportVersion INITIAL_ELASTICSEARCH_8_19_3 = def(8_841_0_67);
Expand Down Expand Up @@ -335,27 +334,6 @@ static TransportVersion def(int id) {
public static final TransportVersion ML_INFERENCE_COHERE_API_VERSION = def(9_110_0_00);
public static final TransportVersion ESQL_PROFILE_INCLUDE_PLAN = def(9_111_0_00);
public static final TransportVersion MAPPINGS_IN_DATA_STREAMS = def(9_112_0_00);
public static final TransportVersion ESQL_FIXED_INDEX_LIKE_9_1 = def(9_112_0_02);
public static final TransportVersion ESQL_SAMPLE_OPERATOR_STATUS_9_1 = def(9_112_0_03);
public static final TransportVersion INITIAL_ELASTICSEARCH_9_1_1 = def(9_112_0_04);
public static final TransportVersion INITIAL_ELASTICSEARCH_9_1_2 = def(9_112_0_05);
public static final TransportVersion INITIAL_ELASTICSEARCH_9_1_3 = def(9_112_0_06);
public static final TransportVersion INITIAL_ELASTICSEARCH_9_1_4 = def(9_112_0_07);
public static final TransportVersion PROJECT_STATE_REGISTRY_RECORDS_DELETIONS = def(9_113_0_00);
public static final TransportVersion ESQL_SERIALIZE_TIMESERIES_FIELD_TYPE = def(9_114_0_00);
public static final TransportVersion ML_INFERENCE_IBM_WATSONX_COMPLETION_ADDED = def(9_115_0_00);
public static final TransportVersion ESQL_LOCAL_RELATION_WITH_NEW_BLOCKS = def(9_117_0_00);
public static final TransportVersion ML_INFERENCE_CUSTOM_SERVICE_EMBEDDING_TYPE = def(9_118_0_00);
public static final TransportVersion ESQL_FIXED_INDEX_LIKE = def(9_119_0_00);
public static final TransportVersion LOOKUP_JOIN_CCS = def(9_120_0_00);
public static final TransportVersion NODE_USAGE_STATS_FOR_THREAD_POOLS_IN_CLUSTER_INFO = def(9_121_0_00);
public static final TransportVersion ESQL_CATEGORIZE_OPTIONS = def(9_122_0_00);
public static final TransportVersion ML_INFERENCE_AZURE_AI_STUDIO_RERANK_ADDED = def(9_123_0_00);
public static final TransportVersion PROJECT_STATE_REGISTRY_ENTRY = def(9_124_0_00);
public static final TransportVersion ML_INFERENCE_LLAMA_ADDED = def(9_125_0_00);
public static final TransportVersion SHARD_WRITE_LOAD_IN_CLUSTER_INFO = def(9_126_0_00);
public static final TransportVersion ESQL_SAMPLE_OPERATOR_STATUS = def(9_127_0_00);
public static final TransportVersion ALLOCATION_DECISION_NOT_PREFERRED = def(9_145_0_00);
public static final TransportVersion ESQL_QUALIFIERS_IN_ATTRIBUTES = def(9_146_0_00);

/*
Expand Down Expand Up @@ -419,12 +397,6 @@ static TransportVersion def(int id) {
*/
public static final TransportVersion MINIMUM_COMPATIBLE = INITIAL_ELASTICSEARCH_8_19;

/**
* Reference to the minimum transport version that can be used with CCS.
* This should be the transport version used by the previous minor release.
*/
public static final TransportVersion MINIMUM_CCS_VERSION = INITIAL_ELASTICSEARCH_9_1_3;

/**
* Sorted list of all versions defined in this class
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
package org.elasticsearch.action.search;

import org.apache.lucene.util.BytesRef;
import org.elasticsearch.TransportVersions;
import org.elasticsearch.TransportVersion;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.io.stream.InputStreamStreamInput;
Expand Down Expand Up @@ -127,14 +127,14 @@ private static SearchContextIdForNode innerReadSearchContextIdForNode(String con
*/
public static void checkCCSVersionCompatibility(Writeable writeableRequest) {
try {
writeableRequest.writeTo(new VersionCheckingStreamOutput(TransportVersions.MINIMUM_CCS_VERSION));
writeableRequest.writeTo(new VersionCheckingStreamOutput(TransportVersion.minimumCCSVersion()));
} catch (Exception e) {
// if we cannot serialize, raise this as an error to indicate to the caller that CCS has problems with this request
throw new IllegalArgumentException(
"["
+ writeableRequest.getClass()
+ "] is not compatible with version "
+ TransportVersions.MINIMUM_CCS_VERSION.toReleaseVersion()
+ TransportVersion.minimumCCSVersion().toReleaseVersion()
+ " and the '"
+ SearchService.CCS_VERSION_CHECK_SETTING.getKey()
+ "' setting is enabled.",
Expand Down
14 changes: 10 additions & 4 deletions server/src/main/java/org/elasticsearch/cluster/ClusterInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

package org.elasticsearch.cluster;

import org.elasticsearch.TransportVersion;
import org.elasticsearch.TransportVersions;
import org.elasticsearch.cluster.routing.RecoverySource;
import org.elasticsearch.cluster.routing.ShardRouting;
Expand Down Expand Up @@ -48,6 +49,11 @@ public class ClusterInfo implements ChunkedToXContent, Writeable {

public static final ClusterInfo EMPTY = new ClusterInfo();

private static final TransportVersion SHARD_WRITE_LOAD_IN_CLUSTER_INFO = TransportVersion.fromName("shard_write_load_in_cluster_info");
private static final TransportVersion NODE_USAGE_STATS_FOR_THREAD_POOLS_IN_CLUSTER_INFO = TransportVersion.fromName(
"node_usage_stats_for_thread_pools_in_cluster_info"
);

private final Map<String, DiskUsage> leastAvailableSpaceUsage;
private final Map<String, DiskUsage> mostAvailableSpaceUsage;
final Map<String, Long> shardSizes;
Expand Down Expand Up @@ -109,12 +115,12 @@ public ClusterInfo(StreamInput in) throws IOException {
} else {
this.estimatedHeapUsages = Map.of();
}
if (in.getTransportVersion().onOrAfter(TransportVersions.NODE_USAGE_STATS_FOR_THREAD_POOLS_IN_CLUSTER_INFO)) {
if (in.getTransportVersion().supports(NODE_USAGE_STATS_FOR_THREAD_POOLS_IN_CLUSTER_INFO)) {
this.nodeUsageStatsForThreadPools = in.readImmutableMap(NodeUsageStatsForThreadPools::new);
} else {
this.nodeUsageStatsForThreadPools = Map.of();
}
if (in.getTransportVersion().onOrAfter(TransportVersions.SHARD_WRITE_LOAD_IN_CLUSTER_INFO)) {
if (in.getTransportVersion().supports(SHARD_WRITE_LOAD_IN_CLUSTER_INFO)) {
this.shardWriteLoads = in.readImmutableMap(ShardId::new, StreamInput::readDouble);
} else {
this.shardWriteLoads = Map.of();
Expand All @@ -132,10 +138,10 @@ public void writeTo(StreamOutput out) throws IOException {
if (out.getTransportVersion().onOrAfter(TransportVersions.HEAP_USAGE_IN_CLUSTER_INFO)) {
out.writeMap(this.estimatedHeapUsages, StreamOutput::writeWriteable);
}
if (out.getTransportVersion().onOrAfter(TransportVersions.NODE_USAGE_STATS_FOR_THREAD_POOLS_IN_CLUSTER_INFO)) {
if (out.getTransportVersion().supports(NODE_USAGE_STATS_FOR_THREAD_POOLS_IN_CLUSTER_INFO)) {
out.writeMap(this.nodeUsageStatsForThreadPools, StreamOutput::writeWriteable);
}
if (out.getTransportVersion().onOrAfter(TransportVersions.SHARD_WRITE_LOAD_IN_CLUSTER_INFO)) {
if (out.getTransportVersion().supports(SHARD_WRITE_LOAD_IN_CLUSTER_INFO)) {
out.writeMap(this.shardWriteLoads, StreamOutput::writeWriteable, StreamOutput::writeDouble);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,14 @@
*/
public class ProjectStateRegistry extends AbstractNamedDiffable<Custom> implements Custom, NamedDiffable<Custom> {
public static final String TYPE = "projects_registry";
private static final TransportVersion PROJECT_STATE_REGISTRY_ENTRY = TransportVersion.fromName("project_state_registry_entry");
public static final ProjectStateRegistry EMPTY = new ProjectStateRegistry(Collections.emptyMap(), Collections.emptySet(), 0);
private static final Entry EMPTY_ENTRY = new Entry(Settings.EMPTY);

private static final TransportVersion PROJECT_STATE_REGISTRY_RECORDS_DELETIONS = TransportVersion.fromName(
"project_state_registry_records_deletions"
);

private final Map<ProjectId, Entry> projectsEntries;
// Projects that have been marked for deletion based on their file-based setting
private final Set<ProjectId> projectsMarkedForDeletion;
Expand All @@ -59,13 +64,13 @@ public static ProjectStateRegistry get(ClusterState clusterState) {
}

public ProjectStateRegistry(StreamInput in) throws IOException {
if (in.getTransportVersion().onOrAfter(TransportVersions.PROJECT_STATE_REGISTRY_ENTRY)) {
if (in.getTransportVersion().supports(PROJECT_STATE_REGISTRY_ENTRY)) {
projectsEntries = in.readMap(ProjectId::readFrom, Entry::readFrom);
} else {
Map<ProjectId, Settings> settingsMap = in.readMap(ProjectId::readFrom, Settings::readSettingsFromStream);
projectsEntries = settingsMap.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> new Entry(e.getValue())));
}
if (in.getTransportVersion().onOrAfter(TransportVersions.PROJECT_STATE_REGISTRY_RECORDS_DELETIONS)) {
if (in.getTransportVersion().supports(PROJECT_STATE_REGISTRY_RECORDS_DELETIONS)) {
projectsMarkedForDeletion = in.readCollectionAsImmutableSet(ProjectId::readFrom);
projectsMarkedForDeletionGeneration = in.readVLong();
} else {
Expand Down Expand Up @@ -135,7 +140,7 @@ public Iterator<? extends ToXContent> toXContentChunked(ToXContent.Params params
}

public static NamedDiff<Custom> readDiffFrom(StreamInput in) throws IOException {
if (in.getTransportVersion().onOrAfter(TransportVersions.PROJECT_STATE_REGISTRY_ENTRY)) {
if (in.getTransportVersion().supports(PROJECT_STATE_REGISTRY_ENTRY)) {
return new ProjectStateRegistryDiff(in);
}
return readDiffFrom(Custom.class, TYPE, in);
Expand All @@ -161,15 +166,15 @@ public TransportVersion getMinimalSupportedVersion() {

@Override
public void writeTo(StreamOutput out) throws IOException {
if (out.getTransportVersion().onOrAfter(TransportVersions.PROJECT_STATE_REGISTRY_ENTRY)) {
if (out.getTransportVersion().supports(PROJECT_STATE_REGISTRY_ENTRY)) {
out.writeMap(projectsEntries);
} else {
Map<ProjectId, Settings> settingsMap = projectsEntries.entrySet()
.stream()
.collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().settings()));
out.writeMap(settingsMap);
}
if (out.getTransportVersion().onOrAfter(TransportVersions.PROJECT_STATE_REGISTRY_RECORDS_DELETIONS)) {
if (out.getTransportVersion().supports(PROJECT_STATE_REGISTRY_RECORDS_DELETIONS)) {
out.writeCollection(projectsMarkedForDeletion);
out.writeVLong(projectsMarkedForDeletionGeneration);
} else {
Expand Down Expand Up @@ -261,7 +266,7 @@ static class ProjectStateRegistryDiff implements NamedDiff<Custom> {

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

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

package org.elasticsearch.cluster.routing.allocation.decider;

import org.elasticsearch.TransportVersions;
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 @@ -115,8 +115,12 @@ enum Type implements Writeable {
NOT_PREFERRED,
YES;

private static final TransportVersion ALLOCATION_DECISION_NOT_PREFERRED = TransportVersion.fromName(
"allocation_decision_not_preferred"
);

public static Type readFrom(StreamInput in) throws IOException {
if (in.getTransportVersion().onOrAfter(TransportVersions.ALLOCATION_DECISION_NOT_PREFERRED)) {
if (in.getTransportVersion().supports(ALLOCATION_DECISION_NOT_PREFERRED)) {
return in.readEnum(Type.class);
} else {
int i = in.readVInt();
Expand All @@ -138,7 +142,7 @@ public static Type min(Type a, Type b) {

@Override
public void writeTo(StreamOutput out) throws IOException {
if (out.getTransportVersion().onOrAfter(TransportVersions.ALLOCATION_DECISION_NOT_PREFERRED)) {
if (out.getTransportVersion().supports(ALLOCATION_DECISION_NOT_PREFERRED)) {
out.writeEnum(this);
} else {
out.writeVInt(switch (this) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public class WildcardQueryBuilder extends AbstractQueryBuilder<WildcardQueryBuil
private static final ParseField VALUE_FIELD = new ParseField("value");
private static final ParseField REWRITE_FIELD = new ParseField("rewrite");

private static final TransportVersion ESQL_FIXED_INDEX_LIKE = TransportVersion.fromName("esql_fixed_index_like");

private final String fieldName;

private final String value;
Expand Down Expand Up @@ -126,9 +128,7 @@ protected void doWriteTo(StreamOutput out) throws IOException {
* Returns true if the Transport version is compatible with ESQL_FIXED_INDEX_LIKE
*/
public static boolean expressionTransportSupported(TransportVersion version) {
return version.onOrAfter(TransportVersions.ESQL_FIXED_INDEX_LIKE)
|| version.isPatchFrom(TransportVersions.ESQL_FIXED_INDEX_LIKE_8_19)
|| version.isPatchFrom(TransportVersions.ESQL_FIXED_INDEX_LIKE_9_1);
return version.supports(ESQL_FIXED_INDEX_LIKE);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9145000
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9122000
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9119000,9112002,8841064
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9117000
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9127000,9112003
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9114000
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9120000
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9123000
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9118000
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9115000
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9125000
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9121000
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9124000
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9113000
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9126000
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9112004
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9112005
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9112006
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9112007
2 changes: 1 addition & 1 deletion server/src/main/resources/transport/upper_bounds/8.19.csv
Original file line number Diff line number Diff line change
@@ -1 +1 @@
esql_split_on_big_values,8841063
esql_fixed_index_like,8841064
2 changes: 1 addition & 1 deletion server/src/main/resources/transport/upper_bounds/9.1.csv
Original file line number Diff line number Diff line change
@@ -1 +1 @@
esql_split_on_big_values,9112001
initial_elasticsearch_9_1_4,9112007
2 changes: 1 addition & 1 deletion server/src/main/resources/transport/upper_bounds/9.2.csv
Original file line number Diff line number Diff line change
@@ -1 +1 @@
esql_lookup_operator_emitted_rows,9144000
allocation_decision_not_preferred,9145000
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
package org.elasticsearch.action.admin.indices.resolve;

import org.elasticsearch.TransportVersion;
import org.elasticsearch.TransportVersions;
import org.elasticsearch.action.support.ActionFilter;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.cluster.node.VersionInformation;
Expand Down Expand Up @@ -54,7 +53,7 @@ public void testCCSCompatibilityCheck() {
.build();
ActionFilters actionFilters = mock(ActionFilters.class);
when(actionFilters.filters()).thenReturn(new ActionFilter[0]);
TransportVersion nextTransportVersion = TransportVersionUtils.getNextVersion(TransportVersions.MINIMUM_CCS_VERSION, true);
TransportVersion nextTransportVersion = TransportVersionUtils.getNextVersion(TransportVersion.minimumCCSVersion(), true);
try {
TransportService transportService = MockTransportService.createNewService(
Settings.EMPTY,
Expand Down
Loading