14
14
import org .elasticsearch .Version ;
15
15
import org .elasticsearch .cluster .node .DiscoveryNode ;
16
16
import org .elasticsearch .cluster .node .DiscoveryNodeRole ;
17
- import org .elasticsearch .common .Strings ;
18
17
import org .elasticsearch .common .io .stream .StreamInput ;
19
18
import org .elasticsearch .common .io .stream .StreamOutput ;
20
19
import org .elasticsearch .common .io .stream .Writeable ;
21
20
import org .elasticsearch .common .settings .Settings ;
22
21
import org .elasticsearch .common .unit .ByteSizeValue ;
23
22
import org .elasticsearch .common .unit .Processors ;
24
23
import org .elasticsearch .core .Nullable ;
25
- import org .elasticsearch .core .UpdateForV9 ;
26
24
import org .elasticsearch .features .NodeFeature ;
27
25
import org .elasticsearch .xcontent .ConstructingObjectParser ;
28
26
import org .elasticsearch .xcontent .ObjectParser ;
38
36
import java .util .Set ;
39
37
import java .util .TreeSet ;
40
38
import java .util .function .Predicate ;
41
- import java .util .regex .Pattern ;
42
39
43
40
import static java .lang .String .format ;
44
41
import static org .elasticsearch .node .Node .NODE_EXTERNAL_ID_SETTING ;
@@ -58,8 +55,6 @@ public final class DesiredNode implements Writeable, ToXContentObject, Comparabl
58
55
private static final ParseField PROCESSORS_RANGE_FIELD = new ParseField ("processors_range" );
59
56
private static final ParseField MEMORY_FIELD = new ParseField ("memory" );
60
57
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" );
63
58
64
59
public static final ConstructingObjectParser <DesiredNode , Void > PARSER = new ConstructingObjectParser <>(
65
60
"desired_node" ,
@@ -69,8 +64,7 @@ public final class DesiredNode implements Writeable, ToXContentObject, Comparabl
69
64
(Processors ) args [1 ],
70
65
(ProcessorsRange ) args [2 ],
71
66
(ByteSizeValue ) args [3 ],
72
- (ByteSizeValue ) args [4 ],
73
- (String ) args [5 ]
67
+ (ByteSizeValue ) args [4 ]
74
68
)
75
69
);
76
70
@@ -104,12 +98,6 @@ static <T> void configureParser(ConstructingObjectParser<T, Void> parser) {
104
98
STORAGE_FIELD ,
105
99
ObjectParser .ValueType .STRING
106
100
);
107
- parser .declareField (
108
- ConstructingObjectParser .optionalConstructorArg (),
109
- (p , c ) -> p .text (),
110
- VERSION_FIELD ,
111
- ObjectParser .ValueType .STRING
112
- );
113
101
}
114
102
115
103
private final Settings settings ;
@@ -118,21 +106,9 @@ static <T> void configureParser(ConstructingObjectParser<T, Void> parser) {
118
106
private final ByteSizeValue memory ;
119
107
private final ByteSizeValue storage ;
120
108
121
- @ UpdateForV9 (owner = UpdateForV9 .Owner .DISTRIBUTED_COORDINATION ) // Remove deprecated version field
122
- private final String version ;
123
109
private final String externalId ;
124
110
private final Set <DiscoveryNodeRole > roles ;
125
111
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
-
136
112
public DesiredNode (Settings settings , ProcessorsRange processorsRange , ByteSizeValue memory , ByteSizeValue storage ) {
137
113
this (settings , null , processorsRange , memory , storage );
138
114
}
@@ -142,17 +118,6 @@ public DesiredNode(Settings settings, double processors, ByteSizeValue memory, B
142
118
}
143
119
144
120
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
- ) {
156
121
assert settings != null ;
157
122
assert memory != null ;
158
123
assert storage != null ;
@@ -186,7 +151,6 @@ public DesiredNode(Settings settings, double processors, ByteSizeValue memory, B
186
151
this .processorsRange = processorsRange ;
187
152
this .memory = memory ;
188
153
this .storage = storage ;
189
- this .version = version ;
190
154
this .externalId = NODE_EXTERNAL_ID_SETTING .get (settings );
191
155
this .roles = Collections .unmodifiableSortedSet (new TreeSet <>(DiscoveryNode .getRolesFromSettings (settings )));
192
156
}
@@ -210,19 +174,7 @@ public static DesiredNode readFrom(StreamInput in) throws IOException {
210
174
} else {
211
175
version = Version .readVersion (in ).toString ();
212
176
}
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 ;
177
+ return new DesiredNode (settings , processors , processorsRange , memory , storage );
226
178
}
227
179
228
180
@ Override
@@ -239,15 +191,9 @@ public void writeTo(StreamOutput out) throws IOException {
239
191
memory .writeTo (out );
240
192
storage .writeTo (out );
241
193
if (out .getTransportVersion ().onOrAfter (TransportVersions .V_8_13_0 )) {
242
- out .writeOptionalString (version );
194
+ out .writeOptionalString (null );
243
195
} 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
- }
196
+ Version .writeVersion (Version .CURRENT , out );
251
197
}
252
198
}
253
199
@@ -275,14 +221,6 @@ public void toInnerXContent(XContentBuilder builder, Params params) throws IOExc
275
221
}
276
222
builder .field (MEMORY_FIELD .getPreferredName (), memory );
277
223
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
- }
286
224
}
287
225
288
226
public boolean hasMasterRole () {
@@ -366,7 +304,6 @@ private boolean equalsWithoutProcessorsSpecification(DesiredNode that) {
366
304
return Objects .equals (settings , that .settings )
367
305
&& Objects .equals (memory , that .memory )
368
306
&& Objects .equals (storage , that .storage )
369
- && Objects .equals (version , that .version )
370
307
&& Objects .equals (externalId , that .externalId )
371
308
&& Objects .equals (roles , that .roles );
372
309
}
@@ -379,7 +316,7 @@ public boolean equalsWithProcessorsCloseTo(DesiredNode that) {
379
316
380
317
@ Override
381
318
public int hashCode () {
382
- return Objects .hash (settings , processors , processorsRange , memory , storage , version , externalId , roles );
319
+ return Objects .hash (settings , processors , processorsRange , memory , storage , externalId , roles );
383
320
}
384
321
385
322
@ Override
@@ -408,10 +345,6 @@ public String toString() {
408
345
+ '}' ;
409
346
}
410
347
411
- public boolean hasVersion () {
412
- return Strings .isNullOrBlank (version ) == false ;
413
- }
414
-
415
348
public record ProcessorsRange (Processors min , @ Nullable Processors max ) implements Writeable , ToXContentObject {
416
349
417
350
private static final ParseField MIN_FIELD = new ParseField ("min" );
0 commit comments