org.apache.nifi.registry.flow.VersionedPort Java Examples

The following examples show how to use org.apache.nifi.registry.flow.VersionedPort. 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: NiFiRegistryFlowMapper.java    From nifi with Apache License 2.0 6 votes vote down vote up
public VersionedPort mapPort(final Port port) {
    final VersionedPort versionedPort = new InstantiatedVersionedPort(port.getIdentifier(), port.getProcessGroupIdentifier());
    versionedPort.setIdentifier(getId(port.getVersionedComponentId(), port.getIdentifier()));
    versionedPort.setGroupIdentifier(getGroupId(port.getProcessGroupIdentifier()));
    versionedPort.setComments(port.getComments());
    versionedPort.setConcurrentlySchedulableTaskCount(port.getMaxConcurrentTasks());
    versionedPort.setName(port.getName());
    versionedPort.setPosition(mapPosition(port.getPosition()));
    versionedPort.setType(PortType.valueOf(port.getConnectableType().name()));

    if (port instanceof PublicPort) {
        versionedPort.setAllowRemoteAccess(true);
    } else {
        versionedPort.setAllowRemoteAccess(false);
    }

    return versionedPort;
}
 
Example #2
Source File: TestFlowDifferenceFilters.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Test
public void testFilterPublicPortNameChangeWhenAllowRemoteAccess() {
    final VersionedPort portA = new VersionedPort();
    portA.setAllowRemoteAccess(true);

    final VersionedPort portB = new VersionedPort();
    portB.setAllowRemoteAccess(false);

    final StandardFlowDifference flowDifference = new StandardFlowDifference(
            DifferenceType.NAME_CHANGED,
            portA, portB,
            "Port A", "Port B",
            "");

    Assert.assertFalse(FlowDifferenceFilters.FILTER_PUBLIC_PORT_NAME_CHANGES.test(flowDifference));
}
 
Example #3
Source File: NiFiRegistryFlowMapperTest.java    From nifi with Apache License 2.0 6 votes vote down vote up
private void verifyPorts(final Set<Port> ports, final Set<VersionedPort> versionedPorts, final PortType portType,
                         final String expectedGroupIdentifier) {
    if (ports.isEmpty()) {
        assertTrue(versionedPorts.isEmpty());
    } else {
        final Port port = ports.iterator().next();
        final VersionedPort versionedPort = versionedPorts.iterator().next();

        assertEquals(flowMapper.getGroupId(port.getIdentifier()), versionedPort.getIdentifier());
        assertEquals(expectedGroupIdentifier, versionedPort.getGroupIdentifier());
        assertEquals(port.getPosition().getX(), versionedPort.getPosition().getX(), 0);
        assertEquals(port.getPosition().getY(), versionedPort.getPosition().getY(), 0);
        assertEquals(port.getName(), versionedPort.getName());
        assertEquals(portType, versionedPort.getType());
    }
}
 
Example #4
Source File: StandardFlowComparator.java    From nifi-registry with Apache License 2.0 5 votes vote down vote up
private void compare(final VersionedPort portA, final VersionedPort portB, final Set<FlowDifference> differences) {
    if (compareComponents(portA, portB, differences)) {
        return;
    }

    if (portA != null && portA.isAllowRemoteAccess() && portB != null && portB.isAllowRemoteAccess()) {
        addIfDifferent(differences, DifferenceType.CONCURRENT_TASKS_CHANGED, portA, portB, VersionedPort::getConcurrentlySchedulableTaskCount);
    }
}
 
Example #5
Source File: NiFiRegPortSchemaFunction.java    From nifi-minifi with Apache License 2.0 5 votes vote down vote up
@Override
public PortSchema apply(VersionedPort versionedPort) {
    Map<String, Object> map = new HashMap<>();
    map.put(ID_KEY, versionedPort.getIdentifier());
    map.put(NAME_KEY, versionedPort.getName());
    return new PortSchema(map, wrapperName);
}
 
Example #6
Source File: FlowDifferenceFilters.java    From nifi with Apache License 2.0 5 votes vote down vote up
public static boolean isPublicPortNameChange(final FlowDifference fd) {
    final VersionedComponent versionedComponent = fd.getComponentA();
    if (fd.getDifferenceType() == DifferenceType.NAME_CHANGED && versionedComponent instanceof VersionedPort) {
        final VersionedPort versionedPort = (VersionedPort) versionedComponent;
        if (versionedPort.isAllowRemoteAccess()) {
            return true;
        }
    }

    return false;
}
 
Example #7
Source File: TestFlowDifferenceFilters.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void testFilterPublicPortNameChangeWhenNotNameChange() {
    final VersionedPort portA = new VersionedPort();
    final VersionedPort portB = new VersionedPort();

    final StandardFlowDifference flowDifference = new StandardFlowDifference(
            DifferenceType.VERSIONED_FLOW_COORDINATES_CHANGED,
            portA, portB,
            "http://localhost:18080", "http://localhost:17080",
            "");

    Assert.assertTrue(FlowDifferenceFilters.FILTER_PUBLIC_PORT_NAME_CHANGES.test(flowDifference));
}
 
Example #8
Source File: TestFlowDifferenceFilters.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void testFilterPublicPortNameChangeWhenNotAllowRemoteAccess() {
    final VersionedPort portA = new VersionedPort();
    final VersionedPort portB = new VersionedPort();

    final StandardFlowDifference flowDifference = new StandardFlowDifference(
            DifferenceType.NAME_CHANGED,
            portA, portB,
            "Port A", "Port B",
            "");

    Assert.assertTrue(FlowDifferenceFilters.FILTER_PUBLIC_PORT_NAME_CHANGES.test(flowDifference));
}