Search in sources :

Example 61 with RemoteProcessGroup

use of org.apache.nifi.groups.RemoteProcessGroup in project nifi by apache.

the class StandardRemoteProcessGroupDAO method createRemoteProcessGroup.

/**
 * Creates a remote process group reference.
 *
 * @param remoteProcessGroupDTO The remote process group
 * @return The remote process group
 */
@Override
public RemoteProcessGroup createRemoteProcessGroup(String groupId, RemoteProcessGroupDTO remoteProcessGroupDTO) {
    ProcessGroup group = locateProcessGroup(flowController, groupId);
    if (remoteProcessGroupDTO.getParentGroupId() != null && !flowController.areGroupsSame(groupId, remoteProcessGroupDTO.getParentGroupId())) {
        throw new IllegalArgumentException("Cannot specify a different Parent Group ID than the Group to which the Remote Process Group is being added.");
    }
    final String targetUris = remoteProcessGroupDTO.getTargetUris();
    if (targetUris == null || targetUris.length() == 0) {
        throw new IllegalArgumentException("Cannot add a Remote Process Group without specifying the Target URI(s)");
    }
    // create the remote process group
    RemoteProcessGroup remoteProcessGroup = flowController.createRemoteProcessGroup(remoteProcessGroupDTO.getId(), targetUris);
    remoteProcessGroup.initialize();
    // set other properties
    updateRemoteProcessGroup(remoteProcessGroup, remoteProcessGroupDTO);
    // get the group to add the remote process group to
    group.addRemoteProcessGroup(remoteProcessGroup);
    return remoteProcessGroup;
}
Also used : RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) ProcessGroup(org.apache.nifi.groups.ProcessGroup) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup)

Example 62 with RemoteProcessGroup

use of org.apache.nifi.groups.RemoteProcessGroup in project nifi by apache.

the class StandardRemoteProcessGroupDAO method updateRemoteProcessGroupOutputPort.

@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
    updatePort(port, remoteProcessGroupPortDto, remoteProcessGroup);
    remoteProcessGroup.getProcessGroup().onComponentModified();
    return port;
}
Also used : RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) RemoteGroupPort(org.apache.nifi.remote.RemoteGroupPort) ResourceNotFoundException(org.apache.nifi.web.ResourceNotFoundException)

Example 63 with RemoteProcessGroup

use of org.apache.nifi.groups.RemoteProcessGroup in project nifi by apache.

the class StandardRemoteProcessGroupDAO method updateRemoteProcessGroup.

private RemoteProcessGroup updateRemoteProcessGroup(RemoteProcessGroup remoteProcessGroup, RemoteProcessGroupDTO remoteProcessGroupDTO) {
    // verify the update request
    verifyUpdate(remoteProcessGroup, remoteProcessGroupDTO);
    // configure the remote process group
    final String targetUris = remoteProcessGroupDTO.getTargetUris();
    final String name = remoteProcessGroupDTO.getName();
    final String comments = remoteProcessGroupDTO.getComments();
    final String communicationsTimeout = remoteProcessGroupDTO.getCommunicationsTimeout();
    final String yieldDuration = remoteProcessGroupDTO.getYieldDuration();
    final String proxyHost = remoteProcessGroupDTO.getProxyHost();
    final Integer proxyPort = remoteProcessGroupDTO.getProxyPort();
    final String proxyUser = remoteProcessGroupDTO.getProxyUser();
    final String proxyPassword = remoteProcessGroupDTO.getProxyPassword();
    final String transportProtocol = remoteProcessGroupDTO.getTransportProtocol();
    final String localNetworkInterface = remoteProcessGroupDTO.getLocalNetworkInterface();
    if (isNotNull(targetUris)) {
        remoteProcessGroup.setTargetUris(targetUris);
    }
    if (isNotNull(name)) {
        remoteProcessGroup.setName(name);
    }
    if (isNotNull(comments)) {
        remoteProcessGroup.setComments(comments);
    }
    if (isNotNull(communicationsTimeout)) {
        remoteProcessGroup.setCommunicationsTimeout(communicationsTimeout);
    }
    if (isNotNull(yieldDuration)) {
        remoteProcessGroup.setYieldDuration(yieldDuration);
    }
    if (isNotNull(remoteProcessGroupDTO.getPosition())) {
        remoteProcessGroup.setPosition(new Position(remoteProcessGroupDTO.getPosition().getX(), remoteProcessGroupDTO.getPosition().getY()));
    }
    if (isNotNull(transportProtocol)) {
        remoteProcessGroup.setTransportProtocol(SiteToSiteTransportProtocol.valueOf(transportProtocol.toUpperCase()));
        // No null check because these proxy settings have to be clear if not specified.
        // But when user Enable/Disable transmission, only isTransmitting is sent.
        // To prevent clearing these values in that case, set these only if transportProtocol is sent,
        // assuming UI sends transportProtocol always for update.
        remoteProcessGroup.setProxyHost(proxyHost);
        remoteProcessGroup.setProxyPort(proxyPort);
        remoteProcessGroup.setProxyUser(proxyUser);
        // specify empty String to clear password.
        if (isNotNull(proxyPassword) && !DtoFactory.SENSITIVE_VALUE_MASK.equals(proxyPassword)) {
            remoteProcessGroup.setProxyPassword(proxyPassword);
        }
    }
    if (localNetworkInterface != null) {
        if (StringUtils.isBlank(localNetworkInterface)) {
            remoteProcessGroup.setNetworkInterface(null);
        } else {
            remoteProcessGroup.setNetworkInterface(localNetworkInterface);
        }
    }
    final Boolean isTransmitting = remoteProcessGroupDTO.isTransmitting();
    if (isNotNull(isTransmitting)) {
        // start or stop as necessary
        if (!remoteProcessGroup.isTransmitting() && isTransmitting) {
            remoteProcessGroup.startTransmitting();
        } else if (remoteProcessGroup.isTransmitting() && !isTransmitting) {
            remoteProcessGroup.stopTransmitting();
        }
    }
    final ProcessGroup group = remoteProcessGroup.getProcessGroup();
    if (group != null) {
        group.onComponentModified();
    }
    return remoteProcessGroup;
}
Also used : Position(org.apache.nifi.connectable.Position) ProcessGroup(org.apache.nifi.groups.ProcessGroup) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup)

