Java Code Examples for org.apache.nifi.connectable.ConnectableType#REMOTE_OUTPUT_PORT

The following examples show how to use org.apache.nifi.connectable.ConnectableType#REMOTE_OUTPUT_PORT . 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: StandardRemoteGroupPort.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isValid() {
    if (!targetExists.get()) {
        return false;
    }

    if (getConnectableType() == ConnectableType.REMOTE_OUTPUT_PORT && getConnections(Relationship.ANONYMOUS).isEmpty()) {
        // if it's an output port, ensure that there is an outbound connection
        return false;
    }

    final boolean groupValid = remoteGroup.validate().stream()
        .allMatch(result -> result.isValid());

    return groupValid;
}
 
Example 2
Source File: StandardRemoteGroupPort.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
@Override
public Collection<ValidationResult> getValidationErrors() {
    final Collection<ValidationResult> validationErrors = new ArrayList<>();
    if (getScheduledState() == ScheduledState.STOPPED) {
        ValidationResult error = null;
        if (!targetExists.get()) {
            error = new ValidationResult.Builder()
                    .explanation(String.format("Remote instance indicates that port '%s' no longer exists.", getName()))
                    .subject(String.format("Remote port '%s'", getName()))
                    .valid(false)
                    .build();
        } else if (getConnectableType() == ConnectableType.REMOTE_OUTPUT_PORT && getConnections(Relationship.ANONYMOUS).isEmpty()) {
            error = new ValidationResult.Builder()
                    .explanation(String.format("Port '%s' has no outbound connections", getName()))
                    .subject(String.format("Remote port '%s'", getName()))
                    .valid(false)
                    .build();
        }

        if (error != null) {
            validationErrors.add(error);
        }
    }
    return validationErrors;
}
 
Example 3
Source File: StandardRemoteProcessGroup.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
/**
 * Adds an Output Port to this Remote Process Group that is described by
 * this DTO.
 *
 * @param descriptor
 *
 * @throws IllegalStateException if an Output Port already exists with the
 * ID given by dto.getId()
 */
private void addOutputPort(final RemoteProcessGroupPortDescriptor descriptor) {
    writeLock.lock();
    try {
        if (outputPorts.containsKey(requireNonNull(descriptor).getId())) {
            throw new IllegalStateException("Output Port with ID " + descriptor.getId() + " already exists");
        }

        final StandardRemoteGroupPort port = new StandardRemoteGroupPort(descriptor.getId(), descriptor.getName(), getProcessGroup(),
            this, TransferDirection.RECEIVE, ConnectableType.REMOTE_OUTPUT_PORT, sslContext, scheduler, nifiProperties);
        outputPorts.put(descriptor.getId(), port);

        if (descriptor.getConcurrentlySchedulableTaskCount() != null) {
            port.setMaxConcurrentTasks(descriptor.getConcurrentlySchedulableTaskCount());
        }
        if (descriptor.getUseCompression() != null) {
            port.setUseCompression(descriptor.getUseCompression());
        }
    } finally {
        writeLock.unlock();
    }
}
 
Example 4
Source File: StandardRemoteGroupPort.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isValid() {
    if (!targetExists.get()) {
        return false;
    }

    if (getConnectableType() == ConnectableType.REMOTE_OUTPUT_PORT && getConnections(Relationship.ANONYMOUS).isEmpty()) {
        // if it's an output port, ensure that there is an outbound connection
        return false;
    }

    final boolean groupValid = remoteGroup.validate().stream()
        .allMatch(result -> result.isValid());

    return groupValid;
}
 
Example 5
Source File: StandardRemoteGroupPort.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Override
public Collection<ValidationResult> getValidationErrors() {
    final Collection<ValidationResult> validationErrors = new ArrayList<>();
    if (getScheduledState() == ScheduledState.STOPPED) {
        ValidationResult error = null;
        if (!targetExists.get()) {
            error = new ValidationResult.Builder()
                    .explanation(String.format("Remote instance indicates that port '%s' no longer exists.", getName()))
                    .subject(String.format("Remote port '%s'", getName()))
                    .valid(false)
                    .build();
        } else if (getConnectableType() == ConnectableType.REMOTE_OUTPUT_PORT && getConnections(Relationship.ANONYMOUS).isEmpty()) {
            error = new ValidationResult.Builder()
                    .explanation(String.format("Port '%s' has no outbound connections", getName()))
                    .subject(String.format("Remote port '%s'", getName()))
                    .valid(false)
                    .build();
        }

        if (error != null) {
            validationErrors.add(error);
        }
    }
    return validationErrors;
}
 
