@@ -57,28 +57,24 @@ public class MlMetadata implements XPackPlugin.XPackMetaDataCustom {
5757 public static final String TYPE = "ml" ;
5858 private static final ParseField JOBS_FIELD = new ParseField ("jobs" );
5959 private static final ParseField DATAFEEDS_FIELD = new ParseField ("datafeeds" );
60- private static final ParseField LAST_MEMORY_REFRESH_VERSION_FIELD = new ParseField ("last_memory_refresh_version" );
6160
62- public static final MlMetadata EMPTY_METADATA = new MlMetadata (Collections .emptySortedMap (), Collections .emptySortedMap (), null );
61+ public static final MlMetadata EMPTY_METADATA = new MlMetadata (Collections .emptySortedMap (), Collections .emptySortedMap ());
6362 // This parser follows the pattern that metadata is parsed leniently (to allow for enhancements)
6463 public static final ObjectParser <Builder , Void > LENIENT_PARSER = new ObjectParser <>("ml_metadata" , true , Builder ::new );
6564
6665 static {
6766 LENIENT_PARSER .declareObjectArray (Builder ::putJobs , (p , c ) -> Job .LENIENT_PARSER .apply (p , c ).build (), JOBS_FIELD );
6867 LENIENT_PARSER .declareObjectArray (Builder ::putDatafeeds ,
6968 (p , c ) -> DatafeedConfig .LENIENT_PARSER .apply (p , c ).build (), DATAFEEDS_FIELD );
70- LENIENT_PARSER .declareLong (Builder ::setLastMemoryRefreshVersion , LAST_MEMORY_REFRESH_VERSION_FIELD );
7169 }
7270
7371 private final SortedMap <String , Job > jobs ;
7472 private final SortedMap <String , DatafeedConfig > datafeeds ;
75- private final Long lastMemoryRefreshVersion ;
7673 private final GroupOrJobLookup groupOrJobLookup ;
7774
78- private MlMetadata (SortedMap <String , Job > jobs , SortedMap <String , DatafeedConfig > datafeeds , Long lastMemoryRefreshVersion ) {
75+ private MlMetadata (SortedMap <String , Job > jobs , SortedMap <String , DatafeedConfig > datafeeds ) {
7976 this .jobs = Collections .unmodifiableSortedMap (jobs );
8077 this .datafeeds = Collections .unmodifiableSortedMap (datafeeds );
81- this .lastMemoryRefreshVersion = lastMemoryRefreshVersion ;
8278 this .groupOrJobLookup = new GroupOrJobLookup (jobs .values ());
8379 }
8480
@@ -121,10 +117,6 @@ public Set<String> expandDatafeedIds(String expression) {
121117 .expand (expression );
122118 }
123119
124- public Long getLastMemoryRefreshVersion () {
125- return lastMemoryRefreshVersion ;
126- }
127-
128120 @ Override
129121 public Version getMinimalSupportedVersion () {
130122 return Version .V_5_4_0 ;
@@ -158,21 +150,13 @@ public MlMetadata(StreamInput in) throws IOException {
158150 datafeeds .put (in .readString (), new DatafeedConfig (in ));
159151 }
160152 this .datafeeds = datafeeds ;
161- if (in .getVersion ().onOrAfter (Version .V_6_6_0 )) {
162- lastMemoryRefreshVersion = in .readOptionalLong ();
163- } else {
164- lastMemoryRefreshVersion = null ;
165- }
166153 this .groupOrJobLookup = new GroupOrJobLookup (jobs .values ());
167154 }
168155
169156 @ Override
170157 public void writeTo (StreamOutput out ) throws IOException {
171158 writeMap (jobs , out );
172159 writeMap (datafeeds , out );
173- if (out .getVersion ().onOrAfter (Version .V_6_6_0 )) {
174- out .writeOptionalLong (lastMemoryRefreshVersion );
175- }
176160 }
177161
178162 private static <T extends Writeable > void writeMap (Map <String , T > map , StreamOutput out ) throws IOException {
@@ -189,9 +173,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
189173 new DelegatingMapParams (Collections .singletonMap (ToXContentParams .FOR_INTERNAL_STORAGE , "true" ), params );
190174 mapValuesToXContent (JOBS_FIELD , jobs , builder , extendedParams );
191175 mapValuesToXContent (DATAFEEDS_FIELD , datafeeds , builder , extendedParams );
192- if (lastMemoryRefreshVersion != null ) {
193- builder .field (LAST_MEMORY_REFRESH_VERSION_FIELD .getPreferredName (), lastMemoryRefreshVersion );
194- }
195176 return builder ;
196177 }
197178
@@ -208,24 +189,17 @@ public static class MlMetadataDiff implements NamedDiff<MetaData.Custom> {
208189
209190 final Diff <Map <String , Job >> jobs ;
210191 final Diff <Map <String , DatafeedConfig >> datafeeds ;
211- final Long lastMemoryRefreshVersion ;
212192
213193 MlMetadataDiff (MlMetadata before , MlMetadata after ) {
214194 this .jobs = DiffableUtils .diff (before .jobs , after .jobs , DiffableUtils .getStringKeySerializer ());
215195 this .datafeeds = DiffableUtils .diff (before .datafeeds , after .datafeeds , DiffableUtils .getStringKeySerializer ());
216- this .lastMemoryRefreshVersion = after .lastMemoryRefreshVersion ;
217196 }
218197
219198 public MlMetadataDiff (StreamInput in ) throws IOException {
220199 this .jobs = DiffableUtils .readJdkMapDiff (in , DiffableUtils .getStringKeySerializer (), Job ::new ,
221200 MlMetadataDiff ::readJobDiffFrom );
222201 this .datafeeds = DiffableUtils .readJdkMapDiff (in , DiffableUtils .getStringKeySerializer (), DatafeedConfig ::new ,
223202 MlMetadataDiff ::readDatafeedDiffFrom );
224- if (in .getVersion ().onOrAfter (Version .V_6_6_0 )) {
225- lastMemoryRefreshVersion = in .readOptionalLong ();
226- } else {
227- lastMemoryRefreshVersion = null ;
228- }
229203 }
230204
231205 /**
@@ -237,17 +211,13 @@ public MlMetadataDiff(StreamInput in) throws IOException {
237211 public MetaData .Custom apply (MetaData .Custom part ) {
238212 TreeMap <String , Job > newJobs = new TreeMap <>(jobs .apply (((MlMetadata ) part ).jobs ));
239213 TreeMap <String , DatafeedConfig > newDatafeeds = new TreeMap <>(datafeeds .apply (((MlMetadata ) part ).datafeeds ));
240- // lastMemoryRefreshVersion always comes from the diff - no need to merge with the old value
241- return new MlMetadata (newJobs , newDatafeeds , lastMemoryRefreshVersion );
214+ return new MlMetadata (newJobs , newDatafeeds );
242215 }
243216
244217 @ Override
245218 public void writeTo (StreamOutput out ) throws IOException {
246219 jobs .writeTo (out );
247220 datafeeds .writeTo (out );
248- if (out .getVersion ().onOrAfter (Version .V_6_6_0 )) {
249- out .writeOptionalLong (lastMemoryRefreshVersion );
250- }
251221 }
252222
253223 @ Override
@@ -272,8 +242,7 @@ public boolean equals(Object o) {
272242 return false ;
273243 MlMetadata that = (MlMetadata ) o ;
274244 return Objects .equals (jobs , that .jobs ) &&
275- Objects .equals (datafeeds , that .datafeeds ) &&
276- Objects .equals (lastMemoryRefreshVersion , that .lastMemoryRefreshVersion );
245+ Objects .equals (datafeeds , that .datafeeds );
277246 }
278247
279248 @ Override
@@ -283,14 +252,13 @@ public final String toString() {
283252
284253 @ Override
285254 public int hashCode () {
286- return Objects .hash (jobs , datafeeds , lastMemoryRefreshVersion );
255+ return Objects .hash (jobs , datafeeds );
287256 }
288257
289258 public static class Builder {
290259
291260 private TreeMap <String , Job > jobs ;
292261 private TreeMap <String , DatafeedConfig > datafeeds ;
293- private Long lastMemoryRefreshVersion ;
294262
295263 public Builder () {
296264 jobs = new TreeMap <>();
@@ -304,7 +272,6 @@ public Builder(@Nullable MlMetadata previous) {
304272 } else {
305273 jobs = new TreeMap <>(previous .jobs );
306274 datafeeds = new TreeMap <>(previous .datafeeds );
307- lastMemoryRefreshVersion = previous .lastMemoryRefreshVersion ;
308275 }
309276 }
310277
@@ -424,13 +391,8 @@ public Builder putDatafeeds(Collection<DatafeedConfig> datafeeds) {
424391 return this ;
425392 }
426393
427- public Builder setLastMemoryRefreshVersion (Long lastMemoryRefreshVersion ) {
428- this .lastMemoryRefreshVersion = lastMemoryRefreshVersion ;
429- return this ;
430- }
431-
432394 public MlMetadata build () {
433- return new MlMetadata (jobs , datafeeds , lastMemoryRefreshVersion );
395+ return new MlMetadata (jobs , datafeeds );
434396 }
435397
436398 public void markJobAsDeleting (String jobId , PersistentTasksCustomMetaData tasks , boolean allowDeleteOpenJob ) {
0 commit comments