org.apache.nifi.reporting.BulletinRepository Java Examples

The following examples show how to use org.apache.nifi.reporting.BulletinRepository. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestStandardPublicPort.java    From nifi with Apache License 2.0 6 votes vote down vote up
private PublicPort createPublicPort(NiFiProperties nifiProperties) {
    final BulletinRepository bulletinRepository = mock(BulletinRepository.class);
    final ProcessScheduler processScheduler = null;

    final Authorizer authorizer = mock(Authorizer.class);
    doAnswer(invocation -> {
        final AuthorizationRequest request = invocation.getArgument(0);
        if ("[email protected]".equals(request.getIdentity())) {
            return AuthorizationResult.approved();
        } else if ("[email protected]".equals(request.getIdentity())) {
            return AuthorizationResult.approved();
        }
        return AuthorizationResult.denied();
    }).when(authorizer).authorize(any(AuthorizationRequest.class));

    final ProcessGroup processGroup = mock(ProcessGroup.class);
    doReturn("process-group-id").when(processGroup).getIdentifier();

    final StandardPublicPort port = new StandardPublicPort("id", "name",
        TransferDirection.SEND, ConnectableType.INPUT_PORT, authorizer, bulletinRepository, processScheduler, true,
        nifiProperties.getBoredYieldDuration(), IdentityMappingUtil.getIdentityMappings(nifiProperties));
    port.setProcessGroup(processGroup);
    return port;
}
 
Example #2
Source File: FlowController.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
public static FlowController createStandaloneInstance(
        final FlowFileEventRepository flowFileEventRepo,
        final NiFiProperties properties,
        final Authorizer authorizer,
        final AuditService auditService,
        final StringEncryptor encryptor,
        final BulletinRepository bulletinRepo,
        final VariableRegistry variableRegistry) {

    return new FlowController(
            flowFileEventRepo,
            properties,
            authorizer,
            auditService,
            encryptor,
            /* configuredForClustering */ false,
            /* NodeProtocolSender */ null,
            bulletinRepo,
            /* cluster coordinator */ null,
            /* heartbeat monitor */ null,
            /* leader election manager */ null,
            /* variable registry */ variableRegistry);
}
 
Example #3
Source File: TestStandardRootGroupPort.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
private RootGroupPort createRootGroupPort(NiFiProperties nifiProperties) {
    final BulletinRepository bulletinRepository = mock(BulletinRepository.class);
    final ProcessScheduler processScheduler = null;

    final Authorizer authorizer = mock(Authorizer.class);
    doAnswer(invocation -> {
        final AuthorizationRequest request = invocation.getArgumentAt(0, AuthorizationRequest.class);
        if ("[email protected]".equals(request.getIdentity())) {
            return AuthorizationResult.approved();
        }
        return AuthorizationResult.denied();
    }).when(authorizer).authorize(any(AuthorizationRequest.class));

    final ProcessGroup processGroup = mock(ProcessGroup.class);
    doReturn("process-group-id").when(processGroup).getIdentifier();

    return new StandardRootGroupPort("id", "name", processGroup,
            TransferDirection.SEND, ConnectableType.INPUT_PORT, authorizer, bulletinRepository,
            processScheduler, true, nifiProperties);
}
 
Example #4
Source File: StandardReportingContext.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
public StandardReportingContext(final FlowController flowController, final BulletinRepository bulletinRepository,
                                final Map<PropertyDescriptor, String> properties, final ControllerServiceProvider serviceProvider, final ReportingTask reportingTask,
                                final VariableRegistry variableRegistry) {
    this.flowController = flowController;
    this.eventAccess = flowController;
    this.bulletinRepository = bulletinRepository;
    this.properties = Collections.unmodifiableMap(properties);
    this.serviceProvider = serviceProvider;
    this.reportingTask = reportingTask;
    this.variableRegistry = variableRegistry;
    preparedQueries = new HashMap<>();
    for (final Map.Entry<PropertyDescriptor, String> entry : properties.entrySet()) {
        final PropertyDescriptor desc = entry.getKey();
        String value = entry.getValue();
        if (value == null) {
            value = desc.getDefaultValue();
        }

        final PreparedQuery pq = Query.prepare(value);
        preparedQueries.put(desc, pq);
    }
}
 
