Skip to content

Commit 8d9f038

Browse files
authored
More 9.2 migrations (#133844)
More transport version migrations for 9.2 ES-12334
1 parent d4fce99 commit 8d9f038

File tree

7 files changed

+19
-13
lines changed

7 files changed

+19
-13
lines changed

server/src/main/java/org/elasticsearch/TransportVersions.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,6 @@ static TransportVersion def(int id) {
353353
public static final TransportVersion ML_INFERENCE_LLAMA_ADDED = def(9_125_0_00);
354354
public static final TransportVersion SHARD_WRITE_LOAD_IN_CLUSTER_INFO = def(9_126_0_00);
355355
public static final TransportVersion ESQL_SAMPLE_OPERATOR_STATUS = def(9_127_0_00);
356-
public static final TransportVersion ALLOCATION_DECISION_NOT_PREFERRED = def(9_145_0_00);
357-
public static final TransportVersion ESQL_QUALIFIERS_IN_ATTRIBUTES = def(9_146_0_00);
358356
public static final TransportVersion PROJECT_RESERVED_STATE_MOVE_TO_REGISTRY = def(9_147_0_00);
359357

360358
/*

server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/Decision.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

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

12-
import org.elasticsearch.TransportVersions;
12+
import org.elasticsearch.TransportVersion;
1313
import org.elasticsearch.common.io.stream.StreamInput;
1414
import org.elasticsearch.common.io.stream.StreamOutput;
1515
import org.elasticsearch.common.io.stream.Writeable;
@@ -115,8 +115,12 @@ enum Type implements Writeable {
115115
NOT_PREFERRED,
116116
YES;
117117

118+
private static final TransportVersion ALLOCATION_DECISION_NOT_PREFERRED = TransportVersion.fromName(
119+
"allocation_decision_not_preferred"
120+
);
121+
118122
public static Type readFrom(StreamInput in) throws IOException {
119-
if (in.getTransportVersion().onOrAfter(TransportVersions.ALLOCATION_DECISION_NOT_PREFERRED)) {
123+
if (in.getTransportVersion().supports(ALLOCATION_DECISION_NOT_PREFERRED)) {
120124
return in.readEnum(Type.class);
121125
} else {
122126
int i = in.readVInt();
@@ -138,7 +142,7 @@ public static Type min(Type a, Type b) {
138142

139143
@Override
140144
public void writeTo(StreamOutput out) throws IOException {
141-
if (out.getTransportVersion().onOrAfter(TransportVersions.ALLOCATION_DECISION_NOT_PREFERRED)) {
145+
if (out.getTransportVersion().supports(ALLOCATION_DECISION_NOT_PREFERRED)) {
142146
out.writeEnum(this);
143147
} else {
144148
out.writeVInt(switch (this) {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
9145000
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
9146000
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
esql_lookup_operator_emitted_rows,9144000
1+
esql_qualifiers_in_attributes,9146000

x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import java.util.Objects;
1919

2020
import static java.util.Collections.emptyList;
21-
import static org.elasticsearch.TransportVersions.ESQL_QUALIFIERS_IN_ATTRIBUTES;
2221

2322
/**
2423
* {@link Expression}s that can be materialized and describe properties of the derived table.
@@ -38,6 +37,8 @@ public abstract class Attribute extends NamedExpression {
3837
*/
3938
protected static final String SYNTHETIC_ATTRIBUTE_NAME_PREFIX = "$$";
4039

40+
private static final TransportVersion ESQL_QUALIFIERS_IN_ATTRIBUTES = TransportVersion.fromName("esql_qualifiers_in_attributes");
41+
4142
// can the attr be null
4243
private final Nullability nullability;
4344
private final String qualifier;
@@ -204,7 +205,7 @@ public static boolean dataTypeEquals(List<Attribute> left, List<Attribute> right
204205
public abstract boolean isDimension();
205206

206207
protected void checkAndSerializeQualifier(PlanStreamOutput out, TransportVersion version) throws IOException {
207-
if (version.onOrAfter(ESQL_QUALIFIERS_IN_ATTRIBUTES)) {
208+
if (version.supports(ESQL_QUALIFIERS_IN_ATTRIBUTES)) {
208209
out.writeOptionalCachedString(qualifier());
209210
} else if (qualifier() != null) {
210211
// Non-null qualifier means the query specifically defined one. Old nodes don't know what to do with it and just writing
@@ -215,7 +216,7 @@ protected void checkAndSerializeQualifier(PlanStreamOutput out, TransportVersion
215216
}
216217

217218
protected static String readQualifier(PlanStreamInput in, TransportVersion version) throws IOException {
218-
if (version.onOrAfter(ESQL_QUALIFIERS_IN_ATTRIBUTES)) {
219+
if (version.supports(ESQL_QUALIFIERS_IN_ATTRIBUTES)) {
219220
return in.readOptionalCachedString();
220221
}
221222
return null;

x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/ReferenceAttribute.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77
package org.elasticsearch.xpack.esql.core.expression;
88

9+
import org.elasticsearch.TransportVersion;
910
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
1011
import org.elasticsearch.common.io.stream.StreamInput;
1112
import org.elasticsearch.common.io.stream.StreamOutput;
@@ -18,8 +19,6 @@
1819

1920
import java.io.IOException;
2021

21-
import static org.elasticsearch.TransportVersions.ESQL_QUALIFIERS_IN_ATTRIBUTES;
22-
2322
/**
2423
* Attribute based on a reference to an expression.
2524
*/
@@ -30,6 +29,8 @@ public class ReferenceAttribute extends TypedAttribute {
3029
ReferenceAttribute::readFrom
3130
);
3231

32+
private static final TransportVersion ESQL_QUALIFIERS_IN_ATTRIBUTES = TransportVersion.fromName("esql_qualifiers_in_attributes");
33+
3334
@Deprecated
3435
/**
3536
* Only used for tests
@@ -61,7 +62,7 @@ public void writeTo(StreamOutput out) throws IOException {
6162
out.writeString(name());
6263
dataType().writeTo(out);
6364
checkAndSerializeQualifier((PlanStreamOutput) out, out.getTransportVersion());
64-
if (out.getTransportVersion().before(ESQL_QUALIFIERS_IN_ATTRIBUTES)) {
65+
if (out.getTransportVersion().supports(ESQL_QUALIFIERS_IN_ATTRIBUTES) == false) {
6566
// We used to always serialize a null qualifier here, so do the same for bwc.
6667
out.writeOptionalString(null);
6768
}
@@ -89,7 +90,7 @@ private static ReferenceAttribute innerReadFrom(StreamInput in) throws IOExcepti
8990
String name = in.readString();
9091
DataType dataType = DataType.readFrom(in);
9192
String qualifier = readQualifier((PlanStreamInput) in, in.getTransportVersion());
92-
if (in.getTransportVersion().before(ESQL_QUALIFIERS_IN_ATTRIBUTES)) {
93+
if (in.getTransportVersion().supports(ESQL_QUALIFIERS_IN_ATTRIBUTES) == false) {
9394
in.readOptionalString();
9495
}
9596
Nullability nullability = in.readEnum(Nullability.class);

0 commit comments

Comments
 (0)