Java源码示例:org.apache.nifi.scheduling.SchedulingStrategy
示例1
@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);
}
示例2
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);
}
示例3
/**
* 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);
}
}
示例4
@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);
}
示例5
@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);
}
示例6
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());
}
}
示例7
/**
* 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;
}
示例8
@Override
public void setMaxThreadCount(final SchedulingStrategy schedulingStrategy, final int maxThreadCount) {
final SchedulingAgent agent = getSchedulingAgent(schedulingStrategy);
if (agent == null) {
return;
}
agent.setMaxThreadCount(maxThreadCount);
}
示例9
@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());
}
示例10
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("setMaxEventDrivenThreadCount");
}
}
示例11
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();
// 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);
}
}
示例12
@Override
public long getSchedulingPeriod(final TimeUnit timeUnit) {
if (schedulingStrategy == SchedulingStrategy.TIMER_DRIVEN) {
return FormatUtils.getTimeDuration(schedulingPeriod, timeUnit);
}
return -1L;
}
示例13
@Override
public void setMaxThreadCount(final SchedulingStrategy schedulingStrategy, final int maxThreadCount) {
final SchedulingAgent agent = getSchedulingAgent(schedulingStrategy);
if (agent == null) {
return;
}
agent.setMaxThreadCount(maxThreadCount);
}
示例14
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;
}
示例15
/**
* 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;
}
示例16
/**
* 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);
}
}
示例17
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();
}
}
示例18
@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());
}
}
示例19
@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());
}
}
示例20
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);
}
}
示例21
@Override
public long getSchedulingPeriod(final TimeUnit timeUnit) {
if (schedulingStrategy == SchedulingStrategy.TIMER_DRIVEN) {
return FormatUtils.getTimeDuration(schedulingPeriod, timeUnit);
}
return -1L;
}
示例22
public static boolean isSchedulingStrategy(String string) {
try {
SchedulingStrategy.valueOf(string);
} catch (Exception e) {
return false;
}
return true;
}
示例23
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;
}
示例24
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();
}
}
示例25
@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);
}
}
示例26
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);
}
示例27
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;
}
示例28
@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);
}
示例29
@Test
public void testSearchForRootBasedOnNameAndComments() {
// given
final String commentForRoot = "test comment for " + ROOT_PROCESSOR_GROUP_NAME + " process group";
final String searchQuery = ROOT_PROCESSOR_GROUP_NAME;
final String processor2Id = "processor2";
final String processor2Name = "NAME2";
final String processor2Comment = "This comment is a test comment containing " + ROOT_PROCESSOR_GROUP_NAME;
givenRootProcessGroup(commentForRoot)
.withProcessor(getProcessorNode("processor1", "name1", AUTHORIZED))
.withProcessor(getProcessorNode(processor2Id, processor2Name, processor2Comment,
Optional.of("versionId"), SchedulingStrategy.TIMER_DRIVEN, ExecutionNode.ALL, ScheduledState.RUNNING, ValidationStatus.VALID,
new HashSet<>(),"Processor", Mockito.mock(Processor.class), new HashMap<>(), AUTHORIZED));
// when
whenExecuteSearch(searchQuery);
// then
thenResultConsists()
.ofProcessGroup(getSimpleResult(ROOT_PROCESSOR_GROUP_ID,
ROOT_PROCESSOR_GROUP_NAME,
ROOT_PROCESSOR_GROUP_ID,
null,
null,
"Name: " + ROOT_PROCESSOR_GROUP_NAME,
"Comments: " + commentForRoot))
.ofProcessor(getSimpleResultFromRoot(processor2Id, processor2Name, "Comments: " + processor2Comment))
.validate(results);
}
示例30
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;
}