From 8ad6aa6ede804978e08753e163aa5481f348547b Mon Sep 17 00:00:00 2001 From: David Handermann Date: Wed, 31 Jul 2024 14:04:49 -0500 Subject: [PATCH] NIFI-13609 Correct Component Search Configuration (#9131) * NIFI-13609 Corrected Component Search Configuration - Removed duplicate Controller Search Service bean definition - Wired Controller Search Service to Controller Facade bean definition - Added Flow Controller reference for SearchableMatcher --- .../WebApplicationConfiguration.java | 24 +++++-------------- .../configuration/WebSearchConfiguration.java | 20 ++++++++++------ 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/configuration/WebApplicationConfiguration.java b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/configuration/WebApplicationConfiguration.java index 56c64b821724..02e23dbe2121 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/configuration/WebApplicationConfiguration.java +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/configuration/WebApplicationConfiguration.java @@ -50,7 +50,6 @@ import org.apache.nifi.web.dao.impl.ComponentDAO; import org.apache.nifi.web.revision.RevisionManager; import org.apache.nifi.web.search.query.RegexSearchQueryParser; -import org.apache.nifi.web.search.resultenrichment.ComponentSearchResultEnricherFactory; import org.apache.nifi.web.util.ClusterReplicationComponentLifecycle; import org.apache.nifi.web.util.LocalComponentLifecycle; import org.apache.nifi.web.util.ParameterContextNameCollisionResolver; @@ -97,6 +96,8 @@ public class WebApplicationConfiguration { private final RuntimeManifestService runtimeManifestService; + private final ControllerSearchService controllerSearchService; + private ClusterCoordinator clusterCoordinator; private RequestReplicator requestReplicator; @@ -113,7 +114,8 @@ public WebApplicationConfiguration( final FlowService flowService, final NiFiProperties properties, final RevisionManager revisionManager, - final RuntimeManifestService runtimeManifestService + final RuntimeManifestService runtimeManifestService, + final ControllerSearchService controllerSearchService ) { this.authorizer = authorizer; this.accessPolicyDao = accessPolicyDao; @@ -125,6 +127,7 @@ public WebApplicationConfiguration( this.properties = properties; this.revisionManager = revisionManager; this.runtimeManifestService = runtimeManifestService; + this.controllerSearchService = controllerSearchService; } @Autowired(required = false) @@ -232,27 +235,11 @@ public RegexSearchQueryParser searchQueryParser() { return new RegexSearchQueryParser(); } - @Bean - public ComponentSearchResultEnricherFactory resultEnricherFactory() { - final ComponentSearchResultEnricherFactory factory = new ComponentSearchResultEnricherFactory(); - factory.setAuthorizer(authorizer); - return factory; - } - @Bean public StandardReloadComponent reloadComponent() { return new StandardReloadComponent(flowController); } - @Bean - public ControllerSearchService controllerSearchService() { - final ControllerSearchService controllerSearchService = new ControllerSearchService(); - controllerSearchService.setAuthorizer(authorizer); - controllerSearchService.setFlowController(flowController); - controllerSearchService.setResultEnricherFactory(resultEnricherFactory()); - return controllerSearchService; - } - @Bean public NiFiWebConfigurationContext nifiWebConfigurationContext() { final StandardNiFiWebConfigurationContext context = new StandardNiFiWebConfigurationContext(); @@ -276,6 +263,7 @@ public ControllerFacade controllerFacade() { controllerFacade.setProperties(properties); controllerFacade.setFlowService(flowService); controllerFacade.setRuntimeManifestService(runtimeManifestService); + controllerFacade.setControllerSearchService(controllerSearchService); controllerFacade.setSearchQueryParser(searchQueryParser()); return controllerFacade; } diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/configuration/WebSearchConfiguration.java b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/configuration/WebSearchConfiguration.java index f7230e249b45..2f0feb4d3dd0 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/configuration/WebSearchConfiguration.java +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/configuration/WebSearchConfiguration.java @@ -58,16 +58,19 @@ public class WebSearchConfiguration { private final FlowController flowController; - private final ComponentSearchResultEnricherFactory resultEnricherFactory; - public WebSearchConfiguration( final Authorizer authorizer, - final FlowController flowController, - final ComponentSearchResultEnricherFactory resultEnricherFactory + final FlowController flowController ) { this.authorizer = authorizer; this.flowController = flowController; - this.resultEnricherFactory = resultEnricherFactory; + } + + @Bean + public ComponentSearchResultEnricherFactory resultEnricherFactory() { + final ComponentSearchResultEnricherFactory factory = new ComponentSearchResultEnricherFactory(); + factory.setAuthorizer(authorizer); + return factory; } @Bean @@ -76,7 +79,7 @@ public ControllerSearchService controllerSearchService() { controllerSearchService.setAuthorizer(authorizer); controllerSearchService.setFlowController(flowController); - controllerSearchService.setResultEnricherFactory(resultEnricherFactory); + controllerSearchService.setResultEnricherFactory(resultEnricherFactory()); final ComponentMatcherFactory factory = new ComponentMatcherFactory(); controllerSearchService.setMatcherForConnection(factory.getInstanceForConnection( @@ -139,6 +142,9 @@ public ControllerSearchService controllerSearchService() { new PortScheduledStateMatcher() ) )); + + final SearchableMatcher searchableMatcher = new SearchableMatcher(); + searchableMatcher.setFlowController(flowController); controllerSearchService.setMatcherForProcessor(factory.getInstanceForConnectable( List.of( new ExtendedMatcher<>(), @@ -148,7 +154,7 @@ public ControllerSearchService controllerSearchService() { new RelationshipMatcher<>(), new ProcessorMetadataMatcher(), new PropertyMatcher<>(), - new SearchableMatcher() + searchableMatcher ) ));