Java Code Examples for org.apache.nifi.web.api.dto.ProcessorConfigDTO#setProperties()
The following examples show how to use
org.apache.nifi.web.api.dto.ProcessorConfigDTO#setProperties() .
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: TestJsonEntitySerializer.java From nifi with Apache License 2.0 | 6 votes |
@Test public void testSerializeProcessor() throws IOException { final ObjectMapper jsonCodec = new ObjectMapper(); jsonCodec.registerModule(new JaxbAnnotationModule()); jsonCodec.setSerializationInclusion(Include.NON_NULL); // Test that we can properly serialize a ProcessorEntity because it has many nested levels, including a Map final JsonEntitySerializer serializer = new JsonEntitySerializer(jsonCodec); try (final ByteArrayOutputStream baos = new ByteArrayOutputStream()) { final ProcessorConfigDTO configDto = new ProcessorConfigDTO(); configDto.setProperties(Collections.singletonMap("key", "value")); final ProcessorDTO processorDto = new ProcessorDTO(); processorDto.setConfig(configDto); final ProcessorEntity processor = new ProcessorEntity(); processor.setId("123"); processor.setComponent(processorDto); serializer.serialize(processor, baos); final String serialized = new String(baos.toByteArray(), StandardCharsets.UTF_8); assertEquals("{\"id\":\"123\",\"component\":{\"config\":{\"properties\":{\"key\":\"value\"}}}}", serialized); } }
Example 2
Source File: TemplateUtils.java From nifi with Apache License 2.0 | 6 votes |
private static void escapeParameterReferences(final ProcessorDTO processorDto) { final ProcessorConfigDTO config = processorDto.getConfig(); if (config == null) { return; } final ParameterParser parameterParser = new ExpressionLanguageAwareParameterParser(); final Map<String, String> escapedPropertyValues = new HashMap<>(); for (final Map.Entry<String, String> entry : config.getProperties().entrySet()) { final ParameterTokenList references = parameterParser.parseTokens(entry.getValue()); final String escaped = references.escape(); escapedPropertyValues.put(entry.getKey(), escaped); } config.setProperties(escapedPropertyValues); }
Example 3
Source File: ParameterContextIT.java From nifi with Apache License 2.0 | 6 votes |
@Test(timeout = 30000) public void testAddingMissingParameterMakesProcessorValid() throws NiFiClientException, IOException, InterruptedException { final ProcessorEntity createdProcessorEntity = createProcessor(TEST_PROCESSORS_PACKAGE + ".CountEvents", NIFI_GROUP_ID, TEST_EXTENSIONS_ARTIFACT_ID, getNiFiVersion()); final String processorId = createdProcessorEntity.getId(); final ProcessorConfigDTO config = createdProcessorEntity.getComponent().getConfig(); config.setProperties(Collections.singletonMap("Name", "#{foo}")); getNifiClient().getProcessorClient().updateProcessor(createdProcessorEntity); waitForInvalidProcessor(processorId); final Set<ParameterEntity> parameters = new HashSet<>(); parameters.add(createParameterEntity("foo", null, false, "bar")); final ParameterContextEntity contextEntity = createParameterContextEntity(getTestName(), null, parameters); final ParameterContextEntity createdContextEntity = getNifiClient().getParamContextClient().createParamContext(contextEntity); setParameterContext("root", createdContextEntity); waitForValidProcessor(processorId); }
Example 4
Source File: StandardNiFiWebConfigurationContext.java From localization_nifi with Apache License 2.0 | 5 votes |
private ProcessorDTO buildProcessorDto(String id, final String annotationData, Map<String, String> properties){ ProcessorDTO processorDto = new ProcessorDTO(); processorDto.setId(id); ProcessorConfigDTO configDto = new ProcessorConfigDTO(); processorDto.setConfig(configDto); configDto.setAnnotationData(annotationData); configDto.setProperties(properties); return processorDto; }
Example 5
Source File: ProcessorSchemaTest.java From nifi-minifi with Apache License 2.0 | 5 votes |
@Before public void setup() { config = new ProcessorConfigDTO(); RelationshipDTO relationshipDTO = new RelationshipDTO(); relationshipDTO.setName(testRelationship); relationshipDTO.setAutoTerminate(true); dto = new ProcessorDTO(); dto.setConfig(config); dto.setName(testName); dto.setId(testId); dto.setType(testProcessorClass); config.setSchedulingStrategy(testSchedulingStrategy); config.setSchedulingPeriod(testSchedulingPeriod); config.setConcurrentlySchedulableTaskCount(testMaxConcurrentTasks); config.setPenaltyDuration(testPenalizationPeriod); config.setYieldDuration(testYieldDuration); config.setRunDurationMillis(testRunDurationNanos / 1000); config.setAnnotationData(testAnnotationData); dto.setRelationships(Arrays.asList(relationshipDTO)); Map<String, String> properties = new HashMap<>(); properties.put(testKey, testValue); config.setProperties(properties); map = new HashMap<>(); map.put(CommonPropertyKeys.NAME_KEY, testName); map.put(CommonPropertyKeys.ID_KEY, testId); map.put(CLASS_KEY, testProcessorClass); map.put(CommonPropertyKeys.SCHEDULING_STRATEGY_KEY, testSchedulingStrategy); map.put(CommonPropertyKeys.SCHEDULING_PERIOD_KEY, testSchedulingPeriod); map.put(CommonPropertyKeys.MAX_CONCURRENT_TASKS_KEY, testMaxConcurrentTasks); map.put(ProcessorSchema.PENALIZATION_PERIOD_KEY, testPenalizationPeriod); map.put(CommonPropertyKeys.YIELD_PERIOD_KEY, testYieldDuration); map.put(ProcessorSchema.RUN_DURATION_NANOS_KEY, testRunDurationNanos); map.put(ProcessorSchema.AUTO_TERMINATED_RELATIONSHIPS_LIST_KEY, Arrays.asList(testRelationship)); map.put(PROPERTIES_KEY, new HashMap<>(properties)); map.put(ANNOTATION_DATA_KEY, testAnnotationData); }
Example 6
Source File: StandardNiFiWebConfigurationContext.java From nifi with Apache License 2.0 | 5 votes |
private ProcessorDTO buildProcessorDto(String id, final String annotationData, Map<String, String> properties){ ProcessorDTO processorDto = new ProcessorDTO(); processorDto.setId(id); ProcessorConfigDTO configDto = new ProcessorConfigDTO(); processorDto.setConfig(configDto); configDto.setAnnotationData(annotationData); configDto.setProperties(properties); return processorDto; }
Example 7
Source File: FlowFromDOMFactory.java From localization_nifi with Apache License 2.0 | 4 votes |
public static ProcessorDTO getProcessor(final Element element, final StringEncryptor encryptor) { final ProcessorDTO dto = new ProcessorDTO(); dto.setId(getString(element, "id")); dto.setName(getString(element, "name")); dto.setType(getString(element, "class")); dto.setPosition(getPosition(DomUtils.getChild(element, "position"))); dto.setStyle(getStyle(DomUtils.getChild(element, "styles"))); final ProcessorConfigDTO configDto = new ProcessorConfigDTO(); dto.setConfig(configDto); configDto.setComments(getString(element, "comment")); configDto.setConcurrentlySchedulableTaskCount(getInt(element, "maxConcurrentTasks")); final String schedulingPeriod = getString(element, "schedulingPeriod"); configDto.setSchedulingPeriod(schedulingPeriod); configDto.setPenaltyDuration(getString(element, "penalizationPeriod")); configDto.setYieldDuration(getString(element, "yieldPeriod")); configDto.setBulletinLevel(getString(element, "bulletinLevel")); configDto.setLossTolerant(getBoolean(element, "lossTolerant")); final ScheduledState scheduledState = getScheduledState(element); dto.setState(scheduledState.toString()); // handle scheduling strategy final String schedulingStrategyName = getString(element, "schedulingStrategy"); if (schedulingStrategyName == null || schedulingStrategyName.trim().isEmpty()) { configDto.setSchedulingStrategy(SchedulingStrategy.TIMER_DRIVEN.name()); } else { configDto.setSchedulingStrategy(schedulingStrategyName.trim()); } // handle execution node final String executionNode = getString(element, "executionNode"); if (executionNode == null || executionNode.trim().isEmpty()) { configDto.setExecutionNode(ExecutionNode.ALL.name()); } else { configDto.setExecutionNode(executionNode.trim()); } final Long runDurationNanos = getOptionalLong(element, "runDurationNanos"); if (runDurationNanos != null) { configDto.setRunDurationMillis(TimeUnit.NANOSECONDS.toMillis(runDurationNanos)); } configDto.setProperties(getProperties(element, encryptor)); configDto.setAnnotationData(getString(element, "annotationData")); final Set<String> autoTerminatedRelationships = new HashSet<>(); final List<Element> autoTerminateList = getChildrenByTagName(element, "autoTerminatedRelationship"); for (final Element autoTerminateElement : autoTerminateList) { autoTerminatedRelationships.add(autoTerminateElement.getTextContent()); } configDto.setAutoTerminatedRelationships(autoTerminatedRelationships); return dto; }
Example 8
Source File: FlowFromDOMFactory.java From nifi with Apache License 2.0 | 4 votes |
public static ProcessorDTO getProcessor(final Element element, final StringEncryptor encryptor, final FlowEncodingVersion flowEncodingVersion) { final ProcessorDTO dto = new ProcessorDTO(); dto.setId(getString(element, "id")); dto.setVersionedComponentId(getString(element, "versionedComponentId")); dto.setName(getString(element, "name")); dto.setType(getString(element, "class")); dto.setBundle(getBundle(DomUtils.getChild(element, "bundle"))); dto.setPosition(getPosition(DomUtils.getChild(element, "position"))); dto.setStyle(getStyle(DomUtils.getChild(element, "styles"))); final ProcessorConfigDTO configDto = new ProcessorConfigDTO(); dto.setConfig(configDto); configDto.setComments(getString(element, "comment")); configDto.setConcurrentlySchedulableTaskCount(getInt(element, "maxConcurrentTasks")); final String schedulingPeriod = getString(element, "schedulingPeriod"); configDto.setSchedulingPeriod(schedulingPeriod); configDto.setPenaltyDuration(getString(element, "penalizationPeriod")); configDto.setYieldDuration(getString(element, "yieldPeriod")); configDto.setBulletinLevel(getString(element, "bulletinLevel")); configDto.setLossTolerant(getBoolean(element, "lossTolerant")); final ScheduledState scheduledState = getScheduledState(element); dto.setState(scheduledState.toString()); // handle scheduling strategy final String schedulingStrategyName = getString(element, "schedulingStrategy"); if (schedulingStrategyName == null || schedulingStrategyName.trim().isEmpty()) { configDto.setSchedulingStrategy(SchedulingStrategy.TIMER_DRIVEN.name()); } else { configDto.setSchedulingStrategy(schedulingStrategyName.trim()); } // handle execution node final String executionNode = getString(element, "executionNode"); if (executionNode == null || executionNode.trim().isEmpty()) { configDto.setExecutionNode(ExecutionNode.ALL.name()); } else { configDto.setExecutionNode(executionNode.trim()); } final Long runDurationNanos = getOptionalLong(element, "runDurationNanos"); if (runDurationNanos != null) { configDto.setRunDurationMillis(TimeUnit.NANOSECONDS.toMillis(runDurationNanos)); } configDto.setProperties(getProperties(element, encryptor, flowEncodingVersion)); configDto.setAnnotationData(getString(element, "annotationData")); final Set<String> autoTerminatedRelationships = new HashSet<>(); final List<Element> autoTerminateList = getChildrenByTagName(element, "autoTerminatedRelationship"); for (final Element autoTerminateElement : autoTerminateList) { autoTerminatedRelationships.add(autoTerminateElement.getTextContent()); } configDto.setAutoTerminatedRelationships(autoTerminatedRelationships); return dto; }
Example 9
Source File: ParameterContextIT.java From nifi with Apache License 2.0 | 4 votes |
@Test public void testProcessorStartedAfterLongValidationPeriod() throws NiFiClientException, IOException, InterruptedException { final ParameterContextEntity createdContextEntity = createParameterContext("sleep", "6 secs"); // Set the Parameter Context on the root Process Group setParameterContext("root", createdContextEntity); // Create a Processor and update it to reference Parameter "name" ProcessorEntity processorEntity = createProcessor(TEST_PROCESSORS_PACKAGE + ".Sleep", NIFI_GROUP_ID, TEST_EXTENSIONS_ARTIFACT_ID, getNiFiVersion()); final String processorId = processorEntity.getId(); // Update processor to reference Parameter "name" final ProcessorConfigDTO config = processorEntity.getComponent().getConfig(); config.setProperties(Collections.singletonMap("Validate Sleep Time", "#{sleep}")); config.setAutoTerminatedRelationships(Collections.singleton("success")); getNifiClient().getProcessorClient().updateProcessor(processorEntity); waitForValidProcessor(processorId); // Start Processors getNifiClient().getProcessorClient().startProcessor(processorId, processorEntity.getRevision().getClientId(), 1); try { // Update Parameter Context to a long validation time. final ParameterContextUpdateRequestEntity updateRequestEntity = updateParameterContext(createdContextEntity, "sleep", "6 sec"); final Set<AffectedComponentEntity> affectedComponents = updateRequestEntity.getRequest().getReferencingComponents(); assertEquals(1, affectedComponents.size()); final String affectedComponentId = affectedComponents.iterator().next().getId(); assertEquals(processorId, affectedComponentId); getClientUtil().waitForParameterContextRequestToComplete(createdContextEntity.getId(), updateRequestEntity.getRequest().getRequestId()); waitForRunningProcessor(processorId); } finally { // Ensure that we stop the processor so that other tests are allowed to change the Parameter Context, etc. getNifiClient().getProcessorClient().stopProcessor(processorId, processorEntity.getRevision().getClientId(), 2); waitForStoppedProcessor(processorId); getNifiClient().getProcessorClient().deleteProcessor(processorId, processorEntity.getRevision().getClientId(), 3); } }
Example 10
Source File: NiFiClientUtil.java From nifi with Apache License 2.0 | 4 votes |
public ProcessorEntity updateProcessorProperties(final ProcessorEntity currentEntity, final Map<String, String> properties) throws NiFiClientException, IOException { final ProcessorConfigDTO config = new ProcessorConfigDTO(); config.setProperties(properties); return updateProcessorConfig(currentEntity, config); }