use of org.apache.nifi.connectable.Position in project nifi by apache.
the class StandardProcessGroupDAO method updateProcessGroup.
@Override
public ProcessGroup updateProcessGroup(ProcessGroupDTO processGroupDTO) {
final ProcessGroup group = locateProcessGroup(flowController, processGroupDTO.getId());
final String name = processGroupDTO.getName();
final String comments = processGroupDTO.getComments();
if (isNotNull(name)) {
group.setName(name);
}
if (isNotNull(processGroupDTO.getPosition())) {
group.setPosition(new Position(processGroupDTO.getPosition().getX(), processGroupDTO.getPosition().getY()));
final ProcessGroup parent = group.getParent();
if (parent != null) {
parent.onComponentModified();
}
}
if (isNotNull(comments)) {
group.setComments(comments);
}
group.onComponentModified();
return group;
}
use of org.apache.nifi.connectable.Position in project nifi by apache.
the class StandardProcessorDAO method configureProcessor.
private void configureProcessor(final ProcessorNode processor, final ProcessorDTO processorDTO) {
final ProcessorConfigDTO config = processorDTO.getConfig();
// ensure some configuration was specified
if (isNotNull(config)) {
// perform the configuration
final String schedulingStrategy = config.getSchedulingStrategy();
final String executionNode = config.getExecutionNode();
final String comments = config.getComments();
final String annotationData = config.getAnnotationData();
final Integer maxTasks = config.getConcurrentlySchedulableTaskCount();
final Map<String, String> configProperties = config.getProperties();
final String schedulingPeriod = config.getSchedulingPeriod();
final String penaltyDuration = config.getPenaltyDuration();
final String yieldDuration = config.getYieldDuration();
final Long runDurationMillis = config.getRunDurationMillis();
final String bulletinLevel = config.getBulletinLevel();
final Set<String> undefinedRelationshipsToTerminate = config.getAutoTerminatedRelationships();
// ensure scheduling strategy is set first
if (isNotNull(schedulingStrategy)) {
processor.setSchedulingStrategy(SchedulingStrategy.valueOf(schedulingStrategy));
}
if (isNotNull(executionNode)) {
processor.setExecutionNode(ExecutionNode.valueOf(executionNode));
}
if (isNotNull(comments)) {
processor.setComments(comments);
}
if (isNotNull(annotationData)) {
processor.setAnnotationData(annotationData);
}
if (isNotNull(maxTasks)) {
processor.setMaxConcurrentTasks(maxTasks);
}
if (isNotNull(schedulingPeriod)) {
processor.setScheduldingPeriod(schedulingPeriod);
}
if (isNotNull(penaltyDuration)) {
processor.setPenalizationPeriod(penaltyDuration);
}
if (isNotNull(yieldDuration)) {
processor.setYieldPeriod(yieldDuration);
}
if (isNotNull(runDurationMillis)) {
processor.setRunDuration(runDurationMillis, TimeUnit.MILLISECONDS);
}
if (isNotNull(bulletinLevel)) {
processor.setBulletinLevel(LogLevel.valueOf(bulletinLevel));
}
if (isNotNull(config.isLossTolerant())) {
processor.setLossTolerant(config.isLossTolerant());
}
if (isNotNull(configProperties)) {
processor.setProperties(configProperties);
}
if (isNotNull(undefinedRelationshipsToTerminate)) {
final Set<Relationship> relationships = new HashSet<>();
for (final String relName : undefinedRelationshipsToTerminate) {
relationships.add(new Relationship.Builder().name(relName).build());
}
processor.setAutoTerminatedRelationships(relationships);
}
}
// update processor settings
if (isNotNull(processorDTO.getPosition())) {
processor.setPosition(new Position(processorDTO.getPosition().getX(), processorDTO.getPosition().getY()));
}
if (isNotNull(processorDTO.getStyle())) {
processor.setStyle(processorDTO.getStyle());
}
final String name = processorDTO.getName();
if (isNotNull(name)) {
processor.setName(name);
}
}
use of org.apache.nifi.connectable.Position in project nifi by apache.
the class FingerprintFactoryTest method testRemoteProcessGroupFingerprintWithProxy.
@Test
public void testRemoteProcessGroupFingerprintWithProxy() throws Exception {
// Fill out every configuration.
final RemoteProcessGroup component = mock(RemoteProcessGroup.class);
when(component.getName()).thenReturn("name");
when(component.getIdentifier()).thenReturn("id");
when(component.getPosition()).thenReturn(new Position(10.5, 20.3));
when(component.getTargetUri()).thenReturn("http://node1:8080/nifi");
when(component.getTargetUris()).thenReturn("http://node1:8080/nifi, http://node2:8080/nifi");
when(component.getComments()).thenReturn("comment");
when(component.getCommunicationsTimeout()).thenReturn("10 sec");
when(component.getYieldDuration()).thenReturn("30 sec");
when(component.getTransportProtocol()).thenReturn(SiteToSiteTransportProtocol.HTTP);
when(component.getProxyHost()).thenReturn("proxy-host");
when(component.getProxyPort()).thenReturn(3128);
when(component.getProxyUser()).thenReturn("proxy-user");
when(component.getProxyPassword()).thenReturn("proxy-pass");
when(component.getVersionedComponentId()).thenReturn(Optional.empty());
// Assert fingerprints with expected one.
final String expected = "id" + "NO_VALUE" + "http://node1:8080/nifi, http://node2:8080/nifi" + "NO_VALUE" + "10 sec" + "30 sec" + "HTTP" + "proxy-host" + "3128" + "proxy-user" + "proxy-pass";
final Element rootElement = serializeElement(encryptor, RemoteProcessGroup.class, component, "addRemoteProcessGroup", IDENTITY_LOOKUP);
final Element componentElement = (Element) rootElement.getElementsByTagName("remoteProcessGroup").item(0);
assertEquals(expected.toString(), fingerprint("addRemoteProcessGroupFingerprint", Element.class, componentElement));
}
use of org.apache.nifi.connectable.Position in project nifi by apache.
the class FingerprintFactoryTest method testRemotePortFingerprint.
@Test
public void testRemotePortFingerprint() throws Exception {
// Fill out every configuration.
final RemoteProcessGroup groupComponent = mock(RemoteProcessGroup.class);
when(groupComponent.getName()).thenReturn("name");
when(groupComponent.getIdentifier()).thenReturn("id");
when(groupComponent.getPosition()).thenReturn(new Position(10.5, 20.3));
when(groupComponent.getTargetUri()).thenReturn("http://node1:8080/nifi");
when(groupComponent.getTransportProtocol()).thenReturn(SiteToSiteTransportProtocol.RAW);
when(groupComponent.getVersionedComponentId()).thenReturn(Optional.empty());
final RemoteGroupPort portComponent = mock(RemoteGroupPort.class);
when(groupComponent.getInputPorts()).thenReturn(Collections.singleton(portComponent));
when(portComponent.getName()).thenReturn("portName");
when(portComponent.getIdentifier()).thenReturn("portId");
when(portComponent.getPosition()).thenReturn(new Position(10.5, 20.3));
when(portComponent.getComments()).thenReturn("portComment");
when(portComponent.getScheduledState()).thenReturn(ScheduledState.RUNNING);
when(portComponent.getMaxConcurrentTasks()).thenReturn(3);
when(portComponent.isUseCompression()).thenReturn(true);
when(portComponent.getBatchCount()).thenReturn(1234);
when(portComponent.getBatchSize()).thenReturn("64KB");
when(portComponent.getBatchDuration()).thenReturn("10sec");
// Serializer doesn't serialize if a port doesn't have any connection.
when(portComponent.hasIncomingConnection()).thenReturn(true);
when(portComponent.getVersionedComponentId()).thenReturn(Optional.empty());
// Assert fingerprints with expected one.
final String expected = "portId" + "NO_VALUE" + "NO_VALUE" + "3" + "true" + "1234" + "64KB" + "10sec";
final Element rootElement = serializeElement(encryptor, RemoteProcessGroup.class, groupComponent, "addRemoteProcessGroup", IDENTITY_LOOKUP);
final Element componentElement = (Element) rootElement.getElementsByTagName("inputPort").item(0);
assertEquals(expected, fingerprint("addRemoteGroupPortFingerprint", Element.class, componentElement));
}
use of org.apache.nifi.connectable.Position in project nifi by apache.
the class StandardProcessGroup method updatePort.
private void updatePort(final Port port, final VersionedPort proposed) {
port.setComments(proposed.getComments());
port.setName(proposed.getName());
port.setPosition(new Position(proposed.getPosition().getX(), proposed.getPosition().getY()));
}
Aggregations