org.apache.nifi.controller.FlowController Java Examples
The following examples show how to use
org.apache.nifi.controller.FlowController.
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: TestConnectableTask.java From nifi with Apache License 2.0 | 6 votes |
private ConnectableTask createTask(final Connectable connectable) { final FlowController flowController = Mockito.mock(FlowController.class); Mockito.when(flowController.getStateManagerProvider()).thenReturn(Mockito.mock(StateManagerProvider.class)); final RepositoryContext repoContext = Mockito.mock(RepositoryContext.class); Mockito.when(repoContext.getFlowFileEventRepository()).thenReturn(Mockito.mock(FlowFileEventRepository.class)); final RepositoryContextFactory contextFactory = Mockito.mock(RepositoryContextFactory.class); Mockito.when(contextFactory.newProcessContext(Mockito.any(Connectable.class), Mockito.any(AtomicLong.class))).thenReturn(repoContext); final LifecycleState scheduleState = new LifecycleState(); final StringEncryptor encryptor = Mockito.mock(StringEncryptor.class); return new ConnectableTask(Mockito.mock(SchedulingAgent.class), connectable, flowController, contextFactory, scheduleState, encryptor); }
Example #2
Source File: ControllerServiceLoader.java From localization_nifi with Apache License 2.0 | 6 votes |
public static void enableControllerServices(final Map<ControllerServiceNode, Element> nodeMap, final FlowController controller, final StringEncryptor encryptor, final boolean autoResumeState) { // Start services if (autoResumeState) { final Set<ControllerServiceNode> nodesToEnable = new HashSet<>(); for (final ControllerServiceNode node : nodeMap.keySet()) { final Element controllerServiceElement = nodeMap.get(node); final ControllerServiceDTO dto; synchronized (controllerServiceElement.getOwnerDocument()) { dto = FlowFromDOMFactory.getControllerService(controllerServiceElement, encryptor); } final ControllerServiceState state = ControllerServiceState.valueOf(dto.getState()); if (state == ControllerServiceState.ENABLED) { nodesToEnable.add(node); } } enableControllerServices(nodesToEnable, controller, autoResumeState); } }
Example #3
Source File: StandardReportingContext.java From nifi with Apache License 2.0 | 6 votes |
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 #4
Source File: FingerprintFactory.java From localization_nifi with Apache License 2.0 | 6 votes |
private void addControllerServiceFingerprint(final StringBuilder builder, final ControllerServiceDTO dto, final FlowController controller) { builder.append(dto.getId()); builder.append(dto.getType()); builder.append(dto.getName()); builder.append(dto.getComments()); builder.append(dto.getAnnotationData()); builder.append(dto.getState()); // create an instance of the ControllerService so that we know the default property values ControllerService controllerService = null; try { if (controller != null) { controllerService = controller.createControllerService(dto.getType(), UUID.randomUUID().toString(), false).getControllerServiceImplementation(); } } catch (Exception e) { logger.warn("Unable to create ControllerService of type {} due to {}; its default properties will be fingerprinted instead of being ignored.", dto.getType(), e.toString()); if (logger.isDebugEnabled()) { logger.warn("", e); } } addPropertiesFingerprint(builder, controllerService, dto.getProperties()); }
Example #5
Source File: ControllerServiceLoader.java From nifi with Apache License 2.0 | 6 votes |
private static ControllerServiceNode createControllerService(final FlowController flowController, final Element controllerServiceElement, final StringEncryptor encryptor, final FlowEncodingVersion encodingVersion) { final ControllerServiceDTO dto = FlowFromDOMFactory.getControllerService(controllerServiceElement, encryptor, encodingVersion); BundleCoordinate coordinate; try { coordinate = BundleUtils.getCompatibleBundle(flowController.getExtensionManager(), dto.getType(), dto.getBundle()); } catch (final IllegalStateException e) { final BundleDTO bundleDTO = dto.getBundle(); if (bundleDTO == null) { coordinate = BundleCoordinate.UNKNOWN_COORDINATE; } else { coordinate = new BundleCoordinate(bundleDTO.getGroup(), bundleDTO.getArtifact(), bundleDTO.getVersion()); } } final ControllerServiceNode node = flowController.getFlowManager().createControllerService(dto.getType(), dto.getId(), coordinate, Collections.emptySet(), false, true); node.setName(dto.getName()); node.setComments(dto.getComments()); node.setVersionedComponentId(dto.getVersionedComponentId()); return node; }
Example #6
Source File: TestStandardControllerServiceProvider.java From localization_nifi with Apache License 2.0 | 6 votes |
@Test public void testEnableReferencingComponents() { final ProcessGroup procGroup = new MockProcessGroup(); final FlowController controller = Mockito.mock(FlowController.class); Mockito.when(controller.getGroup(Mockito.anyString())).thenReturn(procGroup); final StandardProcessScheduler scheduler = createScheduler(); final StandardControllerServiceProvider provider = new StandardControllerServiceProvider(controller, null, null, stateManagerProvider, variableRegistry, NiFiProperties.createBasicNiFiProperties(null, null)); final ControllerServiceNode serviceNode = provider.createControllerService(ServiceA.class.getName(), "1", false); final ProcessorNode procNode = createProcessor(scheduler, provider); serviceNode.addReference(procNode); // procNode.setScheduledState(ScheduledState.STOPPED); provider.unscheduleReferencingComponents(serviceNode); assertEquals(ScheduledState.STOPPED, procNode.getScheduledState()); // procNode.setScheduledState(ScheduledState.RUNNING); provider.unscheduleReferencingComponents(serviceNode); assertEquals(ScheduledState.STOPPED, procNode.getScheduledState()); }
Example #7
Source File: TestStandardProcessScheduler.java From localization_nifi with Apache License 2.0 | 6 votes |
@Before public void setup() throws InitializationException { System.setProperty(NiFiProperties.PROPERTIES_FILE_PATH, TestStandardProcessScheduler.class.getResource("/nifi.properties").getFile()); this.nifiProperties = NiFiProperties.createBasicNiFiProperties(null, null); scheduler = new StandardProcessScheduler(Mockito.mock(ControllerServiceProvider.class), null, stateMgrProvider, variableRegistry, nifiProperties); scheduler.setSchedulingAgent(SchedulingStrategy.TIMER_DRIVEN, Mockito.mock(SchedulingAgent.class)); reportingTask = new TestReportingTask(); final ReportingInitializationContext config = new StandardReportingInitializationContext(UUID.randomUUID().toString(), "Test", SchedulingStrategy.TIMER_DRIVEN, "5 secs", Mockito.mock(ComponentLog.class), null, nifiProperties); reportingTask.initialize(config); final ValidationContextFactory validationContextFactory = new StandardValidationContextFactory(null, variableRegistry); final ComponentLog logger = Mockito.mock(ComponentLog.class); taskNode = new StandardReportingTaskNode(reportingTask, UUID.randomUUID().toString(), null, scheduler, validationContextFactory, variableRegistry, logger); controller = Mockito.mock(FlowController.class); rootGroup = new MockProcessGroup(); Mockito.when(controller.getGroup(Mockito.anyString())).thenReturn(rootGroup); }
Example #8
Source File: StandardXMLFlowConfigurationDAO.java From localization_nifi with Apache License 2.0 | 6 votes |
@Override public synchronized void load(final FlowController controller, final DataFlow dataFlow) throws IOException, FlowSerializationException, FlowSynchronizationException, UninheritableFlowException { final FlowSynchronizer flowSynchronizer = new StandardFlowSynchronizer(encryptor, nifiProperties); controller.synchronize(flowSynchronizer, dataFlow); if (StandardFlowSynchronizer.isEmpty(dataFlow)) { // If the dataflow is empty, we want to save it. We do this because when we start up a brand new cluster with no // dataflow, we need to ensure that the flow is consistent across all nodes in the cluster and that upon restart // of NiFi, the root group ID does not change. However, we don't always want to save it, because if the flow is // not empty, then we can get into a bad situation, since the Processors, etc. don't have the appropriate "Scheduled // State" yet (since they haven't yet been scheduled). So if there are components in the flow and we save it, we // may end up saving the flow in such a way that all components are stopped. // We save based on the controller, not the provided data flow because Process Groups may contain 'local' templates. save(controller); } }
Example #9
Source File: TestProcessorLifecycle.java From localization_nifi with Apache License 2.0 | 6 votes |
private FlowController 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(null, addProps); return FlowController.createStandaloneInstance(mock(FlowFileEventRepository.class), nifiProperties, mock(Authorizer.class), mock(AuditService.class), null, new VolatileBulletinRepository(), new FileBasedVariableRegistry(nifiProperties.getVariableRegistryPropertiesPaths())); }
Example #10
Source File: TestStandardControllerServiceProvider.java From nifi with Apache License 2.0 | 6 votes |
private ProcessorNode createProcessor(final StandardProcessScheduler scheduler, final ControllerServiceProvider serviceProvider) { final ReloadComponent reloadComponent = Mockito.mock(ReloadComponent.class); final Processor processor = new DummyProcessor(); final MockProcessContext context = new MockProcessContext(processor, Mockito.mock(StateManager.class), variableRegistry); final MockProcessorInitializationContext mockInitContext = new MockProcessorInitializationContext(processor, context); processor.initialize(mockInitContext); final LoggableComponent<Processor> dummyProcessor = new LoggableComponent<>(processor, systemBundle.getBundleDetails().getCoordinate(), null); final ProcessorNode procNode = new StandardProcessorNode(dummyProcessor, mockInitContext.getIdentifier(), new StandardValidationContextFactory(serviceProvider, null), scheduler, serviceProvider, new StandardComponentVariableRegistry(VariableRegistry.EMPTY_REGISTRY), reloadComponent, extensionManager, new SynchronousValidationTrigger()); final FlowManager flowManager = Mockito.mock(FlowManager.class); final FlowController flowController = Mockito.mock(FlowController.class ); Mockito.when(flowController.getFlowManager()).thenReturn(flowManager); final ProcessGroup group = new StandardProcessGroup(UUID.randomUUID().toString(), serviceProvider, scheduler, null, null, flowController, new MutableVariableRegistry(variableRegistry)); group.addProcessor(procNode); procNode.setProcessGroup(group); return procNode; }
Example #11
Source File: ControllerServiceLoader.java From nifi with Apache License 2.0 | 6 votes |
public static Map<ControllerServiceNode, Element> loadControllerServices(final List<Element> serviceElements, final FlowController controller, final ProcessGroup parentGroup, final StringEncryptor encryptor, final FlowEncodingVersion encodingVersion) { final Map<ControllerServiceNode, Element> nodeMap = new HashMap<>(); for (final Element serviceElement : serviceElements) { final ControllerServiceNode serviceNode = createControllerService(controller, serviceElement, encryptor, encodingVersion); if (parentGroup == null) { controller.getFlowManager().addRootControllerService(serviceNode); } else { parentGroup.addControllerService(serviceNode); } // We need to clone the node because it will be used in a separate thread below, and // Element is not thread-safe. nodeMap.put(serviceNode, (Element) serviceElement.cloneNode(true)); } for (final Map.Entry<ControllerServiceNode, Element> entry : nodeMap.entrySet()) { configureControllerService(entry.getKey(), entry.getValue(), encryptor, encodingVersion); } return nodeMap; }
Example #12
Source File: StandardFlowSerializerTest.java From nifi with Apache License 2.0 | 5 votes |
@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 #13
Source File: StandardReportingTaskNode.java From nifi with Apache License 2.0 | 5 votes |
public StandardReportingTaskNode(final LoggableComponent<ReportingTask> reportingTask, final String id, final FlowController controller, final ProcessScheduler processScheduler, final ValidationContextFactory validationContextFactory, final ComponentVariableRegistry variableRegistry, final ReloadComponent reloadComponent, final ExtensionManager extensionManager, final ValidationTrigger validationTrigger) { super(reportingTask, id, controller.getControllerServiceProvider(), processScheduler, validationContextFactory, variableRegistry, reloadComponent, extensionManager, validationTrigger); this.flowController = controller; }
Example #14
Source File: TimerDrivenSchedulingAgent.java From nifi with Apache License 2.0 | 5 votes |
public TimerDrivenSchedulingAgent(final FlowController flowController, final FlowEngine flowEngine, final RepositoryContextFactory contextFactory, final StringEncryptor encryptor, final NiFiProperties nifiProperties) { super(flowEngine); this.flowController = flowController; this.contextFactory = contextFactory; this.encryptor = encryptor; final String boredYieldDuration = nifiProperties.getBoredYieldDuration(); try { noWorkYieldNanos = FormatUtils.getTimeDuration(boredYieldDuration, TimeUnit.NANOSECONDS); } catch (final IllegalArgumentException e) { throw new RuntimeException("Failed to create SchedulingAgent because the " + NiFiProperties.BORED_YIELD_DURATION + " property is set to an invalid time duration: " + boredYieldDuration); } }
Example #15
Source File: StandardXMLFlowConfigurationDAO.java From localization_nifi with Apache License 2.0 | 5 votes |
@Override public void save(final FlowController flow) throws IOException { LOG.trace("Saving flow to disk"); try (final OutputStream outStream = Files.newOutputStream(flowXmlPath, StandardOpenOption.WRITE, StandardOpenOption.CREATE); final OutputStream gzipOut = new GZIPOutputStream(outStream)) { save(flow, gzipOut); } LOG.debug("Finished saving flow to disk"); }
Example #16
Source File: StandardXMLFlowConfigurationDAO.java From nifi with Apache License 2.0 | 5 votes |
@Override public synchronized void save(final FlowController controller, final boolean archive) throws IOException { if (null == controller) { throw new NullPointerException(); } Path tempFile; Path configFile; configFile = flowXmlPath; tempFile = configFile.getParent().resolve(configFile.toFile().getName() + ".new.xml.gz"); try (final OutputStream fileOut = Files.newOutputStream(tempFile); final OutputStream outStream = new GZIPOutputStream(fileOut)) { final StandardFlowSerializer xmlTransformer = new StandardFlowSerializer(encryptor); controller.serialize(xmlTransformer, outStream); Files.deleteIfExists(configFile); FileUtils.renameFile(tempFile.toFile(), configFile.toFile(), 5, true); } catch (final FlowSerializationException fse) { throw new IOException(fse); } finally { Files.deleteIfExists(tempFile); } if (archive) { try { archiveManager.archive(); } catch (final Exception ex) { LOG.error("Unable to archive flow configuration as requested due to " + ex); if (LOG.isDebugEnabled()) { LOG.error("", ex); } } } }
Example #17
Source File: ConnectionMissingCheck.java From nifi with Apache License 2.0 | 5 votes |
@Override public FlowInheritability checkInheritability(final DataFlow existingFlow, final DataFlow proposedFlow, final FlowController flowController) { final Document flowDocument = proposedFlow.getFlowDocument(); final Element rootGroupElement = (Element) flowDocument.getDocumentElement().getElementsByTagName("rootGroup").item(0); final FlowEncodingVersion encodingVersion = FlowEncodingVersion.parse(flowDocument.getDocumentElement()); final ProcessGroupDTO rootGroupDto = FlowFromDOMFactory.getProcessGroup(null, rootGroupElement, null, encodingVersion); final Set<String> connectionIds = findAllConnectionIds(rootGroupDto); final FlowFileRepository flowFileRepository = flowController.getRepositoryContextFactory().getFlowFileRepository(); final Set<String> queuesWithFlowFiles; try { queuesWithFlowFiles = flowFileRepository.findQueuesWithFlowFiles(flowController.createSwapManager()); } catch (final IOException ioe) { throw new FlowSynchronizationException("Failed to determine which connections have FlowFiles queued", ioe); } logger.debug("The following {} Connections/Queues have data queued up currently: {}", queuesWithFlowFiles.size(), queuesWithFlowFiles); for (final String queueId : queuesWithFlowFiles) { if (!connectionIds.contains(queueId)) { return FlowInheritability.notInheritable("Proposed Flow does not contain a Connection with ID " + queueId + " but this instance has data queued in that connection"); } } return FlowInheritability.inheritable(); }
Example #18
Source File: ComponentDAO.java From localization_nifi with Apache License 2.0 | 5 votes |
/** * Locates the specified ProcessGroup. * * @param flowController controller * @param groupId id * @return group */ protected ProcessGroup locateProcessGroup(FlowController flowController, String groupId) { ProcessGroup group = flowController.getGroup(groupId); if (group == null) { throw new ResourceNotFoundException(String.format("Unable to locate group with id '%s'.", groupId)); } return group; }
Example #19
Source File: StandardProcessGroup.java From localization_nifi with Apache License 2.0 | 5 votes |
public StandardProcessGroup(final String id, final ControllerServiceProvider serviceProvider, final StandardProcessScheduler scheduler, final NiFiProperties nifiProps, final StringEncryptor encryptor, final FlowController flowController, final VariableRegistry variableRegistry) { this.id = id; this.controllerServiceProvider = serviceProvider; this.parent = new AtomicReference<>(); this.scheduler = scheduler; this.comments = new AtomicReference<>(""); this.encryptor = encryptor; this.flowController = flowController; this.variableRegistry = variableRegistry; name = new AtomicReference<>(); position = new AtomicReference<>(new Position(0D, 0D)); }
Example #20
Source File: QuartzSchedulingAgent.java From localization_nifi with Apache License 2.0 | 5 votes |
public QuartzSchedulingAgent(final FlowController flowController, final FlowEngine flowEngine, final ProcessContextFactory contextFactory, final StringEncryptor enryptor, final VariableRegistry variableRegistry) { super(flowEngine); this.flowController = flowController; this.contextFactory = contextFactory; this.encryptor = enryptor; this.variableRegistry = variableRegistry; }
Example #21
Source File: ContinuallyRunProcessorTask.java From localization_nifi with Apache License 2.0 | 5 votes |
public ContinuallyRunProcessorTask(final SchedulingAgent schedulingAgent, final ProcessorNode procNode, final FlowController flowController, final ProcessContextFactory contextFactory, final ScheduleState scheduleState, final StandardProcessContext processContext) { this.schedulingAgent = schedulingAgent; this.procNode = procNode; this.scheduleState = scheduleState; this.numRelationships = procNode.getRelationships().size(); this.flowController = flowController; context = contextFactory.newProcessContext(procNode, new AtomicLong(0L)); this.processContext = processContext; }
Example #22
Source File: StandardXMLFlowConfigurationDAO.java From localization_nifi with Apache License 2.0 | 5 votes |
@Override public synchronized void save(final FlowController controller, final boolean archive) throws IOException { if (null == controller) { throw new NullPointerException(); } Path tempFile; Path configFile; configFile = flowXmlPath; tempFile = configFile.getParent().resolve(configFile.toFile().getName() + ".new.xml.gz"); try (final OutputStream fileOut = Files.newOutputStream(tempFile); final OutputStream outStream = new GZIPOutputStream(fileOut)) { final StandardFlowSerializer xmlTransformer = new StandardFlowSerializer(encryptor); controller.serialize(xmlTransformer, outStream); Files.deleteIfExists(configFile); FileUtils.renameFile(tempFile.toFile(), configFile.toFile(), 5, true); } catch (final FlowSerializationException fse) { throw new IOException(fse); } finally { Files.deleteIfExists(tempFile); } if (archive) { try { archiveManager.archive(); } catch (final Exception ex) { LOG.error("Unable to archive flow configuration as requested due to " + ex); if (LOG.isDebugEnabled()) { LOG.error("", ex); } } } }
Example #23
Source File: StandardControllerServiceProvider.java From localization_nifi with Apache License 2.0 | 5 votes |
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 #24
Source File: TestProcessorLifecycle.java From localization_nifi with Apache License 2.0 | 5 votes |
/** * */ private void setControllerRootGroup(FlowController controller, ProcessGroup processGroup) { try { Method m = FlowController.class.getDeclaredMethod("setRootGroup", ProcessGroup.class); m.setAccessible(true); m.invoke(controller, processGroup); controller.initializeFlow(); } catch (Exception e) { throw new IllegalStateException("Failed to set root group", e); } }
Example #25
Source File: TestStandardControllerServiceProvider.java From localization_nifi with Apache License 2.0 | 5 votes |
@Test public void validateEnableServices() { StandardProcessScheduler scheduler = createScheduler(); FlowController controller = Mockito.mock(FlowController.class); StandardControllerServiceProvider provider = new StandardControllerServiceProvider(controller, scheduler, null, stateManagerProvider, variableRegistry, NiFiProperties.createBasicNiFiProperties(null, null)); ProcessGroup procGroup = new MockProcessGroup(); Mockito.when(controller.getGroup(Mockito.anyString())).thenReturn(procGroup); ControllerServiceNode A = provider.createControllerService(ServiceA.class.getName(), "A", false); ControllerServiceNode B = provider.createControllerService(ServiceA.class.getName(), "B", false); ControllerServiceNode C = provider.createControllerService(ServiceA.class.getName(), "C", false); ControllerServiceNode D = provider.createControllerService(ServiceB.class.getName(), "D", false); ControllerServiceNode E = provider.createControllerService(ServiceA.class.getName(), "E", false); ControllerServiceNode F = provider.createControllerService(ServiceB.class.getName(), "F", false); procGroup.addControllerService(A); procGroup.addControllerService(B); procGroup.addControllerService(C); procGroup.addControllerService(D); procGroup.addControllerService(E); procGroup.addControllerService(F); setProperty(A, ServiceA.OTHER_SERVICE.getName(), "B"); setProperty(B, ServiceA.OTHER_SERVICE.getName(), "D"); setProperty(C, ServiceA.OTHER_SERVICE.getName(), "B"); setProperty(C, ServiceA.OTHER_SERVICE_2.getName(), "D"); setProperty(E, ServiceA.OTHER_SERVICE.getName(), "A"); setProperty(E, ServiceA.OTHER_SERVICE_2.getName(), "F"); provider.enableControllerServices(Arrays.asList(A, B, C, D, E, F)); assertTrue(A.isActive()); assertTrue(B.isActive()); assertTrue(C.isActive()); assertTrue(D.isActive()); assertTrue(E.isActive()); assertTrue(F.isActive()); }
Example #26
Source File: TestStandardControllerServiceProvider.java From localization_nifi with Apache License 2.0 | 5 votes |
/** * This test is similar to the above, but different combination of service * dependencies * */ @Test public void validateEnableServices2() { StandardProcessScheduler scheduler = createScheduler(); FlowController controller = Mockito.mock(FlowController.class); StandardControllerServiceProvider provider = new StandardControllerServiceProvider(controller, scheduler, null, stateManagerProvider, variableRegistry, NiFiProperties.createBasicNiFiProperties(null, null)); ProcessGroup procGroup = new MockProcessGroup(); Mockito.when(controller.getGroup(Mockito.anyString())).thenReturn(procGroup); ControllerServiceNode A = provider.createControllerService(ServiceC.class.getName(), "A", false); ControllerServiceNode B = provider.createControllerService(ServiceA.class.getName(), "B", false); ControllerServiceNode C = provider.createControllerService(ServiceB.class.getName(), "C", false); ControllerServiceNode D = provider.createControllerService(ServiceA.class.getName(), "D", false); ControllerServiceNode F = provider.createControllerService(ServiceA.class.getName(), "F", false); procGroup.addControllerService(A); procGroup.addControllerService(B); procGroup.addControllerService(C); procGroup.addControllerService(D); procGroup.addControllerService(F); setProperty(A, ServiceC.REQ_SERVICE_1.getName(), "B"); setProperty(A, ServiceC.REQ_SERVICE_2.getName(), "D"); setProperty(B, ServiceA.OTHER_SERVICE.getName(), "C"); setProperty(F, ServiceA.OTHER_SERVICE.getName(), "D"); setProperty(D, ServiceA.OTHER_SERVICE.getName(), "C"); provider.enableControllerServices(Arrays.asList(C, F, A, B, D)); assertTrue(A.isActive()); assertTrue(B.isActive()); assertTrue(C.isActive()); assertTrue(D.isActive()); assertTrue(F.isActive()); }
Example #27
Source File: AccessPolicyResource.java From nifi with Apache License 2.0 | 5 votes |
public AccessPolicyResource(NiFiServiceFacade serviceFacade, Authorizer authorizer, NiFiProperties properties, RequestReplicator requestReplicator, ClusterCoordinator clusterCoordinator, FlowController flowController) { this.serviceFacade = serviceFacade; this.authorizer = authorizer; setProperties(properties); setRequestReplicator(requestReplicator); setClusterCoordinator(clusterCoordinator); setFlowController(flowController); }
Example #28
Source File: StatusRequestParser.java From nifi-minifi with Apache License 2.0 | 5 votes |
static ControllerServiceStatus parseControllerServiceStatusRequest(ControllerServiceNode controllerServiceNode, String statusTypes, FlowController flowController, Logger logger) { ControllerServiceStatus controllerServiceStatus = new ControllerServiceStatus(); String id = controllerServiceNode.getIdentifier(); controllerServiceStatus.setName(id); String[] statusSplits = statusTypes.split(","); List<Bulletin> bulletinList = flowController.getBulletinRepository().findBulletins( new BulletinQuery.Builder() .sourceIdMatches(id) .build()); for (String statusType : statusSplits) { switch (statusType.toLowerCase().trim()) { case "health": ControllerServiceHealth controllerServiceHealth = new ControllerServiceHealth(); controllerServiceHealth.setState(controllerServiceNode.getState().name()); controllerServiceHealth.setHasBulletins(!bulletinList.isEmpty()); Collection<ValidationResult> validationResults = controllerServiceNode.getValidationErrors(); controllerServiceHealth.setValidationErrorList(transformValidationResults(validationResults)); controllerServiceStatus.setControllerServiceHealth(controllerServiceHealth); break; case "bulletins": controllerServiceStatus.setBulletinList(transformBulletins(bulletinList)); break; } } return controllerServiceStatus; }
Example #29
Source File: StatusConfigReporter.java From nifi-minifi with Apache License 2.0 | 5 votes |
private static void handleReportingTaskRequest(RequestItem requestItem, FlowController flowController, List<ReportingTaskStatus> reportingTaskStatusList, Logger logger) { Set<ReportingTaskNode> reportingTaskNodes = flowController.getAllReportingTasks(); if (!reportingTaskNodes.isEmpty()) { for (ReportingTaskNode reportingTaskNode : reportingTaskNodes) { reportingTaskStatusList.add(parseReportingTaskStatusRequest(reportingTaskNode.getIdentifier(), reportingTaskNode, requestItem.options, flowController, logger)); } } }
Example #30
Source File: ReportingTaskProviderFactoryBean.java From nifi with Apache License 2.0 | 5 votes |
@Override public ReportingTaskProvider getObject() throws Exception { if (reportingTaskProvider == null) { reportingTaskProvider = context.getBean("flowController", FlowController.class); } return reportingTaskProvider; }