Example #5
Source File: StandardReportingContext.java    From nifi with Apache License 2.0 6 votes vote down vote up
public StandardReportingContext(final FlowController flowController, final BulletinRepository bulletinRepository,
                                final Map<PropertyDescriptor, String> properties, final ReportingTask reportingTask,
                                final VariableRegistry variableRegistry, final ParameterLookup parameterLookup) {
    this.flowController = flowController;
    this.eventAccess = flowController.getEventAccess();
    this.bulletinRepository = bulletinRepository;
    this.properties = Collections.unmodifiableMap(properties);
    this.serviceProvider = flowController.getControllerServiceProvider();
    this.reportingTask = reportingTask;
    this.variableRegistry = variableRegistry;
    this.parameterLookup = parameterLookup;
    this.analyticsEnabled = flowController.getStatusAnalyticsEngine() != null;
    preparedQueries = new HashMap<>();

    for (final Map.Entry<PropertyDescriptor, String> entry : properties.entrySet()) {
        final PropertyDescriptor desc = entry.getKey();
        String value = entry.getValue();
        if (value == null) {
            value = desc.getDefaultValue();
        }

        final PreparedQuery pq = Query.prepare(value);
        preparedQueries.put(desc, pq);
    }
}
 
Example #6
Source File: FlowController.java    From nifi with Apache License 2.0 5 votes vote down vote up
public static FlowController createStandaloneInstance(
        final FlowFileEventRepository flowFileEventRepo,
        final NiFiProperties properties,
        final Authorizer authorizer,
        final AuditService auditService,
        final StringEncryptor encryptor,
        final BulletinRepository bulletinRepo,
        final VariableRegistry variableRegistry,
        final FlowRegistryClient flowRegistryClient,
        final ExtensionManager extensionManager) {

    return new FlowController(
            flowFileEventRepo,
            properties,
            authorizer,
            auditService,
            encryptor,
            /* configuredForClustering */ false,
            /* NodeProtocolSender */ null,
            bulletinRepo,
            /* cluster coordinator */ null,
            /* heartbeat monitor */ null,
            /* leader election manager */ null,
            /* variable registry */ variableRegistry,
            flowRegistryClient,
            extensionManager);
}
 
Example #7
Source File: StatusConfigReporterTest.java    From nifi-minifi with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
    mockFlowController = mock(FlowController.class);
    rootGroupStatus = mock(ProcessGroupStatus.class);
    bulletinRepo = mock(BulletinRepository.class);
    processGroup = mock(ProcessGroup.class);

    when(mockFlowController.getRootGroupId()).thenReturn("root");
    when(mockFlowController.getGroupStatus("root")).thenReturn(rootGroupStatus);
    when(mockFlowController.getControllerStatus()).thenReturn(rootGroupStatus);
    when(mockFlowController.getBulletinRepository()).thenReturn(bulletinRepo);
    when(mockFlowController.getGroup(mockFlowController.getRootGroupId())).thenReturn(processGroup);
}
 
Example #8
Source File: FlowController.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
private static EventReporter createEventReporter(final BulletinRepository bulletinRepository) {
    return new EventReporter() {
        private static final long serialVersionUID = 1L;

        @Override
        public void reportEvent(final Severity severity, final String category, final String message) {
            final Bulletin bulletin = BulletinFactory.createBulletin(category, severity.name(), message);
            bulletinRepository.addBulletin(bulletin);
        }
    };
}
 
Example #9
Source File: FlowController.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
public static FlowController createClusteredInstance(
        final FlowFileEventRepository flowFileEventRepo,
        final NiFiProperties properties,
        final Authorizer authorizer,
        final AuditService auditService,
        final StringEncryptor encryptor,
        final NodeProtocolSender protocolSender,
        final BulletinRepository bulletinRepo,
        final ClusterCoordinator clusterCoordinator,
        final HeartbeatMonitor heartbeatMonitor,
        final LeaderElectionManager leaderElectionManager,
        final VariableRegistry variableRegistry) {

    final FlowController flowController = new FlowController(
            flowFileEventRepo,
            properties,
            authorizer,
            auditService,
            encryptor,
            /* configuredForClustering */ true,
            protocolSender,
            bulletinRepo,
            clusterCoordinator,
            heartbeatMonitor,
            leaderElectionManager,
            variableRegistry);

    return flowController;
}
 
