Search in sources :

Example 1 with FlowFileEventRepository

use of org.apache.nifi.controller.repository.FlowFileEventRepository in project nifi by apache.

the class FlowControllerFactoryBean method getObject.

@Override
public Object getObject() throws Exception {
    if (flowController == null) {
        final FlowFileEventRepository flowFileEventRepository = applicationContext.getBean("flowFileEventRepository", FlowFileEventRepository.class);
        if (properties.isNode()) {
            final NodeProtocolSender nodeProtocolSender = applicationContext.getBean("nodeProtocolSender", NodeProtocolSender.class);
            final HeartbeatMonitor heartbeatMonitor = applicationContext.getBean("heartbeatMonitor", HeartbeatMonitor.class);
            flowController = FlowController.createClusteredInstance(flowFileEventRepository, properties, authorizer, auditService, encryptor, nodeProtocolSender, bulletinRepository, clusterCoordinator, heartbeatMonitor, leaderElectionManager, variableRegistry, flowRegistryClient);
        } else {
            flowController = FlowController.createStandaloneInstance(flowFileEventRepository, properties, authorizer, auditService, encryptor, bulletinRepository, variableRegistry, flowRegistryClient);
        }
    }
    return flowController;
}
Also used : HeartbeatMonitor(org.apache.nifi.cluster.coordination.heartbeat.HeartbeatMonitor) FlowFileEventRepository(org.apache.nifi.controller.repository.FlowFileEventRepository) NodeProtocolSender(org.apache.nifi.cluster.protocol.NodeProtocolSender)

Example 2 with FlowFileEventRepository

use of org.apache.nifi.controller.repository.FlowFileEventRepository in project nifi by apache.

the class StandardFlowSerializerTest method setUp.

@Before
public void setUp() throws Exception {
    final FlowFileEventRepository flowFileEventRepo = Mockito.mock(FlowFileEventRepository.class);
    final AuditService auditService = Mockito.mock(AuditService.class);
    final Map<String, String> otherProps = new HashMap<>();
    otherProps.put(NiFiProperties.PROVENANCE_REPO_IMPLEMENTATION_CLASS, MockProvenanceRepository.class.getName());
    otherProps.put("nifi.remote.input.socket.port", "");
    otherProps.put("nifi.remote.input.secure", "");
    final NiFiProperties nifiProperties = NiFiProperties.createBasicNiFiProperties(propsFile, otherProps);
    final StringEncryptor encryptor = StringEncryptor.createEncryptor(nifiProperties);
    // use the system bundle
    systemBundle = SystemBundle.create(nifiProperties);
    ExtensionManager.discoverExtensions(systemBundle, Collections.emptySet());
    final AbstractPolicyBasedAuthorizer authorizer = new MockPolicyBasedAuthorizer();
    final VariableRegistry variableRegistry = new FileBasedVariableRegistry(nifiProperties.getVariableRegistryPropertiesPaths());
    final BulletinRepository bulletinRepo = Mockito.mock(BulletinRepository.class);
    controller = FlowController.createStandaloneInstance(flowFileEventRepo, nifiProperties, authorizer, auditService, encryptor, bulletinRepo, variableRegistry, Mockito.mock(FlowRegistryClient.class));
    serializer = new StandardFlowSerializer(encryptor);
}
Also used : NiFiProperties(org.apache.nifi.util.NiFiProperties) BulletinRepository(org.apache.nifi.reporting.BulletinRepository) HashMap(java.util.HashMap) FileBasedVariableRegistry(org.apache.nifi.registry.variable.FileBasedVariableRegistry) VariableRegistry(org.apache.nifi.registry.VariableRegistry) AbstractPolicyBasedAuthorizer(org.apache.nifi.authorization.AbstractPolicyBasedAuthorizer) FlowFileEventRepository(org.apache.nifi.controller.repository.FlowFileEventRepository) MockProvenanceRepository(org.apache.nifi.provenance.MockProvenanceRepository) StringEncryptor(org.apache.nifi.encrypt.StringEncryptor) MockPolicyBasedAuthorizer(org.apache.nifi.authorization.MockPolicyBasedAuthorizer) AuditService(org.apache.nifi.admin.service.AuditService) FileBasedVariableRegistry(org.apache.nifi.registry.variable.FileBasedVariableRegistry) Before(org.junit.Before)

Example 3 with FlowFileEventRepository

use of org.apache.nifi.controller.repository.FlowFileEventRepository in project nifi-minifi by apache.

the class MiNiFiServer method start.

