2929/**
3030 * Handles ingest pipeline resolution and execution for pull-based ingestion.
3131 *
32- * <p>Resolves configured pipelines from index settings (lazy, cached) and executes them
32+ * <p>Resolves configured pipelines from index settings at initialization and executes them
3333 * synchronously by bridging IngestService's async callback API with CompletableFuture.
34+ * Also registers a dynamic settings listener to pick up runtime changes to {@code final_pipeline}.
3435 * Only {@code final_pipeline} is supported.
3536 */
3637public class IngestPipelineExecutor {
@@ -42,25 +43,26 @@ public class IngestPipelineExecutor {
4243
4344 private final IngestService ingestService ;
4445 private final String index ;
45-
46- // Cached pipeline names — resolved lazily on the first document
4746 private volatile String resolvedFinalPipeline ;
48- private volatile boolean pipelinesResolved = false ;
4947
5048 /**
5149 * Creates an IngestPipelineExecutor for the given index.
50+ * Resolves the final pipeline from index settings and registers a dynamic settings listener.
5251 *
5352 * @param ingestService the ingest service for pipeline execution
5453 * @param index the index name
54+ * @param indexSettings the index settings to resolve a pipeline from and register listener on
5555 */
56- public IngestPipelineExecutor (IngestService ingestService , String index ) {
56+ public IngestPipelineExecutor (IngestService ingestService , String index , IndexSettings indexSettings ) {
5757 this .ingestService = Objects .requireNonNull (ingestService );
5858 this .index = Objects .requireNonNull (index );
59+ indexSettings .getScopedSettings ().addSettingsUpdateConsumer (IndexSettings .FINAL_PIPELINE , this ::updateFinalPipeline );
60+ updateFinalPipeline (IndexSettings .FINAL_PIPELINE .get (indexSettings .getSettings ()));
5961 }
6062
6163 /**
6264 * Visible for testing. Creates an executor with a pre-resolved pipeline name,
63- * bypassing lazy resolution from index settings.
65+ * bypassing resolution from index settings.
6466 *
6567 * @param ingestService the ingest service
6668 * @param index the index name
@@ -70,23 +72,6 @@ public IngestPipelineExecutor(IngestService ingestService, String index) {
7072 this .ingestService = Objects .requireNonNull (ingestService );
7173 this .index = Objects .requireNonNull (index );
7274 this .resolvedFinalPipeline = finalPipeline ;
73- this .pipelinesResolved = true ;
74- }
75-
76- /**
77- * Resolves pipeline names from index settings. Called lazily on first document and cached.
78- * Also registers a dynamic settings listener for final_pipeline updates.
79- */
80- void resolvePipelineNames (IndexSettings indexSettings ) {
81- if (pipelinesResolved ) {
82- return ;
83- }
84- updateFinalPipeline (IndexSettings .FINAL_PIPELINE .get (indexSettings .getSettings ()));
85-
86- // Register dynamic settings listener for final_pipeline updates
87- indexSettings .getScopedSettings ().addSettingsUpdateConsumer (IndexSettings .FINAL_PIPELINE , this ::updateFinalPipeline );
88-
89- pipelinesResolved = true ;
9075 }
9176
9277 /**
0 commit comments