Example #10
Source File: StandardControllerServiceProvider.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
public StandardControllerServiceProvider(final FlowController flowController, final ProcessScheduler scheduler, final BulletinRepository bulletinRepo,
        final StateManagerProvider stateManagerProvider, final VariableRegistry variableRegistry, final NiFiProperties nifiProperties) {

    this.flowController = flowController;
    this.processScheduler = scheduler;
    this.bulletinRepo = bulletinRepo;
    this.stateManagerProvider = stateManagerProvider;
    this.variableRegistry = variableRegistry;
    this.nifiProperties = nifiProperties;
}
 
Example #11
Source File: ScriptedActionHandlerTest.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void testAlertWithBulletinLevel() throws Exception {
    setupTestRunner();
    final Map<String, String> attributes = new HashMap<>();
    final Map<String, Object> metrics = new HashMap<>();

    final String category = "Rules Alert";
    final String message = "This should be sent as an alert!";
    final String severity = "INFO";
    attributes.put("category", category);
    attributes.put("message", message);
    attributes.put("severity", severity);
    metrics.put("jvmHeap", "1000000");
    metrics.put("cpu", "90");

    final String expectedOutput = "This should be sent as an alert!\n" +
            "Alert Facts:\n" +
            "Field: cpu, Value: 90\n" +
            "Field: jvmHeap, Value: 1000000\n";

    final Action action = new Action();
    action.setType("ALERT");
    action.setAttributes(attributes);
    actionHandler.execute(reportingContext, action, metrics);
    BulletinRepository bulletinRepository = reportingContext.getBulletinRepository();
    List<Bulletin> bulletins = bulletinRepository.findBulletinsForController();
    assertFalse(bulletins.isEmpty());
    Bulletin bulletin = bulletins.get(0);
    assertEquals(bulletin.getCategory(), category);
    assertEquals(bulletin.getMessage(), expectedOutput);
    assertEquals(bulletin.getLevel(), severity);
}
 
Example #12
Source File: AlertHandler.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
protected void executeAction(PropertyContext propertyContext, Action action, Map<String, Object> facts) {
    ComponentLog logger = getLogger();
    if (propertyContext instanceof ReportingContext) {

        ReportingContext context = (ReportingContext) propertyContext;
        Map<String, String> attributes = action.getAttributes();
        if (context.getBulletinRepository() != null) {
            final String category = attributes.getOrDefault("category", defaultCategory);
            final String message = getMessage(attributes.getOrDefault("message", defaultMessage), facts);
            final String level = attributes.getOrDefault("severity", attributes.getOrDefault("logLevel", defaultLogLevel));
            Severity severity;
            try {
                severity = Severity.valueOf(level.toUpperCase());
            } catch (IllegalArgumentException iae) {
                severity = Severity.INFO;
            }
            BulletinRepository bulletinRepository = context.getBulletinRepository();
            bulletinRepository.addBulletin(context.createBulletin(category, severity, message));

        } else {
            logger.warn("Bulletin Repository is not available which is unusual. Cannot send a bulletin.");
        }

    } else {
        logger.warn("Reporting context was not provided to create bulletins.");
    }
}
 
Example #13
Source File: TestAlertHandler.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void testAlertWithBulletinLevel() {

    final Map<String, String> attributes = new HashMap<>();
    final Map<String, Object> metrics = new HashMap<>();

    final String category = "Rules Alert";
    final String message = "This should be sent as an alert!";
    final String severity =  "INFO";
    attributes.put("category", category);
    attributes.put("message", message);
    attributes.put("severity", severity);
    metrics.put("jvmHeap", "1000000");
    metrics.put("cpu", "90");

    final String expectedOutput = "This should be sent as an alert!\n" +
            "Alert Facts:\n" +
            "Field: cpu, Value: 90\n" +
            "Field: jvmHeap, Value: 1000000\n";

    final Action action = new Action();
    action.setType("ALERT");
    action.setAttributes(attributes);
    alertHandler.execute(reportingContext, action, metrics);
    BulletinRepository bulletinRepository = reportingContext.getBulletinRepository();
    List<Bulletin> bulletins = bulletinRepository.findBulletinsForController();
    assertFalse(bulletins.isEmpty());
    Bulletin bulletin = bulletins.get(0);
    assertEquals(bulletin.getCategory(), category);
    assertEquals(bulletin.getMessage(), expectedOutput);
    assertEquals(bulletin.getLevel(), severity);
}
 
Example #14
Source File: FlowController.java    From nifi with Apache License 2.0 5 votes vote down vote up
public static FlowController createClusteredInstance(
        final FlowFileEventRepository flowFileEventRepo,
        final NiFiProperties properties,
        final Authorizer authorizer,
        final AuditService auditService,
        final StringEncryptor encryptor,
        final NodeProtocolSender protocolSender,
        final BulletinRepository bulletinRepo,
        final ClusterCoordinator clusterCoordinator,
        final HeartbeatMonitor heartbeatMonitor,
        final LeaderElectionManager leaderElectionManager,
        final VariableRegistry variableRegistry,
        final FlowRegistryClient flowRegistryClient,
        final ExtensionManager extensionManager) {

    final FlowController flowController = new FlowController(
            flowFileEventRepo,
            properties,
            authorizer,
            auditService,
            encryptor,
            /* configuredForClustering */ true,
            protocolSender,
            bulletinRepo,
            clusterCoordinator,
            heartbeatMonitor,
            leaderElectionManager,
            variableRegistry,
            flowRegistryClient,
            extensionManager);

    return flowController;
}
 
Example #15
Source File: TestAlertHandler.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void testAlertWithDefaultValues() {

    final Map<String, String> attributes = new HashMap<>();
    final Map<String, Object> metrics = new HashMap<>();

    final String category = "Rules Triggered Alert";
    final String message = "An alert was triggered by a rules based action.";
    final String severity =  "INFO";
    metrics.put("jvmHeap", "1000000");
    metrics.put("cpu", "90");

    final String expectedOutput = "An alert was triggered by a rules-based action.\n" +
            "Alert Facts:\n" +
            "Field: cpu, Value: 90\n" +
            "Field: jvmHeap, Value: 1000000\n";

    final Action action = new Action();
    action.setType("ALERT");
    action.setAttributes(attributes);
    alertHandler.execute(reportingContext, action, metrics);
    BulletinRepository bulletinRepository = reportingContext.getBulletinRepository();
    List<Bulletin> bulletins = bulletinRepository.findBulletinsForController();
    assertFalse(bulletins.isEmpty());
    Bulletin bulletin = bulletins.get(0);
    assertEquals(bulletin.getCategory(), category);
    assertEquals(bulletin.getMessage(), expectedOutput);
    assertEquals(bulletin.getLevel(), severity);
}
 
Example #16
Source File: StandardNiFiServiceFacade.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
private List<BulletinEntity> getProcessGroupBulletins(final ProcessGroup group) {
    final List<Bulletin> bulletins = new ArrayList<>(bulletinRepository.findBulletinsForGroupBySource(group.getIdentifier()));

    for (final ProcessGroup descendantGroup : group.findAllProcessGroups()) {
        bulletins.addAll(bulletinRepository.findBulletinsForGroupBySource(descendantGroup.getIdentifier()));
    }

    List<BulletinEntity> bulletinEntities = new ArrayList<>();
    for (final Bulletin bulletin : bulletins) {
        bulletinEntities.add(entityFactory.createBulletinEntity(dtoFactory.createBulletinDto(bulletin), authorizeBulletin(bulletin)));
    }

    return pruneAndSortBulletins(bulletinEntities, BulletinRepository.MAX_BULLETINS_PER_COMPONENT);
}
 
Example #17
Source File: StandardRootGroupPort.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
public StandardRootGroupPort(final String id, final String name, final ProcessGroup processGroup,
        final TransferDirection direction, final ConnectableType type, final Authorizer authorizer,
        final BulletinRepository bulletinRepository, final ProcessScheduler scheduler, final boolean secure,
        final NiFiProperties nifiProperties) {
    super(id, name, processGroup, type, scheduler);

    setScheduldingPeriod(MINIMUM_SCHEDULING_NANOS + " nanos");
    this.authorizer = authorizer;
    this.secure = secure;
    this.identityMappings = IdentityMappingUtil.getIdentityMappings(nifiProperties);
    this.bulletinRepository = bulletinRepository;
    this.scheduler = scheduler;
    setYieldPeriod("100 millis");
    eventReporter = new EventReporter() {
        private static final long serialVersionUID = 1L;

        @Override
        public void reportEvent(final Severity severity, final String category, final String message) {
            final String groupId = StandardRootGroupPort.this.getProcessGroup().getIdentifier();
            final String sourceId = StandardRootGroupPort.this.getIdentifier();
            final String sourceName = StandardRootGroupPort.this.getName();
            final ComponentType componentType = direction == TransferDirection.RECEIVE ? ComponentType.INPUT_PORT : ComponentType.OUTPUT_PORT;
            bulletinRepository.addBulletin(BulletinFactory.createBulletin(groupId, sourceId, componentType, sourceName, category, severity.name(), message));
        }
    };

    relationships = direction == TransferDirection.RECEIVE ? Collections.singleton(AbstractPort.PORT_RELATIONSHIP) : Collections.<Relationship>emptySet();
}
 
