Skip to content

Commit 8666136

Browse files
authored
Remove some references to Version.transportVersion (#93861)
1 parent dc04f6b commit 8666136

File tree

16 files changed

+58
-48
lines changed

16 files changed

+58
-48
lines changed

qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/DesiredNodesUpgradeIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ public void testUpgradeDesiredNodes() throws Exception {
4343
return;
4444
}
4545

46-
if (UPGRADE_FROM_VERSION.transportVersion.onOrAfter(Processors.DOUBLE_PROCESSORS_SUPPORT_VERSION)) {
46+
if (UPGRADE_FROM_VERSION.onOrAfter(Processors.DOUBLE_PROCESSORS_SUPPORT_VERSION)) {
4747
assertUpgradedNodesCanReadDesiredNodes();
48-
} else if (UPGRADE_FROM_VERSION.transportVersion.onOrAfter(DesiredNode.RANGE_FLOAT_PROCESSORS_SUPPORT_VERSION)) {
48+
} else if (UPGRADE_FROM_VERSION.onOrAfter(DesiredNode.RANGE_FLOAT_PROCESSORS_SUPPORT_VERSION)) {
4949
assertDesiredNodesUpdatedWithRoundedUpFloatsAreIdempotent();
5050
} else {
5151
assertDesiredNodesWithFloatProcessorsAreRejectedInOlderVersions();

server/src/main/java/org/elasticsearch/action/admin/cluster/desirednodes/TransportUpdateDesiredNodesAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ protected void masterOperation(
9595
@Override
9696
protected void doExecute(Task task, UpdateDesiredNodesRequest request, ActionListener<UpdateDesiredNodesResponse> listener) {
9797
final var minNodeVersion = clusterService.state().nodes().getMinNodeVersion();
98-
if (request.isCompatibleWithVersion(minNodeVersion.transportVersion) == false) {
98+
if (request.isCompatibleWithVersion(minNodeVersion) == false) {
9999
listener.onFailure(
100100
new IllegalArgumentException(
101101
"Unable to use processor ranges, floating-point (with greater precision) processors "

server/src/main/java/org/elasticsearch/action/admin/cluster/desirednodes/UpdateDesiredNodesRequest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
package org.elasticsearch.action.admin.cluster.desirednodes;
1010

1111
import org.elasticsearch.TransportVersion;
12+
import org.elasticsearch.Version;
1213
import org.elasticsearch.action.ActionRequestValidationException;
1314
import org.elasticsearch.action.ValidateActions;
1415
import org.elasticsearch.action.support.master.AcknowledgedRequest;
@@ -98,7 +99,7 @@ public boolean isDryRun() {
9899
return dryRun;
99100
}
100101

101-
public boolean isCompatibleWithVersion(TransportVersion version) {
102+
public boolean isCompatibleWithVersion(Version version) {
102103
if (version.onOrAfter(DesiredNode.RANGE_FLOAT_PROCESSORS_SUPPORT_VERSION)) {
103104
return true;
104105
}

server/src/main/java/org/elasticsearch/cluster/metadata/DesiredNode.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
import static org.elasticsearch.node.NodeRoleSettings.NODE_ROLES_SETTING;
4040

4141
public final class DesiredNode implements Writeable, ToXContentObject, Comparable<DesiredNode> {
42-
public static final TransportVersion RANGE_FLOAT_PROCESSORS_SUPPORT_VERSION = TransportVersion.V_8_3_0;
42+
public static final Version RANGE_FLOAT_PROCESSORS_SUPPORT_VERSION = Version.V_8_3_0;
43+
public static final TransportVersion RANGE_FLOAT_PROCESSORS_SUPPORT_TRANSPORT_VERSION = TransportVersion.V_8_3_0;
4344

4445
private static final ParseField SETTINGS_FIELD = new ParseField("settings");
4546
private static final ParseField PROCESSORS_FIELD = new ParseField("processors");
@@ -174,7 +175,7 @@ public static DesiredNode readFrom(StreamInput in) throws IOException {
174175
final var settings = Settings.readSettingsFromStream(in);
175176
final Processors processors;
176177
final ProcessorsRange processorsRange;
177-
if (in.getTransportVersion().onOrAfter(RANGE_FLOAT_PROCESSORS_SUPPORT_VERSION)) {
178+
if (in.getTransportVersion().onOrAfter(RANGE_FLOAT_PROCESSORS_SUPPORT_TRANSPORT_VERSION)) {
178179
processors = in.readOptionalWriteable(Processors::readFrom);
179180
processorsRange = in.readOptionalWriteable(ProcessorsRange::readFrom);
180181
} else {
@@ -190,7 +191,7 @@ public static DesiredNode readFrom(StreamInput in) throws IOException {
190191
@Override
191192
public void writeTo(StreamOutput out) throws IOException {
192193
settings.writeTo(out);
193-
if (out.getTransportVersion().onOrAfter(RANGE_FLOAT_PROCESSORS_SUPPORT_VERSION)) {
194+
if (out.getTransportVersion().onOrAfter(RANGE_FLOAT_PROCESSORS_SUPPORT_TRANSPORT_VERSION)) {
194195
out.writeOptionalWriteable(processors);
195196
out.writeOptionalWriteable(processorsRange);
196197
} else {
@@ -297,7 +298,7 @@ public Set<DiscoveryNodeRole> getRoles() {
297298
return roles;
298299
}
299300

300-
public boolean isCompatibleWithVersion(TransportVersion version) {
301+
public boolean isCompatibleWithVersion(Version version) {
301302
if (version.onOrAfter(RANGE_FLOAT_PROCESSORS_SUPPORT_VERSION)) {
302303
return true;
303304
}

server/src/main/java/org/elasticsearch/common/unit/Processors.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
package org.elasticsearch.common.unit;
1010

1111
import org.elasticsearch.TransportVersion;
12+
import org.elasticsearch.Version;
1213
import org.elasticsearch.common.io.stream.StreamInput;
1314
import org.elasticsearch.common.io.stream.StreamOutput;
1415
import org.elasticsearch.common.io.stream.Writeable;
@@ -29,8 +30,10 @@ public class Processors implements Writeable, Comparable<Processors>, ToXContent
2930
public static final Processors ZERO = new Processors(0.0);
3031
public static final Processors MAX_PROCESSORS = new Processors(Double.MAX_VALUE);
3132

32-
public static final TransportVersion FLOAT_PROCESSORS_SUPPORT_VERSION = TransportVersion.V_8_3_0;
33-
public static final TransportVersion DOUBLE_PROCESSORS_SUPPORT_VERSION = TransportVersion.V_8_5_0;
33+
public static final Version FLOAT_PROCESSORS_SUPPORT_VERSION = Version.V_8_3_0;
34+
public static final TransportVersion FLOAT_PROCESSORS_SUPPORT_TRANSPORT_VERSION = TransportVersion.V_8_3_0;
35+
public static final Version DOUBLE_PROCESSORS_SUPPORT_VERSION = Version.V_8_5_0;
36+
public static final TransportVersion DOUBLE_PROCESSORS_SUPPORT_TRANSPORT_VERSION = TransportVersion.V_8_5_0;
3437
static final int NUMBER_OF_DECIMAL_PLACES = 5;
3538
private static final double MIN_REPRESENTABLE_PROCESSORS = 1E-5;
3639

@@ -63,9 +66,9 @@ public static Processors of(Double count) {
6366

6467
public static Processors readFrom(StreamInput in) throws IOException {
6568
final double processorCount;
66-
if (in.getTransportVersion().before(FLOAT_PROCESSORS_SUPPORT_VERSION)) {
69+
if (in.getTransportVersion().before(FLOAT_PROCESSORS_SUPPORT_TRANSPORT_VERSION)) {
6770
processorCount = in.readInt();
68-
} else if (in.getTransportVersion().before(DOUBLE_PROCESSORS_SUPPORT_VERSION)) {
71+
} else if (in.getTransportVersion().before(DOUBLE_PROCESSORS_SUPPORT_TRANSPORT_VERSION)) {
6972
processorCount = in.readFloat();
7073
} else {
7174
processorCount = in.readDouble();
@@ -75,10 +78,10 @@ public static Processors readFrom(StreamInput in) throws IOException {
7578

7679
@Override
7780
public void writeTo(StreamOutput out) throws IOException {
78-
if (out.getTransportVersion().before(FLOAT_PROCESSORS_SUPPORT_VERSION)) {
81+
if (out.getTransportVersion().before(FLOAT_PROCESSORS_SUPPORT_TRANSPORT_VERSION)) {
7982
assert hasDecimals() == false;
8083
out.writeInt((int) count);
81-
} else if (out.getTransportVersion().before(DOUBLE_PROCESSORS_SUPPORT_VERSION)) {
84+
} else if (out.getTransportVersion().before(DOUBLE_PROCESSORS_SUPPORT_TRANSPORT_VERSION)) {
8285
out.writeFloat((float) count);
8386
} else {
8487
out.writeDouble(count);
@@ -143,7 +146,7 @@ private boolean hasDecimals() {
143146
return ((int) count) != Math.ceil(count);
144147
}
145148

146-
public boolean isCompatibleWithVersion(TransportVersion version) {
149+
public boolean isCompatibleWithVersion(Version version) {
147150
if (version.onOrAfter(FLOAT_PROCESSORS_SUPPORT_VERSION)) {
148151
return true;
149152
}

server/src/test/java/org/elasticsearch/cluster/metadata/DesiredNodeTests.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
package org.elasticsearch.cluster.metadata;
1010

11-
import org.elasticsearch.TransportVersion;
1211
import org.elasticsearch.Version;
1312
import org.elasticsearch.cluster.node.DiscoveryNodeRole;
1413
import org.elasticsearch.common.settings.Settings;
@@ -202,8 +201,8 @@ public void testDesiredNodeIsCompatible() {
202201
ByteSizeValue.ofGb(1),
203202
Version.CURRENT
204203
);
205-
assertThat(desiredNode.isCompatibleWithVersion(TransportVersion.V_8_2_0), is(equalTo(false)));
206-
assertThat(desiredNode.isCompatibleWithVersion(TransportVersion.V_8_3_0), is(equalTo(true)));
204+
assertThat(desiredNode.isCompatibleWithVersion(Version.V_8_2_0), is(equalTo(false)));
205+
assertThat(desiredNode.isCompatibleWithVersion(Version.V_8_3_0), is(equalTo(true)));
207206
}
208207

209208
{
@@ -214,14 +213,14 @@ public void testDesiredNodeIsCompatible() {
214213
ByteSizeValue.ofGb(1),
215214
Version.CURRENT
216215
);
217-
assertThat(desiredNode.isCompatibleWithVersion(TransportVersion.V_8_2_0), is(equalTo(false)));
218-
assertThat(desiredNode.isCompatibleWithVersion(TransportVersion.V_8_3_0), is(equalTo(true)));
216+
assertThat(desiredNode.isCompatibleWithVersion(Version.V_8_2_0), is(equalTo(false)));
217+
assertThat(desiredNode.isCompatibleWithVersion(Version.V_8_3_0), is(equalTo(true)));
219218
}
220219

221220
{
222221
final var desiredNode = new DesiredNode(settings, 2.0f, ByteSizeValue.ofGb(1), ByteSizeValue.ofGb(1), Version.CURRENT);
223-
assertThat(desiredNode.isCompatibleWithVersion(TransportVersion.V_8_2_0), is(equalTo(true)));
224-
assertThat(desiredNode.isCompatibleWithVersion(TransportVersion.V_8_3_0), is(equalTo(true)));
222+
assertThat(desiredNode.isCompatibleWithVersion(Version.V_8_2_0), is(equalTo(true)));
223+
assertThat(desiredNode.isCompatibleWithVersion(Version.V_8_3_0), is(equalTo(true)));
225224
}
226225
}
227226

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/role/PutRoleRequest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public PutRoleRequest(StreamInput in) throws IOException {
5858
runAs = in.readStringArray();
5959
refreshPolicy = RefreshPolicy.readFrom(in);
6060
metadata = in.readMap();
61-
if (in.getTransportVersion().onOrAfter(RoleDescriptor.VERSION_REMOTE_INDICES)) {
61+
if (in.getTransportVersion().onOrAfter(RoleDescriptor.TRANSPORT_VERSION_REMOTE_INDICES)) {
6262
remoteIndicesPrivileges = in.readList(RoleDescriptor.RemoteIndicesPrivileges::new);
6363
}
6464
}
@@ -213,12 +213,12 @@ public void writeTo(StreamOutput out) throws IOException {
213213
out.writeStringArray(runAs);
214214
refreshPolicy.writeTo(out);
215215
out.writeGenericMap(metadata);
216-
if (out.getTransportVersion().onOrAfter(RoleDescriptor.VERSION_REMOTE_INDICES)) {
216+
if (out.getTransportVersion().onOrAfter(RoleDescriptor.TRANSPORT_VERSION_REMOTE_INDICES)) {
217217
out.writeCollection(remoteIndicesPrivileges);
218218
} else if (hasRemoteIndicesPrivileges()) {
219219
throw new IllegalArgumentException(
220220
"versions of Elasticsearch before ["
221-
+ RoleDescriptor.VERSION_REMOTE_INDICES
221+
+ RoleDescriptor.TRANSPORT_VERSION_REMOTE_INDICES
222222
+ "] can't handle remote indices privileges and attempted to send to ["
223223
+ out.getTransportVersion()
224224
+ "]"

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/GetUserPrivilegesResponse.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public GetUserPrivilegesResponse(StreamInput in) throws IOException {
4747
index = Collections.unmodifiableSet(in.readSet(Indices::new));
4848
application = Collections.unmodifiableSet(in.readSet(RoleDescriptor.ApplicationResourcePrivileges::new));
4949
runAs = Collections.unmodifiableSet(in.readSet(StreamInput::readString));
50-
if (in.getTransportVersion().onOrAfter(RoleDescriptor.VERSION_REMOTE_INDICES)) {
50+
if (in.getTransportVersion().onOrAfter(RoleDescriptor.TRANSPORT_VERSION_REMOTE_INDICES)) {
5151
remoteIndex = Collections.unmodifiableSet(in.readSet(RemoteIndices::new));
5252
} else {
5353
remoteIndex = Collections.emptySet();
@@ -105,12 +105,12 @@ public void writeTo(StreamOutput out) throws IOException {
105105
out.writeCollection(index);
106106
out.writeCollection(application);
107107
out.writeCollection(runAs, StreamOutput::writeString);
108-
if (out.getTransportVersion().onOrAfter(RoleDescriptor.VERSION_REMOTE_INDICES)) {
108+
if (out.getTransportVersion().onOrAfter(RoleDescriptor.TRANSPORT_VERSION_REMOTE_INDICES)) {
109109
out.writeCollection(remoteIndex);
110110
} else if (hasRemoteIndicesPrivileges()) {
111111
throw new IllegalArgumentException(
112112
"versions of Elasticsearch before ["
113-
+ RoleDescriptor.VERSION_REMOTE_INDICES
113+
+ RoleDescriptor.TRANSPORT_VERSION_REMOTE_INDICES
114114
+ "] can't handle remote indices privileges and attempted to send to ["
115115
+ out.getTransportVersion()
116116
+ "]"

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/RoleDescriptor.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.elasticsearch.ElasticsearchParseException;
1010
import org.elasticsearch.ElasticsearchSecurityException;
1111
import org.elasticsearch.TransportVersion;
12+
import org.elasticsearch.Version;
1213
import org.elasticsearch.common.Strings;
1314
import org.elasticsearch.common.ValidationException;
1415
import org.elasticsearch.common.bytes.BytesArray;
@@ -53,7 +54,8 @@
5354
public class RoleDescriptor implements ToXContentObject, Writeable {
5455

5556
public static final String ROLE_TYPE = "role";
56-
public static final TransportVersion VERSION_REMOTE_INDICES = TransportVersion.V_8_6_0;
57+
public static final Version VERSION_REMOTE_INDICES = Version.V_8_6_0;
58+
public static final TransportVersion TRANSPORT_VERSION_REMOTE_INDICES = TransportVersion.V_8_6_0;
5759

5860
private final String name;
5961
private final String[] clusterPrivileges;
@@ -166,7 +168,7 @@ public RoleDescriptor(StreamInput in) throws IOException {
166168

167169
this.applicationPrivileges = in.readArray(ApplicationResourcePrivileges::new, ApplicationResourcePrivileges[]::new);
168170
this.configurableClusterPrivileges = ConfigurableClusterPrivileges.readArray(in);
169-
if (in.getTransportVersion().onOrAfter(VERSION_REMOTE_INDICES)) {
171+
if (in.getTransportVersion().onOrAfter(TRANSPORT_VERSION_REMOTE_INDICES)) {
170172
this.remoteIndicesPrivileges = in.readArray(RemoteIndicesPrivileges::new, RemoteIndicesPrivileges[]::new);
171173
} else {
172174
this.remoteIndicesPrivileges = RemoteIndicesPrivileges.NONE;
@@ -353,12 +355,12 @@ public void writeTo(StreamOutput out) throws IOException {
353355
out.writeGenericMap(transientMetadata);
354356
out.writeArray(ApplicationResourcePrivileges::write, applicationPrivileges);
355357
ConfigurableClusterPrivileges.writeArray(out, getConditionalClusterPrivileges());
356-
if (out.getTransportVersion().onOrAfter(VERSION_REMOTE_INDICES)) {
358+
if (out.getTransportVersion().onOrAfter(TRANSPORT_VERSION_REMOTE_INDICES)) {
357359
out.writeArray(remoteIndicesPrivileges);
358360
} else if (hasRemoteIndicesPrivileges()) {
359361
throw new IllegalArgumentException(
360362
"versions of Elasticsearch before ["
361-
+ VERSION_REMOTE_INDICES
363+
+ TRANSPORT_VERSION_REMOTE_INDICES
362364
+ "] can't handle remote indices privileges and attempted to send to ["
363365
+ out.getTransportVersion()
364366
+ "]"

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/role/PutRoleRequestTests.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public void testSerialization() throws IOException {
164164
logger.info("Serializing with version {}", version);
165165
out.setTransportVersion(version);
166166
}
167-
final boolean mayIncludeRemoteIndices = out.getTransportVersion().onOrAfter(RoleDescriptor.VERSION_REMOTE_INDICES);
167+
final boolean mayIncludeRemoteIndices = out.getTransportVersion().onOrAfter(RoleDescriptor.TRANSPORT_VERSION_REMOTE_INDICES);
168168
final PutRoleRequest original = buildRandomRequest(mayIncludeRemoteIndices);
169169
original.writeTo(out);
170170

@@ -180,7 +180,9 @@ public void testSerialization() throws IOException {
180180

181181
public void testSerializationWithRemoteIndicesThrowsOnUnsupportedVersions() throws IOException {
182182
final BytesStreamOutput out = new BytesStreamOutput();
183-
final TransportVersion versionBeforeRemoteIndices = TransportVersionUtils.getPreviousVersion(RoleDescriptor.VERSION_REMOTE_INDICES);
183+
final TransportVersion versionBeforeRemoteIndices = TransportVersionUtils.getPreviousVersion(
184+
RoleDescriptor.TRANSPORT_VERSION_REMOTE_INDICES
185+
);
184186
final TransportVersion version = TransportVersionUtils.randomPreviousCompatibleVersion(random(), versionBeforeRemoteIndices);
185187
out.setTransportVersion(version);
186188

0 commit comments

Comments
 (0)