-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add limit on number of processors in Ingest pipelines
- Loading branch information
Rai
committed
Aug 28, 2024
1 parent
23cba28
commit 290dbff
Showing
7 changed files
with
74 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
server/src/main/java/org/opensearch/ingest/IngestPipelineValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.ingest; | ||
|
||
import java.util.List; | ||
|
||
import org.opensearch.cluster.service.ClusterService; | ||
import org.opensearch.common.settings.Setting; | ||
|
||
/** | ||
* This class contains methods to validate the ingest pipeline. | ||
*/ | ||
public class IngestPipelineValidator { | ||
|
||
/** | ||
* Defines the limit for the number of processors which can run on a given document during ingestion. | ||
* | ||
*/ | ||
public static final Setting<Integer> MAX_NUMBER_OF_INGEST_PROCESSORS = Setting.intSetting( | ||
"cluster.ingest.max_number_processors", | ||
Integer.MAX_VALUE, | ||
1, | ||
Integer.MAX_VALUE, | ||
Setting.Property.NodeScope, | ||
Setting.Property.Dynamic | ||
); | ||
|
||
/** | ||
* Validates that the number of compound processors in the pipeline does not exceed the configured limit. | ||
* @param pipeline | ||
* @param clusterService | ||
*/ | ||
public static void validateIngestPipeline(Pipeline pipeline, ClusterService clusterService) { | ||
|
||
List<Processor> processors = pipeline.getCompoundProcessor().getProcessors(); | ||
int maxNumberOfIngestProcessorsAllowed = clusterService.getClusterSettings().get(MAX_NUMBER_OF_INGEST_PROCESSORS); | ||
|
||
if (processors.size() > maxNumberOfIngestProcessorsAllowed) { | ||
throw new IllegalStateException( | ||
"Cannot use more than the maximum processors allowed. Number of processors configured is [" | ||
+ processors.size() + "] which exceeds the maximum allowed configuration of [" + maxNumberOfIngestProcessorsAllowed + | ||
"] processors."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters