Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Delegate primitive write methods with ByteSizeCachingDirectory wrapped IndexOutput ([#19432](https://github.com/opensearch-project/OpenSearch/pull/19432))
- Bump opensearch-protobufs dependency to 0.18.0 and update transport-grpc module compatibility ([#19447](https://github.com/opensearch-project/OpenSearch/issues/19447))
- Bump opensearch-protobufs dependency to 0.19.0 ([#19453](https://github.com/opensearch-project/OpenSearch/issues/19453))

- Add a function to SearchPipelineService to check if system generated factory enabled or not ([#19545](https://github.com/opensearch-project/OpenSearch/pull/19545))
### Fixed
- Fix unnecessary refreshes on update preparation failures ([#15261](https://github.com/opensearch-project/OpenSearch/issues/15261))
- Fix NullPointerException in segment replicator ([#18997](https://github.com/opensearch-project/OpenSearch/pull/18997))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public class SearchPipelineService implements ClusterStateApplier, ReportingServ
public static final String SEARCH_PIPELINE_ORIGIN = "search_pipeline";
public static final String AD_HOC_PIPELINE_ID = "_ad_hoc_pipeline";
public static final String NOOP_PIPELINE_ID = "_none";
public static final String ALL = "*";
private static final int MAX_PIPELINE_ID_BYTES = 512;
private static final Logger logger = LogManager.getLogger(SearchPipelineService.class);
private final ClusterService clusterService;
Expand Down Expand Up @@ -643,4 +644,9 @@ static class PipelineHolder {
this.pipeline = Objects.requireNonNull(pipeline);
}
}

public boolean isSystemGeneratedFactoryEnabled(String factoryName) {
return enabledSystemGeneratedFactories != null
&& (enabledSystemGeneratedFactories.contains(ALL) || enabledSystemGeneratedFactories.contains(factoryName));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;

import static org.opensearch.search.pipeline.SearchPipelineService.ENABLED_SYSTEM_GENERATED_FACTORIES_SETTING;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
Expand Down Expand Up @@ -1640,4 +1641,25 @@ private SearchResponse createDefaultSearchResponse() {
return new SearchResponse(sections, null, 0, 0, 0, 0, null, null);
}

public void testIsSystemGeneratedFactoryEnabled_whenAllEnabled_thenTrue() throws Exception {
SearchPipelineService service = createWithSystemGeneratedProcessors();
enabledAllSystemGeneratedFactories(service);

assertTrue(service.isSystemGeneratedFactoryEnabled("dummy_factory"));
}

public void testIsSystemGeneratedFactoryEnabled_whenEnabled_thenTrue() {
SearchPipelineService service = createWithSystemGeneratedProcessors();
service.getClusterService()
.getClusterSettings()
.applySettings(Settings.builder().putList(ENABLED_SYSTEM_GENERATED_FACTORIES_SETTING.getKey(), "dummy_factory").build());

assertTrue(service.isSystemGeneratedFactoryEnabled("dummy_factory"));
}

public void testIsSystemGeneratedFactoryEnabled_whenNotEnabled_thenFalse() {
SearchPipelineService service = createWithSystemGeneratedProcessors();

assertFalse(service.isSystemGeneratedFactoryEnabled("dummy_factory"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
import java.util.concurrent.ExecutorService;
import java.util.function.Consumer;

import static org.opensearch.search.pipeline.SearchPipelineService.ALL;
import static org.opensearch.search.pipeline.SearchPipelineService.ENABLED_SYSTEM_GENERATED_FACTORIES_SETTING;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
Expand Down Expand Up @@ -712,9 +714,9 @@ SearchSourceBuilder createDefaultSearchSourceBuilder() {
return SearchSourceBuilder.searchSource().size(10);
}

void enabledAllSystemGeneratedFactories(SearchPipelineService service) throws Exception {
void enabledAllSystemGeneratedFactories(SearchPipelineService service) {
service.getClusterService()
.getClusterSettings()
.applySettings(Settings.builder().putList("cluster.search.enabled_system_generated_factories", "*").build());
.applySettings(Settings.builder().putList(ENABLED_SYSTEM_GENERATED_FACTORIES_SETTING.getKey(), ALL).build());
}
}
Loading