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;
}
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;
}
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;
}
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;
}
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);
}
Aggregations