Java Code Examples for org.apache.nifi.groups.RemoteProcessGroup#getInputPort()

The following examples show how to use org.apache.nifi.groups.RemoteProcessGroup#getInputPort() . 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: StandardRemoteProcessGroupDAO.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Override
public RemoteGroupPort updateRemoteProcessGroupInputPort(String remoteProcessGroupId, RemoteProcessGroupPortDTO remoteProcessGroupPortDto) {
    final RemoteProcessGroup remoteProcessGroup = locateRemoteProcessGroup(remoteProcessGroupId);
    final RemoteGroupPort port = remoteProcessGroup.getInputPort(remoteProcessGroupPortDto.getId());

    if (port == null) {
        throw new ResourceNotFoundException(
                String.format("Unable to find remote process group input port with id '%s'.", remoteProcessGroupPortDto.getId()));
    }

    // verify the update
    verifyUpdatePort(port, remoteProcessGroupPortDto);

    // perform the update
    updatePort(port, remoteProcessGroupPortDto, remoteProcessGroup);

    remoteProcessGroup.getProcessGroup().onComponentModified();
    return port;
}
 
Example 2
Source File: StandardRemoteProcessGroupDAO.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@Override
public void verifyUpdateInputPort(String remoteProcessGroupId, RemoteProcessGroupPortDTO remoteProcessGroupPortDto) {
    final RemoteProcessGroup remoteProcessGroup = locateRemoteProcessGroup(remoteProcessGroupId);
    final RemoteGroupPort port = remoteProcessGroup.getInputPort(remoteProcessGroupPortDto.getId());

    if (port == null) {
        throw new ResourceNotFoundException(
                String.format("Unable to find remote process group input port with id '%s'.", remoteProcessGroupPortDto.getId()));
    }

    verifyUpdatePort(port, remoteProcessGroupPortDto);
}
 
Example 3
Source File: StandardRemoteProcessGroupDAO.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@Override
public RemoteGroupPort updateRemoteProcessGroupInputPort(String remoteProcessGroupId, RemoteProcessGroupPortDTO remoteProcessGroupPortDto) {
    final RemoteProcessGroup remoteProcessGroup = locateRemoteProcessGroup(remoteProcessGroupId);
    final RemoteGroupPort port = remoteProcessGroup.getInputPort(remoteProcessGroupPortDto.getId());

    if (port == null) {
        throw new ResourceNotFoundException(
                String.format("Unable to find remote process group input port with id '%s'.", remoteProcessGroupPortDto.getId()));
    }

    // verify the update
    verifyUpdatePort(port, remoteProcessGroupPortDto);

    // perform the update
    if (isNotNull(remoteProcessGroupPortDto.getConcurrentlySchedulableTaskCount())) {
        port.setMaxConcurrentTasks(remoteProcessGroupPortDto.getConcurrentlySchedulableTaskCount());
    }
    if (isNotNull(remoteProcessGroupPortDto.getUseCompression())) {
        port.setUseCompression(remoteProcessGroupPortDto.getUseCompression());
    }

    final Boolean isTransmitting = remoteProcessGroupPortDto.isTransmitting();
    if (isNotNull(isTransmitting)) {
        // start or stop as necessary
        if (!port.isRunning() && isTransmitting) {
            remoteProcessGroup.startTransmitting(port);
        } else if (port.isRunning() && !isTransmitting) {
            remoteProcessGroup.stopTransmitting(port);
        }
    }

    return port;
}
 
Example 4
Source File: RemoteProcessGroupAuditor.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Audits the update of remote process group input port configuration.
 *
 * @param proceedingJoinPoint       join point
 * @param remoteProcessGroupPortDto dto
 * @param remoteProcessGroupDAO     dao
 * @return group
 * @throws Throwable ex
 */