Example #18
Source File: BulletinEnumerator.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
public void reset() {
    BulletinRepository bulletinRepo = context.getBulletinRepository();
    List<Bulletin> fullBulletinList = new ArrayList<>(bulletinRepo.findBulletinsForController());
    fullBulletinList.addAll(bulletinRepo.findBulletins((new BulletinQuery.Builder()).sourceType(ComponentType.PROCESSOR).build()));
    fullBulletinList.addAll(bulletinRepo.findBulletins((new BulletinQuery.Builder()).sourceType(ComponentType.INPUT_PORT).build()));
    fullBulletinList.addAll(bulletinRepo.findBulletins((new BulletinQuery.Builder()).sourceType(ComponentType.OUTPUT_PORT).build()));
    fullBulletinList.addAll(bulletinRepo.findBulletins((new BulletinQuery.Builder()).sourceType(ComponentType.REMOTE_PROCESS_GROUP).build()));
    fullBulletinList.addAll(bulletinRepo.findBulletins((new BulletinQuery.Builder()).sourceType(ComponentType.REPORTING_TASK).build()));
    fullBulletinList.addAll(bulletinRepo.findBulletins((new BulletinQuery.Builder()).sourceType(ComponentType.CONTROLLER_SERVICE).build()));

    bulletinIterator = fullBulletinList.iterator();
}
 
Example #19
Source File: StandardRemoteProcessGroup.java    From nifi with Apache License 2.0 5 votes vote down vote up
public StandardRemoteProcessGroup(final String id, final String targetUris, final ProcessGroup processGroup, final ProcessScheduler processScheduler,
                                  final BulletinRepository bulletinRepository, final SSLContext sslContext, final NiFiProperties nifiProperties,
                                  final StateManager stateManager) {
    this.nifiProperties = nifiProperties;
    this.stateManager = stateManager;
    this.id = requireNonNull(id);

    this.targetUris = targetUris;
    this.targetId = null;
    this.processGroup = new AtomicReference<>(processGroup);
    this.sslContext = sslContext;
    this.scheduler = processScheduler;
    this.authorizationIssue = "Establishing connection to " + targetUris;

    final String expirationPeriod = nifiProperties.getProperty(NiFiProperties.REMOTE_CONTENTS_CACHE_EXPIRATION, "30 secs");
    remoteContentsCacheExpiration = FormatUtils.getTimeDuration(expirationPeriod, TimeUnit.MILLISECONDS);

    eventReporter = new EventReporter() {
        private static final long serialVersionUID = 1L;

        @Override
        public void reportEvent(final Severity severity, final String category, final String message) {
            final String groupId = StandardRemoteProcessGroup.this.getProcessGroup().getIdentifier();
            final String groupName = StandardRemoteProcessGroup.this.getProcessGroup().getName();
            final String sourceId = StandardRemoteProcessGroup.this.getIdentifier();
            final String sourceName = StandardRemoteProcessGroup.this.getName();
            bulletinRepository.addBulletin(BulletinFactory.createBulletin(groupId, groupName, sourceId, ComponentType.REMOTE_PROCESS_GROUP,
                    sourceName, category, severity.name(), message));
        }
    };

    backgroundThreadExecutor = new FlowEngine(1, "Remote Process Group " + id, true);
}
 
