Skip to content

Commit

Permalink
NIFI-13609 Correct Component Search Configuration (#9131)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
exceptionfactory authored Jul 31, 2024
1 parent d41d8ed commit 8ad6aa6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -97,6 +96,8 @@ public class WebApplicationConfiguration {

private final RuntimeManifestService runtimeManifestService;

private final ControllerSearchService controllerSearchService;

private ClusterCoordinator clusterCoordinator;

private RequestReplicator requestReplicator;
Expand All @@ -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;
Expand All @@ -125,6 +127,7 @@ public WebApplicationConfiguration(
this.properties = properties;
this.revisionManager = revisionManager;
this.runtimeManifestService = runtimeManifestService;
this.controllerSearchService = controllerSearchService;
}

@Autowired(required = false)
Expand Down Expand Up @@ -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();
Expand All @@ -276,6 +263,7 @@ public ControllerFacade controllerFacade() {
controllerFacade.setProperties(properties);
controllerFacade.setFlowService(flowService);
controllerFacade.setRuntimeManifestService(runtimeManifestService);
controllerFacade.setControllerSearchService(controllerSearchService);
controllerFacade.setSearchQueryParser(searchQueryParser());
return controllerFacade;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down Expand Up @@ -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<>(),
Expand All @@ -148,7 +154,7 @@ public ControllerSearchService controllerSearchService() {
new RelationshipMatcher<>(),
new ProcessorMetadataMatcher(),
new PropertyMatcher<>(),
new SearchableMatcher()
searchableMatcher
)
));

Expand Down

0 comments on commit 8ad6aa6

Please sign in to comment.