@Around("within(org.apache.nifi.web.dao.RemoteProcessGroupDAO+) && "
        + "execution(org.apache.nifi.remote.RemoteGroupPort updateRemoteProcessGroupInputPort(java.lang.String, org.apache.nifi.web.api.dto.RemoteProcessGroupPortDTO)) && "
        + "args(remoteProcessGroupId, remoteProcessGroupPortDto) && "
        + "target(remoteProcessGroupDAO)")
public RemoteGroupPort auditUpdateProcessGroupInputPortConfiguration(
        ProceedingJoinPoint proceedingJoinPoint, String remoteProcessGroupId,
        RemoteProcessGroupPortDTO remoteProcessGroupPortDto, RemoteProcessGroupDAO remoteProcessGroupDAO) throws Throwable {

    final RemoteProcessGroup remoteProcessGroup = remoteProcessGroupDAO.getRemoteProcessGroup(remoteProcessGroupId);
    final RemoteGroupPort remoteProcessGroupPort = remoteProcessGroup.getInputPort(remoteProcessGroupPortDto.getId());

    return auditUpdateProcessGroupPortConfiguration(proceedingJoinPoint, remoteProcessGroupPortDto, remoteProcessGroup, remoteProcessGroupPort);
}
 
Example 5
Source File: StandardRemoteProcessGroupDAO.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
public void verifyUpdateInputPort(String remoteProcessGroupId, RemoteProcessGroupPortDTO remoteProcessGroupPortDto) {
    final RemoteProcessGroup remoteProcessGroup = locateRemoteProcessGroup(remoteProcessGroupId);
    final RemoteGroupPort port = remoteProcessGroup.getInputPort(remoteProcessGroupPortDto.getId());

    if (port == null) {
        throw new ResourceNotFoundException(
                String.format("Unable to find remote process group input port with id '%s'.", remoteProcessGroupPortDto.getId()));
    }

    verifyUpdatePort(port, remoteProcessGroupPortDto);
}
 
Example 6
Source File: RemoteProcessGroupAuditor.java    From nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Audits the update of remote process group input port configuration.
 *
 * @param proceedingJoinPoint       join point
 * @param remoteProcessGroupPortDto dto
 * @param remoteProcessGroupDAO     dao
 * @return group
 * @throws Throwable ex
 */
@Around("within(org.apache.nifi.web.dao.RemoteProcessGroupDAO+) && "
        + "execution(org.apache.nifi.remote.RemoteGroupPort updateRemoteProcessGroupInputPort(java.lang.String, org.apache.nifi.web.api.dto.RemoteProcessGroupPortDTO)) && "
        + "args(remoteProcessGroupId, remoteProcessGroupPortDto) && "
        + "target(remoteProcessGroupDAO)")
public RemoteGroupPort auditUpdateProcessGroupInputPortConfiguration(
        ProceedingJoinPoint proceedingJoinPoint, String remoteProcessGroupId,
        RemoteProcessGroupPortDTO remoteProcessGroupPortDto, RemoteProcessGroupDAO remoteProcessGroupDAO) throws Throwable {

    final RemoteProcessGroup remoteProcessGroup = remoteProcessGroupDAO.getRemoteProcessGroup(remoteProcessGroupId);
    final RemoteGroupPort remoteProcessGroupPort = remoteProcessGroup.getInputPort(remoteProcessGroupPortDto.getId());

    return auditUpdateProcessGroupPortConfiguration(proceedingJoinPoint, remoteProcessGroupPortDto, remoteProcessGroup, remoteProcessGroupPort);
}
 
Example 7
Source File: StandardConnectionDAO.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
/**
 * Validates the proposed processor configuration.
 */
