org.apache.nifi.scheduling.SchedulingStrategy Java Examples
The following examples show how to use
org.apache.nifi.scheduling.SchedulingStrategy.
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: StandardProcessorNode.java From nifi with Apache License 2.0 | 6 votes |
/** * Determines the number of concurrent tasks that may be running for this * processor. * * @param taskCount * a number of concurrent tasks this processor may have running * @throws IllegalArgumentException * if the given value is less than 1 */ @Override public synchronized void setMaxConcurrentTasks(final int taskCount) { if (isRunning()) { throw new IllegalStateException("Cannot modify Processor configuration while the Processor is running"); } if (taskCount < 1 && getSchedulingStrategy() != SchedulingStrategy.EVENT_DRIVEN) { throw new IllegalArgumentException("Cannot set Concurrent Tasks to " + taskCount + " for component " + getIdentifier() + " because Scheduling Strategy is not Event Driven"); } if (!isTriggeredSerially()) { concurrentTaskCount.set(taskCount); } }
Example #2
Source File: ControllerSearchServiceIntegrationTest.java From nifi with Apache License 2.0 | 6 votes |
@Test public void testSearchBasedOnRelationship() { // given final ProcessorNode processorNode1 = getProcessorNode("processor1", "name1", "", Optional.empty(), SchedulingStrategy.TIMER_DRIVEN, ExecutionNode.ALL, ScheduledState.RUNNING, ValidationStatus.VALID, getBasicRelationships(), "Processor", Mockito.mock(Processor.class), new HashMap<>(), AUTHORIZED); final ProcessorNode processorNode2 = getProcessorNode("processor2", "name2", "", Optional.empty(), SchedulingStrategy.TIMER_DRIVEN, ExecutionNode.ALL, ScheduledState.RUNNING, ValidationStatus.VALID, getBasicRelationships(), "Processor", Mockito.mock(Processor.class), new HashMap<>(), AUTHORIZED); givenRootProcessGroup() .withProcessor(processorNode1) .withProcessor(processorNode2) .withConnection(getConnection("connection1", "connection1name", getBasicRelationships(), processorNode1, processorNode2, AUTHORIZED)); // when whenExecuteSearch("success"); // then thenResultConsists() .ofProcessor(getSimpleResultFromRoot("processor1", "name1", "Relationship: success")) .ofProcessor(getSimpleResultFromRoot("processor2", "name2", "Relationship: success")) .ofConnection(getSimpleResultFromRoot("connection1", "connection1name", "Relationship: success")) .validate(results); }
Example #3
Source File: ControllerSearchServiceIntegrationTest.java From nifi with Apache License 2.0 | 6 votes |
@Test public void testSearchBasedOnProperty() { // given final Map<PropertyDescriptor, String> rawProperties = new HashMap<>(); final PropertyDescriptor descriptor1 = new PropertyDescriptor.Builder().name("property1").displayName("property1display").description("property1 description").sensitive(false).build(); final PropertyDescriptor descriptor2 = new PropertyDescriptor.Builder().name("property2").displayName("property2display").description("property2 description").sensitive(true).build(); rawProperties.put(descriptor1, "property1value"); rawProperties.put(descriptor2, "property2value"); final ProcessorNode processorNode = getProcessorNode("processor1", "name1", "", Optional.empty(), SchedulingStrategy.TIMER_DRIVEN, ExecutionNode.ALL, ScheduledState.RUNNING, ValidationStatus.VALID, new HashSet<>(), "Processor", Mockito.mock(Processor.class), rawProperties, AUTHORIZED); givenRootProcessGroup() .withProcessor(processorNode); // when whenExecuteSearch("property"); // then thenResultConsists() .ofProcessor(getSimpleResultFromRoot("processor1", "name1", "Property name: property1", "Property value: property1 - property1value", "Property description: property1 description", "Property name: property2", "Property description: property2 description")) .validate(results); }
Example #4
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 #5
Source File: ProvenanceReportingSchema.java From nifi-minifi with Apache License 2.0 | 6 votes |
public ProvenanceReportingSchema(Map map) { schedulingStrategy = getRequiredKeyAsType(map, SCHEDULING_STRATEGY_KEY, String.class, PROVENANCE_REPORTING_KEY); if (schedulingStrategy != null) { try { SchedulingStrategy.valueOf(schedulingStrategy); } catch (IllegalArgumentException e) { addValidationIssue(SCHEDULING_STRATEGY_KEY, PROVENANCE_REPORTING_KEY, "it is not a valid scheduling strategy"); } } schedulingPeriod = getRequiredKeyAsType(map, SCHEDULING_PERIOD_KEY, String.class, PROVENANCE_REPORTING_KEY); comment = getOptionalKeyAsType(map, COMMENT_KEY, String.class, PROVENANCE_REPORTING_KEY, ""); originatingUrl = getOptionalKeyAsType(map, ORIGINATING_URL_KEY, String.class, PROVENANCE_REPORTING_KEY, DEFAULT_ORGINATING_URL); destinationUrl = getRequiredKeyAsType(map, DESTINATION_URL_KEY, String.class, PROVENANCE_REPORTING_KEY); portName = getRequiredKeyAsType(map, PORT_NAME_KEY, String.class, PROVENANCE_REPORTING_KEY); useCompression = getOptionalKeyAsType(map, USE_COMPRESSION_KEY, Boolean.class, PROVENANCE_REPORTING_KEY, DEFAULT_USE_COMPRESSION); timeout = getOptionalKeyAsType(map, TIMEOUT_KEY, String.class, PROVENANCE_REPORTING_KEY, DEFAULT_TIMEOUT); batchSize = getOptionalKeyAsType(map, BATCH_SIZE_KEY, Number.class, PROVENANCE_REPORTING_KEY, DEFAULT_BATCH_SIZE); }
Example #6
Source File: ComponentMockUtil.java From nifi with Apache License 2.0 | 5 votes |
public static ProcessorNode getProcessorNode( final String id, final String name, final SchedulingStrategy schedulingStrategy, final ExecutionNode executionNode, final ScheduledState scheduledState, final ValidationStatus validationStatus, final boolean isAuthorized) { return getProcessorNode(id, name, "", Optional.empty(), schedulingStrategy, executionNode, scheduledState, validationStatus, new HashSet<>(), "Processor", Mockito.mock(Processor.class), new HashMap<>(), isAuthorized); }
Example #7
Source File: StandardReportingInitializationContext.java From nifi with Apache License 2.0 | 5 votes |
public StandardReportingInitializationContext(final String id, final String name, final SchedulingStrategy schedulingStrategy, final String schedulingPeriod, final ComponentLog logger, final ControllerServiceProvider serviceProvider, final KerberosConfig kerberosConfig, final NodeTypeProvider nodeTypeProvider) { this.id = id; this.name = name; this.schedulingPeriod = schedulingPeriod; this.serviceProvider = serviceProvider; this.schedulingStrategy = schedulingStrategy; this.logger = logger; this.kerberosConfig = kerberosConfig; this.nodeTypeProvider = nodeTypeProvider; }
Example #8
Source File: SchedulingMatcherTest.java From nifi with Apache License 2.0 | 5 votes |
@Test public void testWhenKeywordAppearsAndTimer() { // given final SchedulingMatcher testSubject = new SchedulingMatcher(); givenSchedulingStrategy(SchedulingStrategy.TIMER_DRIVEN); givenSearchTerm("timer"); // when testSubject.match(component, searchQuery, matches); // then thenMatchConsistsOf("Scheduling strategy: Timer driven"); }
Example #9
Source File: SchedulingMatcherTest.java From nifi with Apache License 2.0 | 5 votes |
@Test public void testWhenKeywordDoesNotAppearAndEvent() { // given final SchedulingMatcher testSubject = new SchedulingMatcher(); givenSchedulingStrategy(SchedulingStrategy.TIMER_DRIVEN); givenSearchTerm("event"); // when testSubject.match(component, searchQuery, matches); // then thenNoMatches(); }
Example #10
Source File: StandardProcessScheduler.java From nifi with Apache License 2.0 | 5 votes |
@Override public void setMaxThreadCount(final SchedulingStrategy schedulingStrategy, final int maxThreadCount) { final SchedulingAgent agent = getSchedulingAgent(schedulingStrategy); if (agent == null) { return; } agent.setMaxThreadCount(maxThreadCount); }
Example #11
Source File: TestFlowController.java From nifi with Apache License 2.0 | 5 votes |
@Test public void testProcessorDefaultSettingsAnnotation() throws ProcessorInstantiationException, ClassNotFoundException { ProcessorNode p_settings = controller.getFlowManager().createProcessor(DummySettingsProcessor.class.getName(), "1234-SettingsProcessor", systemBundle.getBundleDetails().getCoordinate()); assertEquals("5 sec", p_settings.getYieldPeriod()); assertEquals("1 min", p_settings.getPenalizationPeriod()); assertEquals(LogLevel.DEBUG, p_settings.getBulletinLevel()); assertEquals(1, p_settings.getMaxConcurrentTasks()); assertEquals(SchedulingStrategy.TIMER_DRIVEN, p_settings.getSchedulingStrategy()); assertEquals("0 sec", p_settings.getSchedulingPeriod()); }
Example #12
Source File: SchedulingMatcherTest.java From nifi with Apache License 2.0 | 5 votes |
@Test public void testWhenKeywordAppearsAndEvent() { // given final SchedulingMatcher testSubject = new SchedulingMatcher(); givenSchedulingStrategy(SchedulingStrategy.EVENT_DRIVEN); givenSearchTerm("event"); // when testSubject.match(component, searchQuery, matches); // then thenMatchConsistsOf("Scheduling strategy: Event driven"); }
Example #13
Source File: ControllerSearchServiceIntegrationTest.java From nifi with Apache License 2.0 | 5 votes |
@Test public void testSearchBasedOnConnectionMetadata() { // given final Processor processor = Mockito.mock(ComponentMockUtil.DummyProcessor.class); givenRootProcessGroup() .withProcessor(getProcessorNode("processor1", "name1", "", Optional.empty(), SchedulingStrategy.TIMER_DRIVEN, ExecutionNode.ALL, ScheduledState.RUNNING, ValidationStatus.VALID, new HashSet<>(), "DummyProcessorForTest", processor, new HashMap<>(), AUTHORIZED)); // when whenExecuteSearch("dummy"); // then Assert.assertEquals(1, results.getProcessorResults().size()); final ComponentSearchResultDTO componentSearchResultDTO = results.getProcessorResults().get(0); Assert.assertEquals("processor1", componentSearchResultDTO.getId()); Assert.assertEquals("name1", componentSearchResultDTO.getName()); Assert.assertEquals(2, componentSearchResultDTO.getMatches().size()); final String firstMatch = componentSearchResultDTO.getMatches().get(0); final String secondMatch = componentSearchResultDTO.getMatches().get(1); if ((!firstMatch.equals("Type: DummyProcessorForTest") || !secondMatch.startsWith("Type: ComponentMockUtil$DummyProcessor$MockitoMock$")) && (!secondMatch.equals("Type: DummyProcessorForTest") || !firstMatch.startsWith("Type: ComponentMockUtil$DummyProcessor$MockitoMock$"))) { Assert.fail(); } }
Example #14
Source File: StandardProcessorNode.java From nifi with Apache License 2.0 | 5 votes |
/** * Updates the Scheduling Strategy used for this Processor * * @param schedulingStrategy * strategy * * @throws IllegalArgumentException * if the SchedulingStrategy is not not applicable for this * Processor */ @Override public synchronized void setSchedulingStrategy(final SchedulingStrategy schedulingStrategy) { if (schedulingStrategy == SchedulingStrategy.EVENT_DRIVEN && !processorRef.get().isEventDrivenSupported()) { // not valid. Just ignore it. We don't throw an Exception because if // a developer changes a Processor so that // it no longer supports EventDriven mode, we don't want the app to // fail to startup if it was already in Event-Driven // Mode. Instead, we will simply leave it in Timer-Driven mode return; } this.schedulingStrategy = schedulingStrategy; }
Example #15
Source File: StandardProcessScheduler.java From localization_nifi with Apache License 2.0 | 5 votes |
@Override public void setMaxThreadCount(final SchedulingStrategy schedulingStrategy, final int maxThreadCount) { final SchedulingAgent agent = getSchedulingAgent(schedulingStrategy); if (agent == null) { return; } agent.setMaxThreadCount(maxThreadCount); }
Example #16
Source File: ControllerSearchServiceFilterTest.java From nifi with Apache License 2.0 | 5 votes |
@Test public void testPropertiesAreExcluded() { // given final Map<PropertyDescriptor, String> rawProperties = new HashMap<>(); final PropertyDescriptor descriptor = new PropertyDescriptor.Builder().name("property1").displayName("property1display").description("property1 description").sensitive(false).build(); rawProperties.put(descriptor, "working"); givenRootProcessGroup() .withProcessor(getProcessorNode("workingProcessor1", "processor1Name", "", Optional.empty(), SchedulingStrategy.TIMER_DRIVEN, ExecutionNode.ALL, ScheduledState.RUNNING, ValidationStatus.VALID, new HashSet<>(), "Processor", Mockito.mock(Processor.class), new HashMap<>(), AUTHORIZED)) .withProcessor(getProcessorNode("processor2", "processor2Name", "", Optional.empty(), SchedulingStrategy.TIMER_DRIVEN, ExecutionNode.ALL, ScheduledState.RUNNING, ValidationStatus.VALID, new HashSet<>(), "Processor", Mockito.mock(Processor.class), rawProperties, AUTHORIZED)); // when whenExecuteSearch("properties:exclude working"); // then thenResultConsists() .ofProcessor(getSimpleResultFromRoot("workingProcessor1", "processor1Name", "Id: workingProcessor1")) .validate(results); // when whenExecuteSearch("properties:invalid working"); // then thenResultConsists() .ofProcessor(getSimpleResultFromRoot("workingProcessor1", "processor1Name", "Id: workingProcessor1")) .ofProcessor(getSimpleResultFromRoot("processor2", "processor2Name", "Property value: property1 - working")) .validate(results); }
Example #17
Source File: ComponentMockUtil.java From nifi with Apache License 2.0 | 5 votes |
public static ProcessorNode getProcessorNode( final String id, final String name, final String comments, final Optional<String> versionedId, final SchedulingStrategy schedulingStrategy, final ExecutionNode executionNode, final ScheduledState scheduledState, final ValidationStatus validationStatus, final Collection<Relationship> relationships, final String componentType, final Processor processor, final Map<PropertyDescriptor, String> rawProperties, final boolean isAuthorized) { final ProcessorNode result = Mockito.mock(ProcessorNode.class); Mockito.when(result.getIdentifier()).thenReturn(id); Mockito.when(result.getName()).thenReturn(name); Mockito.when(result.getComments()).thenReturn(comments); Mockito.when(result.getVersionedComponentId()).thenReturn(versionedId); Mockito.when(result.getSchedulingStrategy()).thenReturn(schedulingStrategy); Mockito.when(result.getExecutionNode()).thenReturn(executionNode); Mockito.when(result.getScheduledState()).thenReturn(scheduledState); Mockito.when(result.getValidationStatus()).thenReturn(validationStatus); Mockito.when(result.getRelationships()).thenReturn(relationships); Mockito.when(result.getComponentType()).thenReturn(componentType); Mockito.when(result.getProcessor()).thenReturn(processor); Mockito.when(result.getRawPropertyValues()).thenReturn(rawProperties); setAuthorized(result, isAuthorized); return result; }
Example #18
Source File: NiFiRegistryFlowMapperTest.java From nifi with Apache License 2.0 | 5 votes |
private ProcessorNode prepareProcessor(final ProcessGroup processGroup, final ControllerServiceNode externalControllerServiceNode) { final ProcessorNode processorNode = mock(ProcessorNode.class); prepareComponentAuthorizable(processorNode, processGroup.getIdentifier()); preparePositionable(processorNode); prepareConnectable(processorNode, ConnectableType.PROCESSOR); when(processorNode.getProcessGroup()).thenReturn(processGroup); when(processorNode.getAutoTerminatedRelationships()).thenReturn(Collections.emptySet()); when(processorNode.getBulletinLevel()).thenReturn(LogLevel.INFO); when(processorNode.getExecutionNode()).thenReturn(ExecutionNode.ALL); when(processorNode.getSchedulingStrategy()).thenReturn(SchedulingStrategy.TIMER_DRIVEN); when(processorNode.getBundleCoordinate()).thenReturn(mock(BundleCoordinate.class)); final String rawPropertyValue = "propValue"; final PropertyDescriptor.Builder propertyDescriptorBuilder = new PropertyDescriptor.Builder().name("propName").sensitive(false).displayName("displayName"); if (externalControllerServiceNode != null) { propertyDescriptorBuilder.identifiesControllerService(ControllerService.class); when(controllerServiceProvider.getControllerServiceNode(rawPropertyValue)).thenReturn(externalControllerServiceNode); } final PropertyDescriptor propertyDescriptor = propertyDescriptorBuilder.build(); final PropertyConfiguration propertyConfiguration = mock(PropertyConfiguration.class); final Map<PropertyDescriptor, PropertyConfiguration> properties = Maps.newHashMap(); properties.put(propertyDescriptor, propertyConfiguration); when(processorNode.getProperties()).thenReturn(properties); when(processorNode.getProperty(propertyDescriptor)).thenReturn(propertyConfiguration); when(propertyConfiguration.getRawValue()).thenReturn(rawPropertyValue); return processorNode; }
Example #19
Source File: StandardReportingInitializationContext.java From nifi with Apache License 2.0 | 5 votes |
@Override public long getSchedulingPeriod(final TimeUnit timeUnit) { if (schedulingStrategy == SchedulingStrategy.TIMER_DRIVEN) { return FormatUtils.getTimeDuration(schedulingPeriod, timeUnit); } return -1L; }
Example #20
Source File: StandardProcessorNode.java From localization_nifi with Apache License 2.0 | 5 votes |
/** * Updates the Scheduling Strategy used for this Processor * * @param schedulingStrategy * strategy * * @throws IllegalArgumentException * if the SchedulingStrategy is not not applicable for this * Processor */ @Override public void setSchedulingStrategy(final SchedulingStrategy schedulingStrategy) { if (schedulingStrategy == SchedulingStrategy.EVENT_DRIVEN && !eventDrivenSupported) { // not valid. Just ignore it. We don't throw an Exception because if // a developer changes a Processor so that // it no longer supports EventDriven mode, we don't want the app to // fail to startup if it was already in Event-Driven // Mode. Instead, we will simply leave it in Timer-Driven mode return; } this.schedulingStrategy = schedulingStrategy; }
Example #21
Source File: StandardFlowSynchronizer.java From nifi with Apache License 2.0 | 5 votes |
private ReportingTaskNode getOrCreateReportingTask(final FlowController controller, final ReportingTaskDTO dto, final boolean controllerInitialized, final boolean existingFlowEmpty) throws ReportingTaskInstantiationException { // create a new reporting task node when the controller is not initialized or the flow is empty if (!controllerInitialized || existingFlowEmpty) { BundleCoordinate coordinate; try { coordinate = BundleUtils.getCompatibleBundle(extensionManager, 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 ReportingTaskNode reportingTask = controller.createReportingTask(dto.getType(), dto.getId(), coordinate, false); reportingTask.setName(dto.getName()); reportingTask.setComments(dto.getComments()); reportingTask.setSchedulingPeriod(dto.getSchedulingPeriod()); reportingTask.setSchedulingStrategy(SchedulingStrategy.valueOf(dto.getSchedulingStrategy())); reportingTask.setAnnotationData(dto.getAnnotationData()); reportingTask.setProperties(dto.getProperties()); return reportingTask; } else { // otherwise return the existing reporting task node return controller.getReportingTaskNode(dto.getId()); } }
Example #22
Source File: StandardProcessorNode.java From localization_nifi with Apache License 2.0 | 5 votes |
/** * Determines the number of concurrent tasks that may be running for this * processor. * * @param taskCount * a number of concurrent tasks this processor may have running * @throws IllegalArgumentException * if the given value is less than 1 */ @Override public void setMaxConcurrentTasks(final int taskCount) { if (isRunning()) { throw new IllegalStateException("Cannot modify Processor configuration while the Processor is running"); } if (taskCount < 1 && getSchedulingStrategy() != SchedulingStrategy.EVENT_DRIVEN) { throw new IllegalArgumentException(); } if (!triggeredSerially) { concurrentTaskCount.set(taskCount); } }
Example #23
Source File: FlowController.java From localization_nifi with Apache License 2.0 | 5 votes |
public void setMaxEventDrivenThreadCount(final int maxThreadCount) { writeLock.lock(); try { setMaxThreadCount(maxThreadCount, this.eventDrivenEngineRef.get(), this.maxEventDrivenThreads); processScheduler.setMaxThreadCount(SchedulingStrategy.EVENT_DRIVEN, maxThreadCount); } finally { writeLock.unlock(); } }
Example #24
Source File: StandardFlowFileQueue.java From localization_nifi with Apache License 2.0 | 5 votes |
@Override public void acknowledge(final FlowFileRecord flowFile) { incrementUnacknowledgedQueueSize(-1, -flowFile.getSize()); if (connection.getSource().getSchedulingStrategy() == SchedulingStrategy.EVENT_DRIVEN) { // queue was full but no longer is. Notify that the source may now be available to run, // because of back pressure caused by this queue. scheduler.registerEvent(connection.getSource()); } }
Example #25
Source File: StandardFlowFileQueue.java From localization_nifi with Apache License 2.0 | 5 votes |
@Override public void acknowledge(final Collection<FlowFileRecord> flowFiles) { long totalSize = 0L; for (final FlowFileRecord flowFile : flowFiles) { totalSize += flowFile.getSize(); } incrementUnacknowledgedQueueSize(-flowFiles.size(), -totalSize); if (connection.getSource().getSchedulingStrategy() == SchedulingStrategy.EVENT_DRIVEN) { // it's possible that queue was full but no longer is. Notify that the source may now be available to run, // because of back pressure caused by this queue. scheduler.registerEvent(connection.getSource()); } }
Example #26
Source File: SchedulingMatcher.java From nifi with Apache License 2.0 | 5 votes |
@Override public void match(final ProcessorNode component, final SearchQuery query, final List<String> matches) { final String searchTerm = query.getTerm(); final SchedulingStrategy schedulingStrategy = component.getSchedulingStrategy(); if (EVENT_DRIVEN.equals(schedulingStrategy) && StringUtils.containsIgnoreCase(SEARCH_TERM_EVENT, searchTerm)) { matches.add(MATCH_PREFIX + MATCH_EVENT); } else if (TIMER_DRIVEN.equals(schedulingStrategy) && StringUtils.containsIgnoreCase(SEARCH_TERM_TIMER, searchTerm)) { matches.add(MATCH_PREFIX + MATCH_TIMER); } else if (PRIMARY_NODE_ONLY.equals(schedulingStrategy) && StringUtils.containsIgnoreCase(SEARCH_TERM_PRIMARY, searchTerm)) { // PRIMARY_NODE_ONLY has been deprecated as a SchedulingStrategy and replaced by PRIMARY as an ExecutionNode. matches.add(MATCH_PREFIX + MATCH_PRIMARY); } }
Example #27
Source File: StandardReportingTaskDAO.java From nifi with Apache License 2.0 | 5 votes |
private void configureReportingTask(final ReportingTaskNode reportingTask, final ReportingTaskDTO reportingTaskDTO) { final String name = reportingTaskDTO.getName(); final String schedulingStrategy = reportingTaskDTO.getSchedulingStrategy(); final String schedulingPeriod = reportingTaskDTO.getSchedulingPeriod(); final String annotationData = reportingTaskDTO.getAnnotationData(); final String comments = reportingTaskDTO.getComments(); final Map<String, String> properties = reportingTaskDTO.getProperties(); reportingTask.pauseValidationTrigger(); // avoid triggering validation multiple times try { // ensure scheduling strategy is set first if (isNotNull(schedulingStrategy)) { reportingTask.setSchedulingStrategy(SchedulingStrategy.valueOf(schedulingStrategy)); } if (isNotNull(name)) { reportingTask.setName(name); } if (isNotNull(schedulingPeriod)) { reportingTask.setSchedulingPeriod(schedulingPeriod); } if (isNotNull(annotationData)) { reportingTask.setAnnotationData(annotationData); } if (isNotNull(comments)) { reportingTask.setComments(comments); } if (isNotNull(properties)) { reportingTask.setProperties(properties); } } finally { reportingTask.resumeValidationTrigger(); } }
Example #28
Source File: ProcessorSchema.java From nifi-minifi with Apache License 2.0 | 5 votes |
public static boolean isSchedulingStrategy(String string) { try { SchedulingStrategy.valueOf(string); } catch (Exception e) { return false; } return true; }
Example #29
Source File: ExtensionBuilder.java From nifi with Apache License 2.0 | 5 votes |
private LoggableComponent<ReportingTask> createLoggableReportingTask() throws ReportingTaskInstantiationException { try { final LoggableComponent<ReportingTask> taskComponent = createLoggableComponent(ReportingTask.class); final String taskName = taskComponent.getComponent().getClass().getSimpleName(); final ReportingInitializationContext config = new StandardReportingInitializationContext(identifier, taskName, SchedulingStrategy.TIMER_DRIVEN, "1 min", taskComponent.getLogger(), serviceProvider, kerberosConfig, nodeTypeProvider); taskComponent.getComponent().initialize(config); return taskComponent; } catch (final Exception e) { throw new ReportingTaskInstantiationException(type, e); } }
Example #30
Source File: StandardReportingTaskDAO.java From nifi with Apache License 2.0 | 5 votes |
private List<String> validateProposedConfiguration(final ReportingTaskNode reportingTask, final ReportingTaskDTO reportingTaskDTO) { final List<String> validationErrors = new ArrayList<>(); // get the current scheduling strategy SchedulingStrategy schedulingStrategy = reportingTask.getSchedulingStrategy(); // validate the new scheduling strategy if appropriate if (isNotNull(reportingTaskDTO.getSchedulingStrategy())) { try { // this will be the new scheduling strategy so use it schedulingStrategy = SchedulingStrategy.valueOf(reportingTaskDTO.getSchedulingStrategy()); } catch (IllegalArgumentException iae) { validationErrors.add(String.format("Scheduling strategy: Value must be one of [%s]", StringUtils.join(SchedulingStrategy.values(), ", "))); } } // validate the scheduling period based on the scheduling strategy if (isNotNull(reportingTaskDTO.getSchedulingPeriod())) { switch (schedulingStrategy) { case TIMER_DRIVEN: final Matcher schedulingMatcher = FormatUtils.TIME_DURATION_PATTERN.matcher(reportingTaskDTO.getSchedulingPeriod()); if (!schedulingMatcher.matches()) { validationErrors.add("Scheduling period is not a valid time duration (ie 30 sec, 5 min)"); } break; case CRON_DRIVEN: try { new CronExpression(reportingTaskDTO.getSchedulingPeriod()); } catch (final ParseException pe) { throw new IllegalArgumentException(String.format("Scheduling Period '%s' is not a valid cron expression: %s", reportingTaskDTO.getSchedulingPeriod(), pe.getMessage())); } catch (final Exception e) { throw new IllegalArgumentException("Scheduling Period is not a valid cron expression: " + reportingTaskDTO.getSchedulingPeriod()); } break; } } return validationErrors; }