Example #20
Source File: StandardPublicPort.java    From nifi with Apache License 2.0 5 votes vote down vote up
public StandardPublicPort(final String id, final String name,
                          final TransferDirection direction, final ConnectableType type, final Authorizer authorizer,
                          final BulletinRepository bulletinRepository, final ProcessScheduler scheduler, final boolean secure,
                          final String yieldPeriod, final List<IdentityMapping> identityMappings) {

    super(id, name, type, scheduler);

    setScheduldingPeriod(MINIMUM_SCHEDULING_NANOS + " nanos");
    this.authorizer = authorizer;
    this.secure = secure;
    this.identityMappings = identityMappings;
    this.bulletinRepository = bulletinRepository;
    this.scheduler = scheduler;
    this.direction = direction;
    setYieldPeriod(yieldPeriod);
    eventReporter = new EventReporter() {
        private static final long serialVersionUID = 1L;

        @Override
        public void reportEvent(final Severity severity, final String category, final String message) {
            final String groupId = StandardPublicPort.this.getProcessGroup().getIdentifier();
            final String groupName = StandardPublicPort.this.getProcessGroup().getName();
            final String sourceId = StandardPublicPort.this.getIdentifier();
            final String sourceName = StandardPublicPort.this.getName();
            final ComponentType componentType = direction == TransferDirection.RECEIVE ? ComponentType.INPUT_PORT : ComponentType.OUTPUT_PORT;
            bulletinRepository.addBulletin(BulletinFactory.createBulletin(groupId, groupName, sourceId, componentType, sourceName, category, severity.name(), message));
        }
    };

    relationships = direction == TransferDirection.RECEIVE ? Collections.singleton(AbstractPort.PORT_RELATIONSHIP) : Collections.emptySet();
}
 
Example #21
Source File: StandardRemoteProcessGroup.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
public StandardRemoteProcessGroup(final String id, final String targetUris, final ProcessGroup processGroup,
                                  final FlowController flowController, final SSLContext sslContext, final NiFiProperties nifiProperties) {
    this.nifiProperties = nifiProperties;
    this.id = requireNonNull(id);

    this.targetUris = targetUris;
    this.targetId = null;
    this.processGroup = new AtomicReference<>(processGroup);
    this.sslContext = sslContext;
    this.scheduler = flowController.getProcessScheduler();
    this.authorizationIssue = "Establishing connection to " + targetUris;

    final BulletinRepository bulletinRepository = flowController.getBulletinRepository();
    eventReporter = new EventReporter() {
        private static final long serialVersionUID = 1L;

        @Override
        public void reportEvent(final Severity severity, final String category, final String message) {
            final String groupId = StandardRemoteProcessGroup.this.getProcessGroup().getIdentifier();
            final String sourceId = StandardRemoteProcessGroup.this.getIdentifier();
            final String sourceName = StandardRemoteProcessGroup.this.getName();
            bulletinRepository.addBulletin(BulletinFactory.createBulletin(groupId, sourceId, ComponentType.REMOTE_PROCESS_GROUP,
                    sourceName, category, severity.name(), message));
        }
    };

    final Runnable checkAuthorizations = new InitializationTask();
    backgroundThreadExecutor = new FlowEngine(1, "Remote Process Group " + id + ": " + targetUris);
    backgroundThreadExecutor.scheduleWithFixedDelay(checkAuthorizations, 5L, 30L, TimeUnit.SECONDS);
}
 
Example #22
Source File: StandardFlowSerializerTest.java    From nifi with Apache License 2.0 5 votes vote down vote up
@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 String algorithm = nifiProperties.getProperty(NiFiProperties.SENSITIVE_PROPS_ALGORITHM);
    final String provider = nifiProperties.getProperty(NiFiProperties.SENSITIVE_PROPS_PROVIDER);
    final String password = nifiProperties.getProperty(NiFiProperties.SENSITIVE_PROPS_KEY);
    final StringEncryptor encryptor = StringEncryptor.createEncryptor(algorithm, provider, password);

    // use the system bundle
    systemBundle = SystemBundle.create(nifiProperties);
    extensionManager = new StandardExtensionDiscoveringManager();
    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), extensionManager);

    serializer = new StandardFlowSerializer(encryptor);
}
 
Example #23
Source File: ControllerFacade.java    From nifi with Apache License 2.0 4 votes vote down vote up
public ProcessorDiagnosticsDTO getProcessorDiagnostics(final ProcessorNode processor, final ProcessorStatus processorStatus, final BulletinRepository bulletinRepository,
        final Function<String, ControllerServiceEntity> serviceEntityFactory) {
    return dtoFactory.createProcessorDiagnosticsDto(processor, processorStatus, bulletinRepository, flowController, serviceEntityFactory);
}
 