public void start() {
    try {
        logger.info("Loading Flow...");
        FlowFileEventRepository flowFileEventRepository = new RingBufferEventRepository(5);
        AuditService auditService = new StandardAuditService();
        Authorizer authorizer = new Authorizer() {

            @Override
            public AuthorizationResult authorize(AuthorizationRequest request) throws AuthorizationAccessException {
                return AuthorizationResult.approved();
            }

            @Override
            public void initialize(AuthorizerInitializationContext initializationContext) throws AuthorizerCreationException {
            // do nothing
            }

            @Override
            public void onConfigured(AuthorizerConfigurationContext configurationContext) throws AuthorizerCreationException {
            // do nothing
            }

            @Override
            public void preDestruction() throws AuthorizerDestructionException {
            // do nothing
            }
        };
        final String sensitivePropAlgorithmVal = props.getProperty(StringEncryptor.NF_SENSITIVE_PROPS_ALGORITHM);
        final String sensitivePropProviderVal = props.getProperty(StringEncryptor.NF_SENSITIVE_PROPS_PROVIDER);
        final String sensitivePropValueNifiPropVar = props.getProperty(StringEncryptor.NF_SENSITIVE_PROPS_KEY, DEFAULT_SENSITIVE_PROPS_KEY);
        StringEncryptor encryptor = StringEncryptor.createEncryptor(sensitivePropAlgorithmVal, sensitivePropProviderVal, sensitivePropValueNifiPropVar);
        VariableRegistry variableRegistry = new FileBasedVariableRegistry(props.getVariableRegistryPropertiesPaths());
        BulletinRepository bulletinRepository = new VolatileBulletinRepository();
        FlowController flowController = FlowController.createStandaloneInstance(flowFileEventRepository, props, authorizer, auditService, encryptor, bulletinRepository, variableRegistry, new StandardFlowRegistryClient());
        flowService = StandardFlowService.createStandaloneInstance(flowController, props, encryptor, // revision manager
        null, authorizer);
        // start and load the flow
        flowService.start();
        flowService.load(null);
        flowController.onFlowInitialized(true);
        flowController.getGroup(flowController.getRootGroupId()).startProcessing();
        this.flowController = flowController;
        logger.info("Flow loaded successfully.");
    } catch (Exception e) {
        // ensure the flow service is terminated
        if (flowService != null && flowService.isRunning()) {
            flowService.stop(false);
        }
        startUpFailure(new Exception("Unable to load flow due to: " + e, e));
    }
}
Also used : VolatileBulletinRepository(org.apache.nifi.events.VolatileBulletinRepository) VolatileBulletinRepository(org.apache.nifi.events.VolatileBulletinRepository) BulletinRepository(org.apache.nifi.reporting.BulletinRepository) AuthorizationRequest(org.apache.nifi.authorization.AuthorizationRequest) FileBasedVariableRegistry(org.apache.nifi.util.FileBasedVariableRegistry) VariableRegistry(org.apache.nifi.registry.VariableRegistry) StatusRequestException(org.apache.nifi.minifi.status.StatusRequestException) AuthorizerCreationException(org.apache.nifi.authorization.exception.AuthorizerCreationException) AuthorizerDestructionException(org.apache.nifi.authorization.exception.AuthorizerDestructionException) AuthorizationAccessException(org.apache.nifi.authorization.exception.AuthorizationAccessException) RingBufferEventRepository(org.apache.nifi.controller.repository.metrics.RingBufferEventRepository) FlowFileEventRepository(org.apache.nifi.controller.repository.FlowFileEventRepository) Authorizer(org.apache.nifi.authorization.Authorizer) StringEncryptor(org.apache.nifi.encrypt.StringEncryptor) FlowController(org.apache.nifi.controller.FlowController) AuthorizerInitializationContext(org.apache.nifi.authorization.AuthorizerInitializationContext) StandardFlowRegistryClient(org.apache.nifi.registry.flow.StandardFlowRegistryClient) StandardAuditService(org.apache.nifi.admin.service.impl.StandardAuditService) AuditService(org.apache.nifi.admin.service.AuditService) StandardAuditService(org.apache.nifi.admin.service.impl.StandardAuditService) AuthorizerConfigurationContext(org.apache.nifi.authorization.AuthorizerConfigurationContext) FileBasedVariableRegistry(org.apache.nifi.util.FileBasedVariableRegistry)

Aggregations

FlowFileEventRepository (org.apache.nifi.controller.repository.FlowFileEventRepository)3 AuditService (org.apache.nifi.admin.service.AuditService)2 StringEncryptor (org.apache.nifi.encrypt.StringEncryptor)2 VariableRegistry (org.apache.nifi.registry.VariableRegistry)2 BulletinRepository (org.apache.nifi.reporting.BulletinRepository)2 HashMap (java.util.HashMap)1 StandardAuditService (org.apache.nifi.admin.service.impl.StandardAuditService)1 AbstractPolicyBasedAuthorizer (org.apache.nifi.authorization.AbstractPolicyBasedAuthorizer)1 AuthorizationRequest (org.apache.nifi.authorization.AuthorizationRequest)1 Authorizer (org.apache.nifi.authorization.Authorizer)1 AuthorizerConfigurationContext (org.apache.nifi.authorization.AuthorizerConfigurationContext)1 AuthorizerInitializationContext (org.apache.nifi.authorization.AuthorizerInitializationContext)1 MockPolicyBasedAuthorizer (org.apache.nifi.authorization.MockPolicyBasedAuthorizer)1 AuthorizationAccessException (org.apache.nifi.authorization.exception.AuthorizationAccessException)1 AuthorizerCreationException (org.apache.nifi.authorization.exception.AuthorizerCreationException)1 AuthorizerDestructionException (org.apache.nifi.authorization.exception.AuthorizerDestructionException)1 HeartbeatMonitor (org.apache.nifi.cluster.coordination.heartbeat.HeartbeatMonitor)1 NodeProtocolSender (org.apache.nifi.cluster.protocol.NodeProtocolSender)1 FlowController (org.apache.nifi.controller.FlowController)1 RingBufferEventRepository (org.apache.nifi.controller.repository.metrics.RingBufferEventRepository)1