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 .xcontent .ConstructingObjectParser ;
2724import org .elasticsearch .xcontent .ObjectParser ;
2825import org .elasticsearch .xcontent .ParseField ;
3633import java .util .Objects ;
3734import java .util .Set ;
3835import java .util .TreeSet ;
39- import java .util .regex .Pattern ;
4036
4137import static java .lang .String .format ;
4238import static org .elasticsearch .node .Node .NODE_EXTERNAL_ID_SETTING ;
@@ -52,8 +48,6 @@ public final class DesiredNode implements Writeable, ToXContentObject, Comparabl
5248 private static final ParseField PROCESSORS_RANGE_FIELD = new ParseField ("processors_range" );
5349 private static final ParseField MEMORY_FIELD = new ParseField ("memory" );
5450 private static final ParseField STORAGE_FIELD = new ParseField ("storage" );
55- @ UpdateForV9 (owner = UpdateForV9 .Owner .DISTRIBUTED_COORDINATION ) // Remove deprecated field
56- private static final ParseField VERSION_FIELD = new ParseField ("node_version" );
5751
5852 public static final ConstructingObjectParser <DesiredNode , Void > PARSER = new ConstructingObjectParser <>(
5953 "desired_node" ,
@@ -63,8 +57,7 @@ public final class DesiredNode implements Writeable, ToXContentObject, Comparabl
6357 (Processors ) args [1 ],
6458 (ProcessorsRange ) args [2 ],
6559 (ByteSizeValue ) args [3 ],
66- (ByteSizeValue ) args [4 ],
67- (String ) args [5 ]
60+ (ByteSizeValue ) args [4 ]
6861 )
6962 );
7063
@@ -98,12 +91,6 @@ static <T> void configureParser(ConstructingObjectParser<T, Void> parser) {
9891 STORAGE_FIELD ,
9992 ObjectParser .ValueType .STRING
10093 );
101- parser .declareField (
102- ConstructingObjectParser .optionalConstructorArg (),
103- (p , c ) -> p .text (),
104- VERSION_FIELD ,
105- ObjectParser .ValueType .STRING
106- );
10794 }
10895
10996 private final Settings settings ;
@@ -112,21 +99,9 @@ static <T> void configureParser(ConstructingObjectParser<T, Void> parser) {
11299 private final ByteSizeValue memory ;
113100 private final ByteSizeValue storage ;
114101
115- @ UpdateForV9 (owner = UpdateForV9 .Owner .DISTRIBUTED_COORDINATION ) // Remove deprecated version field
116- private final String version ;
117102 private final String externalId ;
118103 private final Set <DiscoveryNodeRole > roles ;
119104
120- @ Deprecated
121- public DesiredNode (Settings settings , ProcessorsRange processorsRange , ByteSizeValue memory , ByteSizeValue storage , String version ) {
122- this (settings , null , processorsRange , memory , storage , version );
123- }
124-
125- @ Deprecated
126- public DesiredNode (Settings settings , double processors , ByteSizeValue memory , ByteSizeValue storage , String version ) {
127- this (settings , Processors .of (processors ), null , memory , storage , version );
128- }
129-
130105 public DesiredNode (Settings settings , ProcessorsRange processorsRange , ByteSizeValue memory , ByteSizeValue storage ) {
131106 this (settings , null , processorsRange , memory , storage );
132107 }
@@ -136,17 +111,6 @@ public DesiredNode(Settings settings, double processors, ByteSizeValue memory, B
136111 }
137112
138113 DesiredNode (Settings settings , Processors processors , ProcessorsRange processorsRange , ByteSizeValue memory , ByteSizeValue storage ) {
139- this (settings , processors , processorsRange , memory , storage , null );
140- }
141-
142- DesiredNode (
143- Settings settings ,
144- Processors processors ,
145- ProcessorsRange processorsRange ,
146- ByteSizeValue memory ,
147- ByteSizeValue storage ,
148- @ Deprecated String version
149- ) {
150114 assert settings != null ;
151115 assert memory != null ;
152116 assert storage != null ;
@@ -180,7 +144,6 @@ public DesiredNode(Settings settings, double processors, ByteSizeValue memory, B
180144 this .processorsRange = processorsRange ;
181145 this .memory = memory ;
182146 this .storage = storage ;
183- this .version = version ;
184147 this .externalId = NODE_EXTERNAL_ID_SETTING .get (settings );
185148 this .roles = Collections .unmodifiableSortedSet (new TreeSet <>(DiscoveryNode .getRolesFromSettings (settings )));
186149 }
@@ -198,25 +161,10 @@ public static DesiredNode readFrom(StreamInput in) throws IOException {
198161 }
199162 final var memory = ByteSizeValue .readFrom (in );
200163 final var storage = ByteSizeValue .readFrom (in );
201- final String version ;
202- if (in .getTransportVersion ().onOrAfter (TransportVersions .V_8_13_0 )) {
203- version = in .readOptionalString ();
204- } else {
205- version = Version .readVersion (in ).toString ();
164+ if (in .getTransportVersion ().before (TransportVersions .REMOVE_DESIRED_NODE_VERSION )) {
165+ in .readOptionalString ();
206166 }
207- return new DesiredNode (settings , processors , processorsRange , memory , storage , version );
208- }
209-
210- private static final Pattern SEMANTIC_VERSION_PATTERN = Pattern .compile ("^(\\ d+\\ .\\ d+\\ .\\ d+)\\ D?.*" );
211-
212- private static Version parseLegacyVersion (String version ) {
213- if (version != null ) {
214- var semanticVersionMatcher = SEMANTIC_VERSION_PATTERN .matcher (version );
215- if (semanticVersionMatcher .matches ()) {
216- return Version .fromString (semanticVersionMatcher .group (1 ));
217- }
218- }
219- return null ;
167+ return new DesiredNode (settings , processors , processorsRange , memory , storage );
220168 }
221169
222170 @ Override
@@ -232,16 +180,8 @@ public void writeTo(StreamOutput out) throws IOException {
232180 }
233181 memory .writeTo (out );
234182 storage .writeTo (out );
235- if (out .getTransportVersion ().onOrAfter (TransportVersions .V_8_13_0 )) {
236- out .writeOptionalString (version );
237- } else {
238- Version parsedVersion = parseLegacyVersion (version );
239- if (version == null ) {
240- // Some node is from before we made the version field not required. If so, fill in with the current node version.
241- Version .writeVersion (Version .CURRENT , out );
242- } else {
243- Version .writeVersion (parsedVersion , out );
244- }
183+ if (out .getTransportVersion ().before (TransportVersions .REMOVE_DESIRED_NODE_VERSION )) {
184+ out .writeOptionalString (null );
245185 }
246186 }
247187
@@ -269,14 +209,6 @@ public void toInnerXContent(XContentBuilder builder, Params params) throws IOExc
269209 }
270210 builder .field (MEMORY_FIELD .getPreferredName (), memory );
271211 builder .field (STORAGE_FIELD .getPreferredName (), storage );
272- addDeprecatedVersionField (builder );
273- }
274-
275- @ UpdateForV9 (owner = UpdateForV9 .Owner .DISTRIBUTED_COORDINATION ) // Remove deprecated field from response
276- private void addDeprecatedVersionField (XContentBuilder builder ) throws IOException {
277- if (version != null ) {
278- builder .field (VERSION_FIELD .getPreferredName (), version );
279- }
280212 }
281213
282214 public boolean hasMasterRole () {
@@ -356,7 +288,6 @@ private boolean equalsWithoutProcessorsSpecification(DesiredNode that) {
356288 return Objects .equals (settings , that .settings )
357289 && Objects .equals (memory , that .memory )
358290 && Objects .equals (storage , that .storage )
359- && Objects .equals (version , that .version )
360291 && Objects .equals (externalId , that .externalId )
361292 && Objects .equals (roles , that .roles );
362293 }
@@ -369,7 +300,7 @@ public boolean equalsWithProcessorsCloseTo(DesiredNode that) {
369300
370301 @ Override
371302 public int hashCode () {
372- return Objects .hash (settings , processors , processorsRange , memory , storage , version , externalId , roles );
303+ return Objects .hash (settings , processors , processorsRange , memory , storage , externalId , roles );
373304 }
374305
375306 @ Override
@@ -398,10 +329,6 @@ public String toString() {
398329 + '}' ;
399330 }
400331
401- public boolean hasVersion () {
402- return Strings .isNullOrBlank (version ) == false ;
403- }
404-
405332 public record ProcessorsRange (Processors min , @ Nullable Processors max ) implements Writeable , ToXContentObject {
406333
407334 private static final ParseField MIN_FIELD = new ParseField ("min" );
0 commit comments