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

The following examples show how to use org.apache.nifi.registry.flow.VersionedRemoteGroupPort. 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: StatelessRemoteInputPort.java    From nifi with Apache License 2.0 6 votes vote down vote up
public StatelessRemoteInputPort(final VersionedRemoteProcessGroup rpg, final VersionedRemoteGroupPort remotePort, final SSLContext sslContext) {
    final String timeout = rpg.getCommunicationsTimeout();
    final long timeoutMillis = FormatUtils.getTimeDuration(timeout, TimeUnit.MILLISECONDS);

    url = rpg.getTargetUris();
    name = remotePort.getName();

    client = new SiteToSiteClient.Builder()
        .portName(remotePort.getName())
        .timeout(timeoutMillis, TimeUnit.MILLISECONDS)
        .transportProtocol(SiteToSiteTransportProtocol.valueOf(rpg.getTransportProtocol()))
        .url(rpg.getTargetUris())
        .useCompression(remotePort.isUseCompression())
        .sslContext(sslContext)
        .eventReporter(EventReporter.NO_OP)
        .build();
}
 
Example #2
Source File: StandardFlowComparator.java    From nifi-registry with Apache License 2.0 5 votes vote down vote up
private void compare(final VersionedRemoteGroupPort portA, final VersionedRemoteGroupPort portB, final Set<FlowDifference> differences) {
    if (compareComponents(portA, portB, differences)) {
        return;
    }

    addIfDifferent(differences, DifferenceType.REMOTE_PORT_BATCH_SIZE_CHANGED, portA, portB, VersionedRemoteGroupPort::getBatchSize);
    addIfDifferent(differences, DifferenceType.REMOTE_PORT_COMPRESSION_CHANGED, portA, portB, VersionedRemoteGroupPort::isUseCompression);
    addIfDifferent(differences, DifferenceType.CONCURRENT_TASKS_CHANGED, portA, portB, VersionedRemoteGroupPort::getConcurrentlySchedulableTaskCount);
}
 
Example #3
Source File: NiFiRegRemotePortSchemaFunction.java    From nifi-minifi with Apache License 2.0 5 votes vote down vote up
@Override
public RemotePortSchema apply(VersionedRemoteGroupPort versionedRemoteGroupPort) {
    Map<String, Object> map = new HashMap<>();
    // If a targetId is specified, it takes precedence over the original id
    final String targetId = versionedRemoteGroupPort.getTargetId();
    map.put(ID_KEY, StringUtils.isNotBlank(targetId) ? targetId : versionedRemoteGroupPort.getIdentifier());
    map.put(NAME_KEY, versionedRemoteGroupPort.getName());

    map.put(CommonPropertyKeys.COMMENT_KEY, versionedRemoteGroupPort.getComments());
    map.put(CommonPropertyKeys.MAX_CONCURRENT_TASKS_KEY, versionedRemoteGroupPort.getConcurrentlySchedulableTaskCount());
    map.put(CommonPropertyKeys.USE_COMPRESSION_KEY, versionedRemoteGroupPort.isUseCompression());
    return new RemotePortSchema(map);
}
 
