Search in sources :

Example 1 with VolatileBulletinRepository

use of org.apache.nifi.events.VolatileBulletinRepository in project nifi by apache.

the class StandardFlowServiceTest method setup.

@Before
public void setup() throws Exception {
    properties = NiFiProperties.createBasicNiFiProperties(null, null);
    variableRegistry = new FileBasedVariableRegistry(properties.getVariableRegistryPropertiesPaths());
    mockFlowFileEventRepository = mock(FlowFileEventRepository.class);
    authorizer = mock(Authorizer.class);
    mockAuditService = mock(AuditService.class);
    revisionManager = mock(RevisionManager.class);
    flowController = FlowController.createStandaloneInstance(mockFlowFileEventRepository, properties, authorizer, mockAuditService, mockEncryptor, new VolatileBulletinRepository(), variableRegistry, mock(FlowRegistryClient.class));
    flowService = StandardFlowService.createStandaloneInstance(flowController, properties, mockEncryptor, revisionManager, authorizer);
}
Also used : VolatileBulletinRepository(org.apache.nifi.events.VolatileBulletinRepository) FlowFileEventRepository(org.apache.nifi.controller.repository.FlowFileEventRepository) Authorizer(org.apache.nifi.authorization.Authorizer) RevisionManager(org.apache.nifi.web.revision.RevisionManager) AuditService(org.apache.nifi.admin.service.AuditService) FileBasedVariableRegistry(org.apache.nifi.registry.variable.FileBasedVariableRegistry) Before(org.junit.Before)

Example 2 with VolatileBulletinRepository

use of org.apache.nifi.events.VolatileBulletinRepository in project nifi by apache.

the class TestProcessorLifecycle method buildFlowControllerForTest.

private FlowControllerAndSystemBundle buildFlowControllerForTest(final String propKey, final String propValue) throws Exception {
    final Map<String, String> addProps = new HashMap<>();
    addProps.put(NiFiProperties.ADMINISTRATIVE_YIELD_DURATION, "1 sec");
    addProps.put(NiFiProperties.STATE_MANAGEMENT_CONFIG_FILE, "target/test-classes/state-management.xml");
    addProps.put(NiFiProperties.STATE_MANAGEMENT_LOCAL_PROVIDER_ID, "local-provider");
    addProps.put(NiFiProperties.PROVENANCE_REPO_IMPLEMENTATION_CLASS, MockProvenanceRepository.class.getName());
    addProps.put("nifi.remote.input.socket.port", "");
    addProps.put("nifi.remote.input.secure", "");
    if (propKey != null && propValue != null) {
        addProps.put(propKey, propValue);
    }
    final NiFiProperties nifiProperties = NiFiProperties.createBasicNiFiProperties(propsFile, addProps);
    final Bundle systemBundle = SystemBundle.create(nifiProperties);
    ExtensionManager.discoverExtensions(systemBundle, Collections.emptySet());
    final FlowController flowController = FlowController.createStandaloneInstance(mock(FlowFileEventRepository.class), nifiProperties, mock(Authorizer.class), mock(AuditService.class), null, new VolatileBulletinRepository(), new FileBasedVariableRegistry(nifiProperties.getVariableRegistryPropertiesPaths()), mock(FlowRegistryClient.class));
    return new FlowControllerAndSystemBundle(flowController, systemBundle);
}
Also used : NiFiProperties(org.apache.nifi.util.NiFiProperties) VolatileBulletinRepository(org.apache.nifi.events.VolatileBulletinRepository) HashMap(java.util.HashMap) Bundle(org.apache.nifi.bundle.Bundle) SystemBundle(org.apache.nifi.nar.SystemBundle) FlowRegistryClient(org.apache.nifi.registry.flow.FlowRegistryClient) FlowFileEventRepository(org.apache.nifi.controller.repository.FlowFileEventRepository) Authorizer(org.apache.nifi.authorization.Authorizer) MockProvenanceRepository(org.apache.nifi.provenance.MockProvenanceRepository) FlowController(org.apache.nifi.controller.FlowController) AuditService(org.apache.nifi.admin.service.AuditService) FileBasedVariableRegistry(org.apache.nifi.registry.variable.FileBasedVariableRegistry)

Example 3 with VolatileBulletinRepository

use of org.apache.nifi.events.VolatileBulletinRepository 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

AuditService (org.apache.nifi.admin.service.AuditService)3 Authorizer (org.apache.nifi.authorization.Authorizer)3 FlowFileEventRepository (org.apache.nifi.controller.repository.FlowFileEventRepository)3 VolatileBulletinRepository (org.apache.nifi.events.VolatileBulletinRepository)3 FlowController (org.apache.nifi.controller.FlowController)2 FileBasedVariableRegistry (org.apache.nifi.registry.variable.FileBasedVariableRegistry)2 HashMap (java.util.HashMap)1 StandardAuditService (org.apache.nifi.admin.service.impl.StandardAuditService)1 AuthorizationRequest (org.apache.nifi.authorization.AuthorizationRequest)1 AuthorizerConfigurationContext (org.apache.nifi.authorization.AuthorizerConfigurationContext)1 AuthorizerInitializationContext (org.apache.nifi.authorization.AuthorizerInitializationContext)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 Bundle (org.apache.nifi.bundle.Bundle)1 RingBufferEventRepository (org.apache.nifi.controller.repository.metrics.RingBufferEventRepository)1 StringEncryptor (org.apache.nifi.encrypt.StringEncryptor)1 StatusRequestException (org.apache.nifi.minifi.status.StatusRequestException)1 SystemBundle (org.apache.nifi.nar.SystemBundle)1 MockProvenanceRepository (org.apache.nifi.provenance.MockProvenanceRepository)1