use of org.apache.nifi.cluster.coordination.http.replication.RequestReplicator in project nifi by apache.
the class ApplicationStartupContextListener method contextInitialized.
@Override
public void contextInitialized(ServletContextEvent sce) {
final ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(sce.getServletContext());
final NiFiProperties properties = ctx.getBean("nifiProperties", NiFiProperties.class);
try {
flowService = ctx.getBean("flowService", FlowService.class);
flowController = ctx.getBean("flowController", FlowController.class);
requestReplicator = ctx.getBean("requestReplicator", RequestReplicator.class);
// the flow loading here when not clustered resolves this.
if (!properties.isNode()) {
logger.info("Starting Flow Controller...");
// start and load the flow
flowService.start();
flowService.load(null);
/*
* Start up all processors if specified.
*
* When operating as the node, the cluster manager controls
* which processors should start. As part of the flow
* reloading actions, the node will start the necessary
* processors.
*/
flowController.onFlowInitialized(properties.getAutoResumeState());
logger.info("Flow Controller started successfully.");
}
} catch (BeansException | RepositoryPurgeException | IOException e) {
shutdown();
throw new NiFiCoreException("Unable to start Flow Controller.", e);
}
try {
// attempt to get a few beans that we want to to ensure properly created since they are lazily initialized
ctx.getBean("loginIdentityProvider", LoginIdentityProvider.class);
ctx.getBean("authorizer", Authorizer.class);
} catch (final BeansException e) {
shutdown();
throw new NiFiCoreException("Unable to start Flow Controller.", e);
}
}
Aggregations