Example #4
Source File: NiFiRegRemoteProcessGroupSchemaFunction.java    From nifi-minifi with Apache License 2.0 5 votes vote down vote up
@Override
public RemoteProcessGroupSchema apply(VersionedRemoteProcessGroup versionedRemoteProcessGroup) {
    Map<String, Object> map = new HashMap<>();
    map.put(CommonPropertyKeys.ID_KEY, versionedRemoteProcessGroup.getIdentifier());
    map.put(CommonPropertyKeys.NAME_KEY, versionedRemoteProcessGroup.getName());
    map.put(RemoteProcessGroupSchema.URL_KEY, versionedRemoteProcessGroup.getTargetUri());

    Set<VersionedRemoteGroupPort> inputPorts = versionedRemoteProcessGroup.getInputPorts();
    if (inputPorts != null) {
        map.put(CommonPropertyKeys.INPUT_PORTS_KEY, inputPorts.stream()
                .map(remotePortSchemaFunction)
                .map(RemotePortSchema::toMap)
                .collect(Collectors.toList()));
    }

    Set<VersionedRemoteGroupPort> outputPorts = versionedRemoteProcessGroup.getOutputPorts();
    if (outputPorts != null) {
        map.put(CommonPropertyKeys.OUTPUT_PORTS_KEY, outputPorts.stream()
                .map(remotePortSchemaFunction)
                .map(RemotePortSchema::toMap)
                .collect(Collectors.toList()));
    }


    map.put(CommonPropertyKeys.COMMENT_KEY, versionedRemoteProcessGroup.getComments());
    map.put(RemoteProcessGroupSchema.TIMEOUT_KEY, versionedRemoteProcessGroup.getCommunicationsTimeout());
    map.put(CommonPropertyKeys.YIELD_PERIOD_KEY, versionedRemoteProcessGroup.getYieldDuration());
    map.put(RemoteProcessGroupSchema.TRANSPORT_PROTOCOL_KEY, versionedRemoteProcessGroup.getTransportProtocol());
    map.put(RemoteProcessGroupSchema.PROXY_HOST_KEY, versionedRemoteProcessGroup.getProxyHost());
    map.put(RemoteProcessGroupSchema.PROXY_PORT_KEY, versionedRemoteProcessGroup.getProxyPort());
    map.put(RemoteProcessGroupSchema.PROXY_USER_KEY, versionedRemoteProcessGroup.getProxyUser());

    // TODO - we don't have this in registry data model, most likely templates blank it out too?
    //map.put(RemoteProcessGroupSchema.PROXY_PASSWORD_KEY, versionedRemoteProcessGroup.getProxyPassword());

    map.put(RemoteProcessGroupSchema.LOCAL_NETWORK_INTERFACE_KEY, versionedRemoteProcessGroup.getLocalNetworkInterface());
    return new RemoteProcessGroupSchema(map);
}
 
Example #5
Source File: StatelessRemoteOutputPort.java    From nifi with Apache License 2.0 5 votes vote down vote up
public StatelessRemoteOutputPort(final VersionedRemoteProcessGroup rpg, final VersionedRemoteGroupPort remotePort, final SSLContext sslContext) {
    final String timeout = rpg.getCommunicationsTimeout();
    final long timeoutMillis = FormatUtils.getTimeDuration(timeout, TimeUnit.MILLISECONDS);

    url = rpg.getTargetUris();
    name = remotePort.getName();

    final BatchSize batchSize = remotePort.getBatchSize();
    final int batchCount;
    final long batchBytes;
    final long batchMillis;
    if (batchSize == null) {
        batchCount = 1;
        batchBytes = 1L;
        batchMillis = 1L;
    } else {
        batchCount = batchSize.getCount() == null ? 1 : batchSize.getCount();
        batchBytes = batchSize.getSize() == null ? 1L : DataUnit.parseDataSize(batchSize.getSize(), DataUnit.B).longValue();
        batchMillis = batchSize.getDuration() == null ? 1L : FormatUtils.getTimeDuration(batchSize.getDuration(), TimeUnit.MILLISECONDS);
    }

    client = new SiteToSiteClient.Builder()
        .portName(remotePort.getName())
        .timeout(timeoutMillis, TimeUnit.MILLISECONDS)
        .requestBatchCount(batchCount)
        .requestBatchDuration(batchMillis, TimeUnit.MILLISECONDS)
        .requestBatchSize(batchBytes)
        .transportProtocol(SiteToSiteTransportProtocol.valueOf(rpg.getTransportProtocol()))
        .url(rpg.getTargetUris())
        .sslContext(sslContext)
        .useCompression(remotePort.isUseCompression())
        .eventReporter(EventReporter.NO_OP)
        .build();
}
 
Example #6
Source File: StatelessFlow.java    From nifi with Apache License 2.0 5 votes vote down vote up
private void findRemoteGroupRecursive(final VersionedProcessGroup group, final Map<String, VersionedRemoteProcessGroup> rpgs, final Map<String, VersionedRemoteGroupPort> ports) {
    for (final VersionedRemoteProcessGroup rpg : group.getRemoteProcessGroups()) {
        rpgs.put(rpg.getIdentifier(), rpg);

        rpg.getInputPorts().forEach(port -> ports.put(port.getIdentifier(), port));
        rpg.getOutputPorts().forEach(port -> ports.put(port.getIdentifier(), port));
    }
}
 
