Java Code Examples for org.apache.nifi.web.api.dto.RemoteProcessGroupPortDTO#isTransmitting()

The following examples show how to use org.apache.nifi.web.api.dto.RemoteProcessGroupPortDTO#isTransmitting() . 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 localization_nifi with Apache License 2.0 6 votes vote down vote up
/**
 * Verified the specified remote port can be updated, if necessary.
 */
private void verifyUpdatePort(RemoteGroupPort port, RemoteProcessGroupPortDTO remoteProcessGroupPortDto) {
    // see if the remote process group can start/stop transmitting
    if (isNotNull(remoteProcessGroupPortDto.isTransmitting())) {
        if (!port.isRunning() && remoteProcessGroupPortDto.isTransmitting()) {
            port.verifyCanStart();
        } else if (port.isRunning() && !remoteProcessGroupPortDto.isTransmitting()) {
            port.verifyCanStop();
        }
    }

    // validate the proposed configuration
    final List<String> requestValidation = validateProposedRemoteProcessGroupPortConfiguration(port, remoteProcessGroupPortDto);
    // ensure there was no validation errors
    if (!requestValidation.isEmpty()) {
        throw new ValidationException(requestValidation);
    }


    // verify update when appropriate
    if (isAnyNotNull(remoteProcessGroupPortDto.getConcurrentlySchedulableTaskCount(), remoteProcessGroupPortDto.getUseCompression())) {
        port.verifyCanUpdate();
    }
}
 
Example 2
Source File: StandardRemoteProcessGroupDAO.java    From nifi with Apache License 2.0 6 votes vote down vote up
/**
 * Verified the specified remote port can be updated, if necessary.
 */
private void verifyUpdatePort(RemoteGroupPort port, RemoteProcessGroupPortDTO remoteProcessGroupPortDto) {
    // see if the remote process group can start/stop transmitting
    if (isNotNull(remoteProcessGroupPortDto.isTransmitting())) {
        if (!port.isRunning() && remoteProcessGroupPortDto.isTransmitting()) {
            port.verifyCanStart();
        } else if (port.isRunning() && !remoteProcessGroupPortDto.isTransmitting()) {
            port.verifyCanStop();
        }
    }

    // validate the proposed configuration
    final List<String> requestValidation = validateProposedRemoteProcessGroupPortConfiguration(port, remoteProcessGroupPortDto);
    // ensure there was no validation errors
    if (!requestValidation.isEmpty()) {
        throw new ValidationException(requestValidation);
    }


    // verify update when appropriate
    if (isAnyNotNull(remoteProcessGroupPortDto.getConcurrentlySchedulableTaskCount(),
            remoteProcessGroupPortDto.getUseCompression(),
            remoteProcessGroupPortDto.getBatchSettings())) {
        port.verifyCanUpdate();
    }
}
 
Example 3
Source File: StandardRemoteProcessGroupDAO.java    From nifi with Apache License 2.0 6 votes vote down vote up
/**
 *
 * @param port Port instance to be updated.
 * @param remoteProcessGroupPortDto DTO containing updated remote process group port settings.
 * @param remoteProcessGroup If remoteProcessGroupPortDto has updated isTransmitting input,
 *                           this method will start or stop the port in this remoteProcessGroup as necessary.
 */
private void updatePort(RemoteGroupPort port, RemoteProcessGroupPortDTO remoteProcessGroupPortDto, RemoteProcessGroup remoteProcessGroup) {
    if (isNotNull(remoteProcessGroupPortDto.getConcurrentlySchedulableTaskCount())) {
        port.setMaxConcurrentTasks(remoteProcessGroupPortDto.getConcurrentlySchedulableTaskCount());
    }
    if (isNotNull(remoteProcessGroupPortDto.getUseCompression())) {
        port.setUseCompression(remoteProcessGroupPortDto.getUseCompression());
    }

    final BatchSettingsDTO batchSettingsDTO = remoteProcessGroupPortDto.getBatchSettings();
    if (isNotNull(batchSettingsDTO)) {
        port.setBatchCount(batchSettingsDTO.getCount());
        port.setBatchSize(batchSettingsDTO.getSize());
        port.setBatchDuration(batchSettingsDTO.getDuration());
    }

    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);
        }
    }
}
 
Example 4
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 5
Source File: StandardRemoteProcessGroupDAO.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@Override
public RemoteGroupPort updateRemoteProcessGroupOutputPort(String remoteProcessGroupId, RemoteProcessGroupPortDTO remoteProcessGroupPortDto) {
    final RemoteProcessGroup remoteProcessGroup = locateRemoteProcessGroup(remoteProcessGroupId);
    final RemoteGroupPort port = remoteProcessGroup.getOutputPort(remoteProcessGroupPortDto.getId());

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

    // 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;
}