Search in sources :

Example 1 with RepositoryPurgeException

use of org.apache.nifi.controller.repository.RepositoryPurgeException 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);
    }
}
Also used : NiFiProperties(org.apache.nifi.util.NiFiProperties) ApplicationContext(org.springframework.context.ApplicationContext) NiFiCoreException(org.apache.nifi.web.NiFiCoreException) RequestReplicator(org.apache.nifi.cluster.coordination.http.replication.RequestReplicator) FlowController(org.apache.nifi.controller.FlowController) IOException(java.io.IOException) RepositoryPurgeException(org.apache.nifi.controller.repository.RepositoryPurgeException) FlowService(org.apache.nifi.services.FlowService) BeansException(org.springframework.beans.BeansException)

Aggregations

IOException (java.io.IOException)1 RequestReplicator (org.apache.nifi.cluster.coordination.http.replication.RequestReplicator)1 FlowController (org.apache.nifi.controller.FlowController)1 RepositoryPurgeException (org.apache.nifi.controller.repository.RepositoryPurgeException)1 FlowService (org.apache.nifi.services.FlowService)1 NiFiProperties (org.apache.nifi.util.NiFiProperties)1 NiFiCoreException (org.apache.nifi.web.NiFiCoreException)1 BeansException (org.springframework.beans.BeansException)1 ApplicationContext (org.springframework.context.ApplicationContext)1