Search in sources :

Example 6 with Position

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;
}
Also used : Position(org.apache.nifi.connectable.Position) ProcessGroup(org.apache.nifi.groups.ProcessGroup) VersionedProcessGroup(org.apache.nifi.registry.flow.VersionedProcessGroup) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup)

Example 7 with Position

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);
    }
}
Also used : ProcessorConfigDTO(org.apache.nifi.web.api.dto.ProcessorConfigDTO) Position(org.apache.nifi.connectable.Position) Relationship(org.apache.nifi.processor.Relationship) HashSet(java.util.HashSet)

Example 8 with Position

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));
}
Also used : RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) Position(org.apache.nifi.connectable.Position) Element(org.w3c.dom.Element) Test(org.junit.Test)

Example 9 with Position

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));
}
Also used : RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) Position(org.apache.nifi.connectable.Position) RemoteGroupPort(org.apache.nifi.remote.RemoteGroupPort) Element(org.w3c.dom.Element) Test(org.junit.Test)

Example 10 with Position

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()));
}
Also used : Position(org.apache.nifi.connectable.Position)

Aggregations

Position (org.apache.nifi.connectable.Position)28 Port (org.apache.nifi.connectable.Port)10 ProcessGroup (org.apache.nifi.groups.ProcessGroup)10 RootGroupPort (org.apache.nifi.remote.RootGroupPort)10 ArrayList (java.util.ArrayList)9 Size (org.apache.nifi.connectable.Size)9 FlowFilePrioritizer (org.apache.nifi.flowfile.FlowFilePrioritizer)9 RemoteProcessGroup (org.apache.nifi.groups.RemoteProcessGroup)9 HashSet (java.util.HashSet)7 Funnel (org.apache.nifi.connectable.Funnel)7 Label (org.apache.nifi.controller.label.Label)7 Relationship (org.apache.nifi.processor.Relationship)7 RemoteGroupPort (org.apache.nifi.remote.RemoteGroupPort)7 BundleCoordinate (org.apache.nifi.bundle.BundleCoordinate)6 Connection (org.apache.nifi.connectable.Connection)5 ProcessorInstantiationException (org.apache.nifi.controller.exception.ProcessorInstantiationException)5 ControllerServiceNode (org.apache.nifi.controller.service.ControllerServiceNode)5 VersionedProcessGroup (org.apache.nifi.registry.flow.VersionedProcessGroup)5 Element (org.w3c.dom.Element)5 URL (java.net.URL)4