Example #7
Source File: NiFiRegistryFlowMapper.java    From nifi with Apache License 2.0 5 votes vote down vote up
public VersionedRemoteGroupPort mapRemotePort(final RemoteGroupPort remotePort, final ComponentType componentType) {
    final VersionedRemoteGroupPort port = new InstantiatedVersionedRemoteGroupPort(remotePort.getIdentifier(), remotePort.getRemoteProcessGroup().getIdentifier());
    port.setIdentifier(getId(remotePort.getVersionedComponentId(), remotePort.getIdentifier()));
    port.setGroupIdentifier(getGroupId(remotePort.getRemoteProcessGroup().getIdentifier()));
    port.setComments(remotePort.getComments());
    port.setConcurrentlySchedulableTaskCount(remotePort.getMaxConcurrentTasks());
    port.setRemoteGroupId(getGroupId(remotePort.getRemoteProcessGroup().getIdentifier()));
    port.setName(remotePort.getName());
    port.setUseCompression(remotePort.isUseCompression());
    port.setBatchSize(mapBatchSettings(remotePort));
    port.setTargetId(remotePort.getTargetIdentifier());
    port.setComponentType(componentType);
    return port;
}
 
Example #8
Source File: TestFlowDifferenceFilters.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void testFilterAddedRemotePortsWithRemoteInputPortAsComponentB() {
    VersionedRemoteGroupPort remoteGroupPort = new VersionedRemoteGroupPort();
    remoteGroupPort.setComponentType(ComponentType.REMOTE_INPUT_PORT);

    StandardFlowDifference flowDifference = new StandardFlowDifference(
            DifferenceType.COMPONENT_ADDED, null, remoteGroupPort, null, null, "");

    // predicate should return false because we don't want to include changes for adding a remote input port
    Assert.assertFalse(FlowDifferenceFilters.FILTER_ADDED_REMOVED_REMOTE_PORTS.test(flowDifference));
}
 
Example #9
Source File: TestFlowDifferenceFilters.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void testFilterAddedRemotePortsWithRemoteInputPortAsComponentA() {
    VersionedRemoteGroupPort remoteGroupPort = new VersionedRemoteGroupPort();
    remoteGroupPort.setComponentType(ComponentType.REMOTE_INPUT_PORT);

    StandardFlowDifference flowDifference = new StandardFlowDifference(
            DifferenceType.COMPONENT_ADDED, remoteGroupPort, null, null, null, "");

    // predicate should return false because we don't want to include changes for adding a remote input port
    Assert.assertFalse(FlowDifferenceFilters.FILTER_ADDED_REMOVED_REMOTE_PORTS.test(flowDifference));
}
 
Example #10
Source File: TestFlowDifferenceFilters.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void testFilterAddedRemotePortsWithRemoteOutputPort() {
    VersionedRemoteGroupPort remoteGroupPort = new VersionedRemoteGroupPort();
    remoteGroupPort.setComponentType(ComponentType.REMOTE_OUTPUT_PORT);

    StandardFlowDifference flowDifference = new StandardFlowDifference(
            DifferenceType.COMPONENT_ADDED, null, remoteGroupPort, null, null, "");

    // predicate should return false because we don't want to include changes for adding a remote input port
    Assert.assertFalse(FlowDifferenceFilters.FILTER_ADDED_REMOVED_REMOTE_PORTS.test(flowDifference));
}
 
Example #11
Source File: NiFiRegistryFlowMapperTest.java    From nifi with Apache License 2.0 5 votes vote down vote up
private void verifyRemotePorts(final Set<RemoteGroupPort> remotePorts,
                               final Set<VersionedRemoteGroupPort> versionedRemotePorts,
                               final ComponentType componentType, final String expectedPortGroupIdentifier) {
    if (remotePorts.isEmpty()) {
        assertTrue(versionedRemotePorts.isEmpty());
    } else {
        final RemoteGroupPort remotePort = remotePorts.iterator().next();
        final VersionedRemoteGroupPort versionedRemotePort = versionedRemotePorts.iterator().next();

        assertEquals(flowMapper.getGroupId(remotePort.getIdentifier()), versionedRemotePort.getIdentifier());
        assertEquals(expectedPortGroupIdentifier, versionedRemotePort.getGroupIdentifier());
        assertEquals(remotePort.getName(), versionedRemotePort.getName());
        assertEquals(componentType, versionedRemotePort.getComponentType());
    }
}