@@ -180,6 +180,7 @@ public class DataStreamLifecycleService implements ClusterStateListener, Closeab
180180 private final MasterServiceTaskQueue <DeleteSourceAndAddDownsampleToDS > swapSourceWithDownsampleIndexQueue ;
181181 private volatile ByteSizeValue targetMergePolicyFloorSegment ;
182182 private volatile int targetMergePolicyFactor ;
183+ private final AdditionalDataStreamLifecycleActions additionalDataStreamLifecycleActions ;
183184 /**
184185 * The number of retries for a particular index and error after which DSL will emmit a signal (e.g. log statement)
185186 */
@@ -218,7 +219,8 @@ public DataStreamLifecycleService(
218219 DataStreamLifecycleErrorStore errorStore ,
219220 AllocationService allocationService ,
220221 DataStreamLifecycleHealthInfoPublisher dataStreamLifecycleHealthInfoPublisher ,
221- DataStreamGlobalRetentionSettings globalRetentionSettings
222+ DataStreamGlobalRetentionSettings globalRetentionSettings ,
223+ @ Nullable AdditionalDataStreamLifecycleActions additionalDataStreamLifecycleActions
222224 ) {
223225 this .settings = settings ;
224226 this .client = client ;
@@ -248,6 +250,7 @@ public DataStreamLifecycleService(
248250 new DeleteSourceAndAddDownsampleIndexExecutor (allocationService )
249251 );
250252 this .dslHealthInfoPublisher = dataStreamLifecycleHealthInfoPublisher ;
253+ this .additionalDataStreamLifecycleActions = additionalDataStreamLifecycleActions ;
251254 }
252255
253256 /**
@@ -378,7 +381,16 @@ private void run(ProjectState projectState) {
378381 // the following indices should not be considered for the remainder of this service run, for various reasons.
379382 Set <Index > indicesToExcludeForRemainingRun = new HashSet <>();
380383 for (DataStreamLifecycleAction action : actions ) {
381- indicesToExcludeForRemainingRun .addAll (action .apply (projectState , dataStream , indicesToExcludeForRemainingRun ));
384+ indicesToExcludeForRemainingRun .addAll (
385+ action .apply (projectState , dataStream , indicesToExcludeForRemainingRun , client , errorStore )
386+ );
387+ }
388+ if (additionalDataStreamLifecycleActions != null ) {
389+ for (DataStreamLifecycleAction action : additionalDataStreamLifecycleActions .getDataStreamLifecycleActions ()) {
390+ indicesToExcludeForRemainingRun .addAll (
391+ action .apply (projectState , dataStream , indicesToExcludeForRemainingRun , client , errorStore )
392+ );
393+ }
382394 }
383395 affectedIndices += indicesToExcludeForRemainingRun .size ();
384396 affectedDataStreams ++;
@@ -396,7 +408,9 @@ private void run(ProjectState projectState) {
396408 private Set <Index > timeSeriesIndicesStillWithinTimeBounds (
397409 ProjectState projectState ,
398410 DataStream dataStream ,
399- Set <Index > indicesToExcludeForRemainingRun
411+ Set <Index > indicesToExcludeForRemainingRun ,
412+ Client client ,
413+ DataStreamLifecycleErrorStore errorStore
400414 ) {
401415 return timeSeriesIndicesStillWithinTimeBounds (projectState , dataStream , indicesToExcludeForRemainingRun , nowSupplier );
402416 }
@@ -449,7 +463,13 @@ static Set<Index> timeSeriesIndicesStillWithinTimeBounds(
449463 * replacing an index in the data stream, deleting a source index, or downsampling itself) so these indices can be skipped in case
450464 * there are other operations to be executed by the data stream lifecycle after downsampling.
451465 */
452- Set <Index > maybeExecuteDownsampling (ProjectState projectState , DataStream dataStream , Set <Index > indicesToExcludeForRemainingRun ) {
466+ Set <Index > maybeExecuteDownsampling (
467+ ProjectState projectState ,
468+ DataStream dataStream ,
469+ Set <Index > indicesToExcludeForRemainingRun ,
470+ Client client ,
471+ DataStreamLifecycleErrorStore errorStore
472+ ) {
453473 Set <Index > affectedIndices = new HashSet <>();
454474 try {
455475 List <Index > targetIndices = getTargetIndices (
@@ -836,7 +856,13 @@ private void clearErrorStoreForUnmanagedIndices(ProjectMetadata project, DataStr
836856 }
837857 }
838858
839- private Set <Index > maybeExecuteRollover (ProjectState projectState , DataStream dataStream , Set <Index > indicesToExcludeForRemainingRun ) {
859+ private Set <Index > maybeExecuteRollover (
860+ ProjectState projectState ,
861+ DataStream dataStream ,
862+ Set <Index > indicesToExcludeForRemainingRun ,
863+ Client client ,
864+ DataStreamLifecycleErrorStore errorStore
865+ ) {
840866 var dataRetention = getEffectiveRetention (dataStream , globalRetentionSettings , false );
841867 var failuresRetention = getEffectiveRetention (dataStream , globalRetentionSettings , true );
842868 // These are the pre-rollover write indices. They may or may not be the write index after maybeExecuteRollover has executed,
@@ -919,7 +945,13 @@ private Index maybeExecuteRollover(
919945 * @param indicesToExcludeForRemainingRun Indices to exclude from retention even if it would be time for them to be deleted
920946 * @return The set of indices that delete requests have been sent for
921947 */
922- Set <Index > maybeExecuteRetention (ProjectState projectState , DataStream dataStream , Set <Index > indicesToExcludeForRemainingRun ) {
948+ Set <Index > maybeExecuteRetention (
949+ ProjectState projectState ,
950+ DataStream dataStream ,
951+ Set <Index > indicesToExcludeForRemainingRun ,
952+ Client client ,
953+ DataStreamLifecycleErrorStore errorStore
954+ ) {
923955 Set <Index > indicesToBeRemoved = new HashSet <>();
924956 try {
925957 var dataRetention = getEffectiveRetention (dataStream , globalRetentionSettings , false );
@@ -1012,7 +1044,9 @@ Set<Index> maybeExecuteRetention(ProjectState projectState, DataStream dataStrea
10121044 private Set <Index > maybeExecuteForceMerge (
10131045 ProjectState projectState ,
10141046 DataStream dataStream ,
1015- Set <Index > indicesToExcludeForRemainingRun
1047+ Set <Index > indicesToExcludeForRemainingRun ,
1048+ Client client ,
1049+ DataStreamLifecycleErrorStore errorStore
10161050 ) {
10171051 Set <Index > affectedIndices = new HashSet <>();
10181052 try {
@@ -1725,16 +1759,4 @@ public int hashCode() {
17251759 }
17261760 }
17271761
1728- @ FunctionalInterface
1729- public interface DataStreamLifecycleAction {
1730- /**
1731- *
1732- * This takes some action on the data stream. The action is expected to be fast, or run asynchronously. It returns a set of indices
1733- * that ought to be ignored by subsequent actions in the current pass.
1734- * @param projectState The current ProjectState
1735- * @param dataStream The data stream to be acted upon
1736- * @param indicesToExcludeForRemainingRun A set of indices that ought to be ignored by this action.
1737- */
1738- Set <Index > apply (ProjectState projectState , DataStream dataStream , Set <Index > indicesToExcludeForRemainingRun );
1739- }
17401762}
0 commit comments