Example 64 with RemoteProcessGroup

use of org.apache.nifi.groups.RemoteProcessGroup in project nifi by apache.

the class StandardRemoteProcessGroupDAO method getRemoteProcessGroups.

/**
 * Gets all of the remote process groups.
 *
 * @return The remote process groups
 */
@Override
public Set<RemoteProcessGroup> getRemoteProcessGroups(String groupId) {
    final ProcessGroup group = locateProcessGroup(flowController, groupId);
    final Set<RemoteProcessGroup> remoteProcessGroups = group.getRemoteProcessGroups();
    return remoteProcessGroups;
}
Also used : RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) ProcessGroup(org.apache.nifi.groups.ProcessGroup) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup)

Example 65 with RemoteProcessGroup

use of org.apache.nifi.groups.RemoteProcessGroup in project nifi by apache.

the class StandardRemoteProcessGroupDAO method verifyUpdateOutputPort.

@Override
public void verifyUpdateOutputPort(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'.", remoteProcessGroupPortDto.getId()));
    }
    verifyUpdatePort(port, remoteProcessGroupPortDto);
}
Also used : RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) RemoteGroupPort(org.apache.nifi.remote.RemoteGroupPort) ResourceNotFoundException(org.apache.nifi.web.ResourceNotFoundException)

Aggregations

RemoteProcessGroup (org.apache.nifi.groups.RemoteProcessGroup)74 ProcessGroup (org.apache.nifi.groups.ProcessGroup)32 RemoteGroupPort (org.apache.nifi.remote.RemoteGroupPort)31 Action (org.apache.nifi.action.Action)27 RemoteProcessGroupDTO (org.apache.nifi.web.api.dto.RemoteProcessGroupDTO)26 ArrayList (java.util.ArrayList)20 Connection (org.apache.nifi.connectable.Connection)20 Port (org.apache.nifi.connectable.Port)19 Test (org.junit.Test)18 HashSet (java.util.HashSet)16 RootGroupPort (org.apache.nifi.remote.RootGroupPort)16 Funnel (org.apache.nifi.connectable.Funnel)15 Connectable (org.apache.nifi.connectable.Connectable)14 ProcessorNode (org.apache.nifi.controller.ProcessorNode)14 Label (org.apache.nifi.controller.label.Label)13 ControllerServiceNode (org.apache.nifi.controller.service.ControllerServiceNode)13 Collection (java.util.Collection)11 HashMap (java.util.HashMap)10 Snippet (org.apache.nifi.controller.Snippet)10 ProcessGroupStatus (org.apache.nifi.controller.status.ProcessGroupStatus)10