Example 6
Source File: StandardRemoteProcessGroup.java    From nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Adds an Output Port to this Remote Process Group that is described by
 * this DTO.
 *
 * @param descriptor the RPG port descriptor
 * @throws IllegalStateException if an Output Port already exists with the
 *                               ID given by dto.getId()
 */
private StandardRemoteGroupPort addOutputPort(final RemoteProcessGroupPortDescriptor descriptor) {
    writeLock.lock();
    try {
        if (outputPorts.containsKey(requireNonNull(descriptor).getId())) {
            throw new IllegalStateException("Output Port with ID " + descriptor.getId() + " already exists");
        }

        final StandardRemoteGroupPort port = new StandardRemoteGroupPort(descriptor.getId(), descriptor.getTargetId(), descriptor.getName(),
                this, TransferDirection.RECEIVE, ConnectableType.REMOTE_OUTPUT_PORT, sslContext, scheduler, nifiProperties);
        port.setProcessGroup(getProcessGroup());
        outputPorts.put(descriptor.getId(), port);

        if (descriptor.getConcurrentlySchedulableTaskCount() != null) {
            port.setMaxConcurrentTasks(descriptor.getConcurrentlySchedulableTaskCount());
        }
        if (descriptor.getUseCompression() != null) {
            port.setUseCompression(descriptor.getUseCompression());
        }
        if (descriptor.getBatchCount() != null && descriptor.getBatchCount() > 0) {
            port.setBatchCount(descriptor.getBatchCount());
        }
        if (!StringUtils.isBlank(descriptor.getBatchSize())) {
            port.setBatchSize(descriptor.getBatchSize());
        }
        if (!StringUtils.isBlank(descriptor.getBatchDuration())) {
            port.setBatchDuration(descriptor.getBatchDuration());
        }
        port.setVersionedComponentId(descriptor.getVersionedComponentId());

        return port;
    } finally {
        writeLock.unlock();
    }
}
 
Example 7
Source File: StandardRemoteGroupPort.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isTriggerWhenEmpty() {
    return getConnectableType() == ConnectableType.REMOTE_OUTPUT_PORT;
}
 
Example 8
Source File: StandardFlowSerializer.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
private void addConnection(final Element parentElement, final Connection connection) {
    final Document doc = parentElement.getOwnerDocument();
    final Element element = doc.createElement("connection");
    parentElement.appendChild(element);
    addTextElement(element, "id", connection.getIdentifier());
    addTextElement(element, "name", connection.getName());

    final Element bendPointsElement = doc.createElement("bendPoints");
    element.appendChild(bendPointsElement);
    for (final Position bendPoint : connection.getBendPoints()) {
        addPosition(bendPointsElement, bendPoint, "bendPoint");
    }

    addTextElement(element, "labelIndex", connection.getLabelIndex());
    addTextElement(element, "zIndex", connection.getZIndex());

    final String sourceId = connection.getSource().getIdentifier();
    final ConnectableType sourceType = connection.getSource().getConnectableType();
    final String sourceGroupId;
    if (sourceType == ConnectableType.REMOTE_OUTPUT_PORT) {
        sourceGroupId = ((RemoteGroupPort) connection.getSource()).getRemoteProcessGroup().getIdentifier();
    } else {
        sourceGroupId = connection.getSource().getProcessGroup().getIdentifier();
    }

    final ConnectableType destinationType = connection.getDestination().getConnectableType();
    final String destinationId = connection.getDestination().getIdentifier();
    final String destinationGroupId;
    if (destinationType == ConnectableType.REMOTE_INPUT_PORT) {
        destinationGroupId = ((RemoteGroupPort) connection.getDestination()).getRemoteProcessGroup().getIdentifier();
    } else {
        destinationGroupId = connection.getDestination().getProcessGroup().getIdentifier();
    }

    addTextElement(element, "sourceId", sourceId);
    addTextElement(element, "sourceGroupId", sourceGroupId);
    addTextElement(element, "sourceType", sourceType.toString());

    addTextElement(element, "destinationId", destinationId);
    addTextElement(element, "destinationGroupId", destinationGroupId);
    addTextElement(element, "destinationType", destinationType.toString());

    for (final Relationship relationship : connection.getRelationships()) {
        addTextElement(element, "relationship", relationship.getName());
    }

    addTextElement(element, "maxWorkQueueSize", connection.getFlowFileQueue().getBackPressureObjectThreshold());
    addTextElement(element, "maxWorkQueueDataSize", connection.getFlowFileQueue().getBackPressureDataSizeThreshold());

    addTextElement(element, "flowFileExpiration", connection.getFlowFileQueue().getFlowFileExpiration());
    for (final FlowFilePrioritizer comparator : connection.getFlowFileQueue().getPriorities()) {
        final String className = comparator.getClass().getCanonicalName();
        addTextElement(element, "queuePrioritizerClass", className);
    }

    parentElement.appendChild(element);
}
 