Example #24
Source File: SocketProtocolListener.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Override
public void setBulletinRepository(final BulletinRepository bulletinRepository) {
    this.bulletinRepository = bulletinRepository;
}
 
Example #25
Source File: ClusterCoordinationProtocolSenderListener.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Override
public void setBulletinRepository(final BulletinRepository bulletinRepository) {
    listener.setBulletinRepository(bulletinRepository);
    sender.setBulletinRepository(bulletinRepository);
}
 
Example #26
Source File: TestFlowController.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Before
public void setup() {

    flowFileEventRepo = Mockito.mock(FlowFileEventRepository.class);
    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 String propsFile = "src/test/resources/flowcontrollertest.nifi.properties";
    nifiProperties = NiFiProperties.createBasicNiFiProperties(propsFile, otherProps);
    encryptor = createEncryptorFromProperties(nifiProperties);

    // use the system bundle
    systemBundle = SystemBundle.create(nifiProperties);
    extensionManager = new StandardExtensionDiscoveringManager();
    extensionManager.discoverExtensions(systemBundle, Collections.emptySet());

    User user1 = new User.Builder().identifier("user-id-1").identity("user-1").build();
    User user2 = new User.Builder().identifier("user-id-2").identity("user-2").build();

    Group group1 = new Group.Builder().identifier("group-id-1").name("group-1").addUser(user1.getIdentifier()).build();
    Group group2 = new Group.Builder().identifier("group-id-2").name("group-2").build();

    AccessPolicy policy1 = new AccessPolicy.Builder()
            .identifier("policy-id-1")
            .resource("resource1")
            .action(RequestAction.READ)
            .addUser(user1.getIdentifier())
            .addUser(user2.getIdentifier())
            .build();

    AccessPolicy policy2 = new AccessPolicy.Builder()
            .identifier("policy-id-2")
            .resource("resource2")
            .action(RequestAction.READ)
            .addGroup(group1.getIdentifier())
            .addGroup(group2.getIdentifier())
            .addUser(user1.getIdentifier())
            .addUser(user2.getIdentifier())
            .build();

    Set<Group> groups1 = new LinkedHashSet<>();
    groups1.add(group1);
    groups1.add(group2);

    Set<User> users1 = new LinkedHashSet<>();
    users1.add(user1);
    users1.add(user2);

    Set<AccessPolicy> policies1 = new LinkedHashSet<>();
    policies1.add(policy1);
    policies1.add(policy2);

    authorizer = new MockPolicyBasedAuthorizer(groups1, users1, policies1);
    variableRegistry = new FileBasedVariableRegistry(nifiProperties.getVariableRegistryPropertiesPaths());

    bulletinRepo = Mockito.mock(BulletinRepository.class);
    controller = FlowController.createStandaloneInstance(flowFileEventRepo, nifiProperties, authorizer,
        auditService, encryptor, bulletinRepo, variableRegistry, Mockito.mock(FlowRegistryClient.class), extensionManager);
}
 
Example #27
Source File: FlowControllerFactoryBean.java    From nifi with Apache License 2.0 4 votes vote down vote up
public void setBulletinRepository(final BulletinRepository bulletinRepository) {
    this.bulletinRepository = bulletinRepository;
}
 
Example #28
Source File: ControllerServiceLogObserver.java    From nifi with Apache License 2.0 4 votes vote down vote up
public ControllerServiceLogObserver(final BulletinRepository bulletinRepository, final ControllerServiceNode serviceNode) {
    this.bulletinRepository = bulletinRepository;
    this.serviceNode = serviceNode;
}
 
Example #29
Source File: ReportingTaskLogObserver.java    From nifi with Apache License 2.0 4 votes vote down vote up
public ReportingTaskLogObserver(final BulletinRepository bulletinRepository, final ReportingTaskNode taskNode) {
    this.bulletinRepository = bulletinRepository;
    this.taskNode = taskNode;
}
 
Example #30
Source File: ProcessorLogObserver.java    From nifi with Apache License 2.0 4 votes vote down vote up
public ProcessorLogObserver(BulletinRepository bulletinRepository, ProcessorNode processorNode) {
    this.bulletinRepository = bulletinRepository;
    this.processorNode = processorNode;
}