@@ -48,6 +48,7 @@ public class IndexLifecycleExplainResponse implements ToXContentObject, Writeabl
48
48
private static final ParseField STEP_TIME_MILLIS_FIELD = new ParseField ("step_time_millis" );
49
49
private static final ParseField STEP_TIME_FIELD = new ParseField ("step_time" );
50
50
private static final ParseField STEP_INFO_FIELD = new ParseField ("step_info" );
51
+ private static final ParseField PREVIOUS_STEP_INFO_FIELD = new ParseField ("previous_step_info" );
51
52
private static final ParseField PHASE_EXECUTION_INFO = new ParseField ("phase_execution" );
52
53
private static final ParseField AGE_FIELD = new ParseField ("age" );
53
54
private static final ParseField TIME_SINCE_INDEX_CREATION_FIELD = new ParseField ("time_since_index_creation" );
@@ -76,6 +77,7 @@ public class IndexLifecycleExplainResponse implements ToXContentObject, Writeabl
76
77
(String ) a [17 ],
77
78
(String ) a [18 ],
78
79
(BytesReference ) a [11 ],
80
+ (BytesReference ) a [21 ],
79
81
(PhaseExecutionInfo ) a [12 ]
80
82
// a[13] == "age"
81
83
// a[20] == "time_since_index_creation"
@@ -111,6 +113,11 @@ public class IndexLifecycleExplainResponse implements ToXContentObject, Writeabl
111
113
PARSER .declareString (ConstructingObjectParser .optionalConstructorArg (), SHRINK_INDEX_NAME );
112
114
PARSER .declareLong (ConstructingObjectParser .optionalConstructorArg (), INDEX_CREATION_DATE_MILLIS_FIELD );
113
115
PARSER .declareString (ConstructingObjectParser .optionalConstructorArg (), TIME_SINCE_INDEX_CREATION_FIELD );
116
+ PARSER .declareObject (ConstructingObjectParser .optionalConstructorArg (), (p , c ) -> {
117
+ XContentBuilder builder = JsonXContent .contentBuilder ();
118
+ builder .copyCurrentStructure (p );
119
+ return BytesReference .bytes (builder );
120
+ }, PREVIOUS_STEP_INFO_FIELD );
114
121
}
115
122
116
123
private final String index ;
@@ -126,6 +133,7 @@ public class IndexLifecycleExplainResponse implements ToXContentObject, Writeabl
126
133
private final Long stepTime ;
127
134
private final boolean managedByILM ;
128
135
private final BytesReference stepInfo ;
136
+ private final BytesReference previousStepInfo ;
129
137
private final PhaseExecutionInfo phaseExecutionInfo ;
130
138
private final Boolean isAutoRetryableError ;
131
139
private final Integer failedStepRetryCount ;
@@ -153,6 +161,7 @@ public static IndexLifecycleExplainResponse newManagedIndexResponse(
153
161
String snapshotName ,
154
162
String shrinkIndexName ,
155
163
BytesReference stepInfo ,
164
+ BytesReference previousStepInfo ,
156
165
PhaseExecutionInfo phaseExecutionInfo
157
166
) {
158
167
return new IndexLifecycleExplainResponse (
@@ -174,6 +183,7 @@ public static IndexLifecycleExplainResponse newManagedIndexResponse(
174
183
snapshotName ,
175
184
shrinkIndexName ,
176
185
stepInfo ,
186
+ previousStepInfo ,
177
187
phaseExecutionInfo
178
188
);
179
189
}
@@ -198,6 +208,7 @@ public static IndexLifecycleExplainResponse newUnmanagedIndexResponse(String ind
198
208
null ,
199
209
null ,
200
210
null ,
211
+ null ,
201
212
null
202
213
);
203
214
}
@@ -221,6 +232,7 @@ private IndexLifecycleExplainResponse(
221
232
String snapshotName ,
222
233
String shrinkIndexName ,
223
234
BytesReference stepInfo ,
235
+ BytesReference previousStepInfo ,
224
236
PhaseExecutionInfo phaseExecutionInfo
225
237
) {
226
238
if (managedByILM ) {
@@ -262,6 +274,7 @@ private IndexLifecycleExplainResponse(
262
274
|| actionTime != null
263
275
|| stepTime != null
264
276
|| stepInfo != null
277
+ || previousStepInfo != null
265
278
|| phaseExecutionInfo != null ) {
266
279
throw new IllegalArgumentException (
267
280
"Unmanaged index response must only contain fields: [" + MANAGED_BY_ILM_FIELD + ", " + INDEX_FIELD + "]"
@@ -283,6 +296,7 @@ private IndexLifecycleExplainResponse(
283
296
this .isAutoRetryableError = isAutoRetryableError ;
284
297
this .failedStepRetryCount = failedStepRetryCount ;
285
298
this .stepInfo = stepInfo ;
299
+ this .previousStepInfo = previousStepInfo ;
286
300
this .phaseExecutionInfo = phaseExecutionInfo ;
287
301
this .repositoryName = repositoryName ;
288
302
this .snapshotName = snapshotName ;
@@ -314,6 +328,11 @@ public IndexLifecycleExplainResponse(StreamInput in) throws IOException {
314
328
} else {
315
329
indexCreationDate = null ;
316
330
}
331
+ if (in .getTransportVersion ().onOrAfter (TransportVersions .RETAIN_ILM_STEP_INFO )) {
332
+ previousStepInfo = in .readOptionalBytesReference ();
333
+ } else {
334
+ previousStepInfo = null ;
335
+ }
317
336
} else {
318
337
policyName = null ;
319
338
lifecycleDate = null ;
@@ -327,6 +346,7 @@ public IndexLifecycleExplainResponse(StreamInput in) throws IOException {
327
346
actionTime = null ;
328
347
stepTime = null ;
329
348
stepInfo = null ;
349
+ previousStepInfo = null ;
330
350
phaseExecutionInfo = null ;
331
351
repositoryName = null ;
332
352
snapshotName = null ;
@@ -359,6 +379,9 @@ public void writeTo(StreamOutput out) throws IOException {
359
379
if (out .getTransportVersion ().onOrAfter (TransportVersions .V_8_1_0 )) {
360
380
out .writeOptionalLong (indexCreationDate );
361
381
}
382
+ if (out .getTransportVersion ().onOrAfter (TransportVersions .RETAIN_ILM_STEP_INFO )) {
383
+ out .writeOptionalBytesReference (previousStepInfo );
384
+ }
362
385
}
363
386
}
364
387
@@ -422,6 +445,10 @@ public BytesReference getStepInfo() {
422
445
return stepInfo ;
423
446
}
424
447
448
+ public BytesReference getPreviousStepInfo () {
449
+ return previousStepInfo ;
450
+ }
451
+
425
452
public PhaseExecutionInfo getPhaseExecutionInfo () {
426
453
return phaseExecutionInfo ;
427
454
}
@@ -515,6 +542,9 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
515
542
if (stepInfo != null && stepInfo .length () > 0 ) {
516
543
builder .rawField (STEP_INFO_FIELD .getPreferredName (), stepInfo .streamInput (), XContentType .JSON );
517
544
}
545
+ if (previousStepInfo != null && previousStepInfo .length () > 0 ) {
546
+ builder .rawField (PREVIOUS_STEP_INFO_FIELD .getPreferredName (), previousStepInfo .streamInput (), XContentType .JSON );
547
+ }
518
548
if (phaseExecutionInfo != null ) {
519
549
builder .field (PHASE_EXECUTION_INFO .getPreferredName (), phaseExecutionInfo );
520
550
}
@@ -544,6 +574,7 @@ public int hashCode() {
544
574
snapshotName ,
545
575
shrinkIndexName ,
546
576
stepInfo ,
577
+ previousStepInfo ,
547
578
phaseExecutionInfo
548
579
);
549
580
}
@@ -575,6 +606,7 @@ public boolean equals(Object obj) {
575
606
&& Objects .equals (snapshotName , other .snapshotName )
576
607
&& Objects .equals (shrinkIndexName , other .shrinkIndexName )
577
608
&& Objects .equals (stepInfo , other .stepInfo )
609
+ && Objects .equals (previousStepInfo , other .previousStepInfo )
578
610
&& Objects .equals (phaseExecutionInfo , other .phaseExecutionInfo );
579
611
}
580
612
0 commit comments