Example 9
Source File: StandardRemoteGroupPort.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isTriggerWhenEmpty() {
    return getConnectableType() == ConnectableType.REMOTE_OUTPUT_PORT;
}
 
Example 10
Source File: StandardFlowSerializer.java    From nifi with Apache License 2.0 4 votes vote down vote up
private void addConnection(final Element parentElement, final Connection connection) {
    final Document doc = parentElement.getOwnerDocument();
    final Element element = doc.createElement("connection");
    parentElement.appendChild(element);
    addTextElement(element, "id", connection.getIdentifier());
    addTextElement(element, "versionedComponentId", connection.getVersionedComponentId());
    addTextElement(element, "name", connection.getName());

    final Element bendPointsElement = doc.createElement("bendPoints");
    element.appendChild(bendPointsElement);
    for (final Position bendPoint : connection.getBendPoints()) {
        addPosition(bendPointsElement, bendPoint, "bendPoint");
    }

    addTextElement(element, "labelIndex", connection.getLabelIndex());
    addTextElement(element, "zIndex", connection.getZIndex());

    final String sourceId = connection.getSource().getIdentifier();
    final ConnectableType sourceType = connection.getSource().getConnectableType();
    final String sourceGroupId;
    if (sourceType == ConnectableType.REMOTE_OUTPUT_PORT) {
        sourceGroupId = ((RemoteGroupPort) connection.getSource()).getRemoteProcessGroup().getIdentifier();
    } else {
        sourceGroupId = connection.getSource().getProcessGroup().getIdentifier();
    }

    final ConnectableType destinationType = connection.getDestination().getConnectableType();
    final String destinationId = connection.getDestination().getIdentifier();
    final String destinationGroupId;
    if (destinationType == ConnectableType.REMOTE_INPUT_PORT) {
        destinationGroupId = ((RemoteGroupPort) connection.getDestination()).getRemoteProcessGroup().getIdentifier();
    } else {
        destinationGroupId = connection.getDestination().getProcessGroup().getIdentifier();
    }

    addTextElement(element, "sourceId", sourceId);
    addTextElement(element, "sourceGroupId", sourceGroupId);
    addTextElement(element, "sourceType", sourceType.toString());

    addTextElement(element, "destinationId", destinationId);
    addTextElement(element, "destinationGroupId", destinationGroupId);
    addTextElement(element, "destinationType", destinationType.toString());

    for (final Relationship relationship : connection.getRelationships()) {
        addTextElement(element, "relationship", relationship.getName());
    }

    addTextElement(element, "maxWorkQueueSize", connection.getFlowFileQueue().getBackPressureObjectThreshold());
    addTextElement(element, "maxWorkQueueDataSize", connection.getFlowFileQueue().getBackPressureDataSizeThreshold());

    addTextElement(element, "flowFileExpiration", connection.getFlowFileQueue().getFlowFileExpiration());
    for (final FlowFilePrioritizer comparator : connection.getFlowFileQueue().getPriorities()) {
        final String className = comparator.getClass().getCanonicalName();
        addTextElement(element, "queuePrioritizerClass", className);
    }

    addTextElement(element, "loadBalanceStrategy", connection.getFlowFileQueue().getLoadBalanceStrategy().name());
    addTextElement(element, "partitioningAttribute", connection.getFlowFileQueue().getPartitioningAttribute());
    addTextElement(element, "loadBalanceCompression", connection.getFlowFileQueue().getLoadBalanceCompression().name());

    parentElement.appendChild(element);
}