use of org.apache.nifi.connectable.Position in project nifi by apache.
the class StandardOutputPortDAO method updatePort.
@Override
public Port updatePort(PortDTO portDTO) {
Port outputPort = locatePort(portDTO.getId());
// ensure we can do this update
verifyUpdate(outputPort, portDTO);
// handle state transition
if (portDTO.getState() != null) {
final ScheduledState purposedScheduledState = ScheduledState.valueOf(portDTO.getState());
// only attempt an action if it is changing
if (!purposedScheduledState.equals(outputPort.getScheduledState())) {
try {
// perform the appropriate action
switch(purposedScheduledState) {
case RUNNING:
outputPort.getProcessGroup().startOutputPort(outputPort);
break;
case STOPPED:
switch(outputPort.getScheduledState()) {
case RUNNING:
outputPort.getProcessGroup().stopOutputPort(outputPort);
break;
case DISABLED:
outputPort.getProcessGroup().enableOutputPort(outputPort);
break;
}
break;
case DISABLED:
outputPort.getProcessGroup().disableOutputPort(outputPort);
break;
}
} catch (IllegalStateException ise) {
throw new NiFiCoreException(ise.getMessage(), ise);
}
}
}
if (outputPort instanceof RootGroupPort) {
final RootGroupPort rootPort = (RootGroupPort) outputPort;
if (isNotNull(portDTO.getGroupAccessControl())) {
rootPort.setGroupAccessControl(portDTO.getGroupAccessControl());
}
if (isNotNull(portDTO.getUserAccessControl())) {
rootPort.setUserAccessControl(portDTO.getUserAccessControl());
}
}
// perform the configuration
final String name = portDTO.getName();
final String comments = portDTO.getComments();
final Integer concurrentTasks = portDTO.getConcurrentlySchedulableTaskCount();
if (isNotNull(portDTO.getPosition())) {
outputPort.setPosition(new Position(portDTO.getPosition().getX(), portDTO.getPosition().getY()));
}
if (isNotNull(name)) {
outputPort.setName(name);
}
if (isNotNull(comments)) {
outputPort.setComments(comments);
}
if (isNotNull(concurrentTasks)) {
outputPort.setMaxConcurrentTasks(concurrentTasks);
}
outputPort.getProcessGroup().onComponentModified();
return outputPort;
}
use of org.apache.nifi.connectable.Position in project nifi by apache.
the class StandardOutputPortDAO method createPort.
@Override
public Port createPort(String groupId, PortDTO portDTO) {
if (isNotNull(portDTO.getParentGroupId()) && !flowController.areGroupsSame(groupId, portDTO.getParentGroupId())) {
throw new IllegalArgumentException("Cannot specify a different Parent Group ID than the Group to which the OutputPort is being added.");
}
// ensure the name has been specified
if (portDTO.getName() == null) {
throw new IllegalArgumentException("Port name must be specified.");
}
// get the desired group
ProcessGroup group = locateProcessGroup(flowController, groupId);
// determine if this is the root group
Port port;
if (group.getParent() == null) {
port = flowController.createRemoteOutputPort(portDTO.getId(), portDTO.getName());
} else {
port = flowController.createLocalOutputPort(portDTO.getId(), portDTO.getName());
}
// ensure we can perform the update before we add the processor to the flow
verifyUpdate(port, portDTO);
// configure
if (portDTO.getPosition() != null) {
port.setPosition(new Position(portDTO.getPosition().getX(), portDTO.getPosition().getY()));
}
port.setComments(portDTO.getComments());
// add the port
group.addOutputPort(port);
return port;
}
use of org.apache.nifi.connectable.Position 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;
}
Aggregations