1111
1212import org .elasticsearch .TransportVersion ;
1313import org .elasticsearch .TransportVersions ;
14- import org .elasticsearch .Version ;
1514import org .elasticsearch .cluster .node .DiscoveryNode ;
1615import org .elasticsearch .cluster .node .DiscoveryNodeRole ;
17- import org .elasticsearch .common .Strings ;
1816import org .elasticsearch .common .io .stream .StreamInput ;
1917import org .elasticsearch .common .io .stream .StreamOutput ;
2018import org .elasticsearch .common .io .stream .Writeable ;
2119import org .elasticsearch .common .settings .Settings ;
2220import org .elasticsearch .common .unit .ByteSizeValue ;
2321import org .elasticsearch .common .unit .Processors ;
2422import org .elasticsearch .core .Nullable ;
25- import org .elasticsearch .core .UpdateForV9 ;
2623import org .elasticsearch .features .NodeFeature ;
2724import org .elasticsearch .xcontent .ConstructingObjectParser ;
2825import org .elasticsearch .xcontent .ObjectParser ;
3835import java .util .Set ;
3936import java .util .TreeSet ;
4037import java .util .function .Predicate ;
41- import java .util .regex .Pattern ;
4238
4339import static java .lang .String .format ;
4440import static org .elasticsearch .node .Node .NODE_EXTERNAL_ID_SETTING ;
@@ -49,7 +45,6 @@ public final class DesiredNode implements Writeable, ToXContentObject, Comparabl
4945
5046 public static final NodeFeature RANGE_FLOAT_PROCESSORS_SUPPORTED = new NodeFeature ("desired_node.range_float_processors" );
5147 public static final NodeFeature DOUBLE_PROCESSORS_SUPPORTED = new NodeFeature ("desired_node.double_processors" );
52- public static final NodeFeature DESIRED_NODE_VERSION_DEPRECATED = new NodeFeature ("desired_node.version_deprecated" );
5348
5449 public static final TransportVersion RANGE_FLOAT_PROCESSORS_SUPPORT_TRANSPORT_VERSION = TransportVersions .V_8_3_0 ;
5550
@@ -58,8 +53,6 @@ public final class DesiredNode implements Writeable, ToXContentObject, Comparabl
5853 private static final ParseField PROCESSORS_RANGE_FIELD = new ParseField ("processors_range" );
5954 private static final ParseField MEMORY_FIELD = new ParseField ("memory" );
6055 private static final ParseField STORAGE_FIELD = new ParseField ("storage" );
61- @ UpdateForV9 (owner = UpdateForV9 .Owner .DISTRIBUTED_COORDINATION ) // Remove deprecated field
62- private static final ParseField VERSION_FIELD = new ParseField ("node_version" );
6356
6457 public static final ConstructingObjectParser <DesiredNode , Void > PARSER = new ConstructingObjectParser <>(
6558 "desired_node" ,
@@ -69,8 +62,7 @@ public final class DesiredNode implements Writeable, ToXContentObject, Comparabl
6962 (Processors ) args [1 ],
7063 (ProcessorsRange ) args [2 ],
7164 (ByteSizeValue ) args [3 ],
72- (ByteSizeValue ) args [4 ],
73- (String ) args [5 ]
65+ (ByteSizeValue ) args [4 ]
7466 )
7567 );
7668
@@ -104,12 +96,6 @@ static <T> void configureParser(ConstructingObjectParser<T, Void> parser) {
10496 STORAGE_FIELD ,
10597 ObjectParser .ValueType .STRING
10698 );
107- parser .declareField (
108- ConstructingObjectParser .optionalConstructorArg (),
109- (p , c ) -> p .text (),
110- VERSION_FIELD ,
111- ObjectParser .ValueType .STRING
112- );
11399 }
114100
115101 private final Settings settings ;
@@ -118,21 +104,9 @@ static <T> void configureParser(ConstructingObjectParser<T, Void> parser) {
118104 private final ByteSizeValue memory ;
119105 private final ByteSizeValue storage ;
120106
121- @ UpdateForV9 (owner = UpdateForV9 .Owner .DISTRIBUTED_COORDINATION ) // Remove deprecated version field
122- private final String version ;
123107 private final String externalId ;
124108 private final Set <DiscoveryNodeRole > roles ;
125109
126- @ Deprecated
127- public DesiredNode (Settings settings , ProcessorsRange processorsRange , ByteSizeValue memory , ByteSizeValue storage , String version ) {
128- this (settings , null , processorsRange , memory , storage , version );
129- }
130-
131- @ Deprecated
132- public DesiredNode (Settings settings , double processors , ByteSizeValue memory , ByteSizeValue storage , String version ) {
133- this (settings , Processors .of (processors ), null , memory , storage , version );
134- }
135-
136110 public DesiredNode (Settings settings , ProcessorsRange processorsRange , ByteSizeValue memory , ByteSizeValue storage ) {
137111 this (settings , null , processorsRange , memory , storage );
138112 }
@@ -142,17 +116,6 @@ public DesiredNode(Settings settings, double processors, ByteSizeValue memory, B
142116 }
143117
144118 DesiredNode (Settings settings , Processors processors , ProcessorsRange processorsRange , ByteSizeValue memory , ByteSizeValue storage ) {
145- this (settings , processors , processorsRange , memory , storage , null );
146- }
147-
148- DesiredNode (
149- Settings settings ,
150- Processors processors ,
151- ProcessorsRange processorsRange ,
152- ByteSizeValue memory ,
153- ByteSizeValue storage ,
154- @ Deprecated String version
155- ) {
156119 assert settings != null ;
157120 assert memory != null ;
158121 assert storage != null ;
@@ -186,7 +149,6 @@ public DesiredNode(Settings settings, double processors, ByteSizeValue memory, B
186149 this .processorsRange = processorsRange ;
187150 this .memory = memory ;
188151 this .storage = storage ;
189- this .version = version ;
190152 this .externalId = NODE_EXTERNAL_ID_SETTING .get (settings );
191153 this .roles = Collections .unmodifiableSortedSet (new TreeSet <>(DiscoveryNode .getRolesFromSettings (settings )));
192154 }
@@ -205,24 +167,7 @@ public static DesiredNode readFrom(StreamInput in) throws IOException {
205167 final var memory = ByteSizeValue .readFrom (in );
206168 final var storage = ByteSizeValue .readFrom (in );
207169 final String version ;
208- if (in .getTransportVersion ().onOrAfter (TransportVersions .V_8_13_0 )) {
209- version = in .readOptionalString ();
210- } else {
211- version = Version .readVersion (in ).toString ();
212- }
213- return new DesiredNode (settings , processors , processorsRange , memory , storage , version );
214- }
215-
216- private static final Pattern SEMANTIC_VERSION_PATTERN = Pattern .compile ("^(\\ d+\\ .\\ d+\\ .\\ d+)\\ D?.*" );
217-
218- private static Version parseLegacyVersion (String version ) {
219- if (version != null ) {
220- var semanticVersionMatcher = SEMANTIC_VERSION_PATTERN .matcher (version );
221- if (semanticVersionMatcher .matches ()) {
222- return Version .fromString (semanticVersionMatcher .group (1 ));
223- }
224- }
225- return null ;
170+ return new DesiredNode (settings , processors , processorsRange , memory , storage );
226171 }
227172
228173 @ Override
@@ -238,17 +183,6 @@ public void writeTo(StreamOutput out) throws IOException {
238183 }
239184 memory .writeTo (out );
240185 storage .writeTo (out );
241- if (out .getTransportVersion ().onOrAfter (TransportVersions .V_8_13_0 )) {
242- out .writeOptionalString (version );
243- } else {
244- Version parsedVersion = parseLegacyVersion (version );
245- if (version == null ) {
246- // Some node is from before we made the version field not required. If so, fill in with the current node version.
247- Version .writeVersion (Version .CURRENT , out );
248- } else {
249- Version .writeVersion (parsedVersion , out );
250- }
251- }
252186 }
253187
254188 public static DesiredNode fromXContent (XContentParser parser ) throws IOException {
@@ -275,14 +209,6 @@ public void toInnerXContent(XContentBuilder builder, Params params) throws IOExc
275209 }
276210 builder .field (MEMORY_FIELD .getPreferredName (), memory );
277211 builder .field (STORAGE_FIELD .getPreferredName (), storage );
278- addDeprecatedVersionField (builder );
279- }
280-
281- @ UpdateForV9 (owner = UpdateForV9 .Owner .DISTRIBUTED_COORDINATION ) // Remove deprecated field from response
282- private void addDeprecatedVersionField (XContentBuilder builder ) throws IOException {
283- if (version != null ) {
284- builder .field (VERSION_FIELD .getPreferredName (), version );
285- }
286212 }
287213
288214 public boolean hasMasterRole () {
@@ -366,7 +292,6 @@ private boolean equalsWithoutProcessorsSpecification(DesiredNode that) {
366292 return Objects .equals (settings , that .settings )
367293 && Objects .equals (memory , that .memory )
368294 && Objects .equals (storage , that .storage )
369- && Objects .equals (version , that .version )
370295 && Objects .equals (externalId , that .externalId )
371296 && Objects .equals (roles , that .roles );
372297 }
@@ -379,7 +304,7 @@ public boolean equalsWithProcessorsCloseTo(DesiredNode that) {
379304
380305 @ Override
381306 public int hashCode () {
382- return Objects .hash (settings , processors , processorsRange , memory , storage , version , externalId , roles );
307+ return Objects .hash (settings , processors , processorsRange , memory , storage , externalId , roles );
383308 }
384309
385310 @ Override
@@ -408,10 +333,6 @@ public String toString() {
408333 + '}' ;
409334 }
410335
411- public boolean hasVersion () {
412- return Strings .isNullOrBlank (version ) == false ;
413- }
414-
415336 public record ProcessorsRange (Processors min , @ Nullable Processors max ) implements Writeable , ToXContentObject {
416337
417338 private static final ParseField MIN_FIELD = new ParseField ("min" );
0 commit comments