private List<String> validateProposedConfiguration(final String groupId, final ConnectionDTO connectionDTO) {
    List<String> validationErrors = new ArrayList<>();

    if (isNotNull(connectionDTO.getBackPressureObjectThreshold()) && connectionDTO.getBackPressureObjectThreshold() < 0) {
        validationErrors.add("Max queue size must be a non-negative integer");
    }
    if (isNotNull(connectionDTO.getFlowFileExpiration())) {
        Matcher expirationMatcher = FormatUtils.TIME_DURATION_PATTERN.matcher(connectionDTO.getFlowFileExpiration());
        if (!expirationMatcher.matches()) {
            validationErrors.add("Flow file expiration is not a valid time duration (ie 30 sec, 5 min)");
        }
    }
    if (isNotNull(connectionDTO.getLabelIndex())) {
        if (connectionDTO.getLabelIndex() < 0) {
            validationErrors.add("The label index must be positive.");
        }
    }

    // validation is required when connecting to a remote process group since each node in a
    // cluster may or may not be authorized
    final ConnectableDTO proposedDestination = connectionDTO.getDestination();
    if (proposedDestination != null && ConnectableType.REMOTE_INPUT_PORT.name().equals(proposedDestination.getType())) {
        // the group id must be specified
        if (proposedDestination.getGroupId() == null) {
            validationErrors.add("When the destination is a remote input port its group id is required.");
            return validationErrors;
        }

        // attempt to location the proprosed destination
        final ProcessGroup destinationParentGroup = locateProcessGroup(flowController, groupId);
        final RemoteProcessGroup remoteProcessGroup = destinationParentGroup.getRemoteProcessGroup(proposedDestination.getGroupId());
        if (remoteProcessGroup == null) {
            validationErrors.add("Unable to find the specified remote process group.");
            return validationErrors;
        }

        // ensure the new destination was found
        final RemoteGroupPort remoteInputPort = remoteProcessGroup.getInputPort(proposedDestination.getId());
        if (remoteInputPort == null) {
            validationErrors.add("Unable to find the specified destination.");
            return validationErrors;
        }
    }

    return validationErrors;
}
 
Example 8
Source File: StandardConnectionDAO.java    From nifi with Apache License 2.0 4 votes vote down vote up
/**
 * Validates the proposed processor configuration.
 */
private List<String> validateProposedConfiguration(final String groupId, final ConnectionDTO connectionDTO) {
    List<String> validationErrors = new ArrayList<>();

    if (isNotNull(connectionDTO.getBackPressureObjectThreshold()) && connectionDTO.getBackPressureObjectThreshold() < 0) {
        validationErrors.add("Max queue size must be a non-negative integer");
    }
    if (isNotNull(connectionDTO.getFlowFileExpiration())) {
        Matcher expirationMatcher = FormatUtils.TIME_DURATION_PATTERN.matcher(connectionDTO.getFlowFileExpiration());
        if (!expirationMatcher.matches()) {
            validationErrors.add("Flow file expiration is not a valid time duration (ie 30 sec, 5 min)");
        }
    }
    if (isNotNull(connectionDTO.getLabelIndex())) {
        if (connectionDTO.getLabelIndex() < 0) {
            validationErrors.add("The label index must be positive.");
        }
    }

    // validation is required when connecting to a remote process group since each node in a
    // cluster may or may not be authorized
    final ConnectableDTO proposedDestination = connectionDTO.getDestination();
    if (proposedDestination != null && ConnectableType.REMOTE_INPUT_PORT.name().equals(proposedDestination.getType())) {
        // the group id must be specified
        if (proposedDestination.getGroupId() == null) {
            validationErrors.add("When the destination is a remote input port its group id is required.");
            return validationErrors;
        }

        // attempt to location the proprosed destination
        final ProcessGroup destinationParentGroup = locateProcessGroup(flowController, groupId);
        final RemoteProcessGroup remoteProcessGroup = destinationParentGroup.getRemoteProcessGroup(proposedDestination.getGroupId());
        if (remoteProcessGroup == null) {
            validationErrors.add("Unable to find the specified remote process group.");
            return validationErrors;
        }

        // ensure the new destination was found
        final RemoteGroupPort remoteInputPort = remoteProcessGroup.getInputPort(proposedDestination.getId());
        if (remoteInputPort == null) {
            validationErrors.add("Unable to find the specified destination.");
            return validationErrors;
        }
    }

    return validationErrors;
}