use of org.apache.nifi.groups.ProcessGroup in project nifi by apache.
the class StandardProcessGroupDAO method updateVariableRegistry.
@Override
public ProcessGroup updateVariableRegistry(final NiFiUser user, final VariableRegistryDTO variableRegistry) {
final ProcessGroup group = locateProcessGroup(flowController, variableRegistry.getProcessGroupId());
if (group == null) {
throw new ResourceNotFoundException("Could not find Process Group with ID " + variableRegistry.getProcessGroupId());
}
final Map<String, String> variableMap = new HashMap<>();
// have to use forEach here instead of using Collectors.toMap because value may be null
variableRegistry.getVariables().stream().map(VariableEntity::getVariable).forEach(var -> variableMap.put(var.getName(), var.getValue()));
group.setVariables(variableMap);
group.onComponentModified();
return group;
}
use of org.apache.nifi.groups.ProcessGroup in project nifi by apache.
the class StandardProcessGroupDAO method updateVersionControlInformation.
@Override
public ProcessGroup updateVersionControlInformation(final VersionControlInformationDTO versionControlInformation, final Map<String, String> versionedComponentMapping) {
final String groupId = versionControlInformation.getGroupId();
final ProcessGroup group = locateProcessGroup(flowController, groupId);
final String registryId = versionControlInformation.getRegistryId();
final FlowRegistry flowRegistry = flowController.getFlowRegistryClient().getFlowRegistry(registryId);
final String registryName = flowRegistry == null ? registryId : flowRegistry.getName();
final NiFiRegistryFlowMapper mapper = new NiFiRegistryFlowMapper();
final VersionedProcessGroup flowSnapshot = mapper.mapProcessGroup(group, flowController, flowController.getFlowRegistryClient(), false);
final StandardVersionControlInformation vci = StandardVersionControlInformation.Builder.fromDto(versionControlInformation).registryName(registryName).flowSnapshot(flowSnapshot).build();
group.setVersionControlInformation(vci, versionedComponentMapping);
group.onComponentModified();
return group;
}
use of org.apache.nifi.groups.ProcessGroup in project nifi by apache.
the class StandardProcessGroupDAO method updateProcessGroupFlow.
@Override
public ProcessGroup updateProcessGroupFlow(final String groupId, final NiFiUser user, final VersionedFlowSnapshot proposedSnapshot, final VersionControlInformationDTO versionControlInformation, final String componentIdSeed, final boolean verifyNotModified, final boolean updateSettings, final boolean updateDescendantVersionedFlows) {
final ProcessGroup group = locateProcessGroup(flowController, groupId);
group.updateFlow(proposedSnapshot, componentIdSeed, verifyNotModified, updateSettings, updateDescendantVersionedFlows);
group.findAllRemoteProcessGroups().stream().forEach(RemoteProcessGroup::initialize);
final StandardVersionControlInformation svci = StandardVersionControlInformation.Builder.fromDto(versionControlInformation).flowSnapshot(proposedSnapshot.getFlowContents()).build();
group.setVersionControlInformation(svci, Collections.emptyMap());
group.onComponentModified();
return group;
}
use of org.apache.nifi.groups.ProcessGroup in project nifi by apache.
the class StandardProcessGroupDAO method scheduleComponents.
@Override
public Future<Void> scheduleComponents(final String groupId, final ScheduledState state, final Set<String> componentIds) {
final ProcessGroup group = locateProcessGroup(flowController, groupId);
CompletableFuture<Void> future = CompletableFuture.completedFuture(null);
for (final String componentId : componentIds) {
final Connectable connectable = group.findLocalConnectable(componentId);
if (ScheduledState.RUNNING.equals(state)) {
switch(connectable.getConnectableType()) {
case PROCESSOR:
final CompletableFuture<?> processorFuture = connectable.getProcessGroup().startProcessor((ProcessorNode) connectable, true);
future = CompletableFuture.allOf(future, processorFuture);
break;
case INPUT_PORT:
connectable.getProcessGroup().startInputPort((Port) connectable);
break;
case OUTPUT_PORT:
connectable.getProcessGroup().startOutputPort((Port) connectable);
break;
case REMOTE_INPUT_PORT:
case REMOTE_OUTPUT_PORT:
final RemoteGroupPort remotePort = group.findRemoteGroupPort(componentId);
remotePort.getRemoteProcessGroup().startTransmitting(remotePort);
break;
}
} else {
switch(connectable.getConnectableType()) {
case PROCESSOR:
final CompletableFuture<?> processorFuture = connectable.getProcessGroup().stopProcessor((ProcessorNode) connectable);
future = CompletableFuture.allOf(future, processorFuture);
break;
case INPUT_PORT:
connectable.getProcessGroup().stopInputPort((Port) connectable);
break;
case OUTPUT_PORT:
connectable.getProcessGroup().stopOutputPort((Port) connectable);
break;
case REMOTE_INPUT_PORT:
case REMOTE_OUTPUT_PORT:
final RemoteGroupPort remotePort = group.findRemoteGroupPort(componentId);
remotePort.getRemoteProcessGroup().stopTransmitting(remotePort);
break;
}
}
}
return future;
}
use of org.apache.nifi.groups.ProcessGroup in project nifi by apache.
the class StandardProcessGroupDAO method createProcessGroup.
@Override
public ProcessGroup createProcessGroup(String parentGroupId, ProcessGroupDTO processGroup) {
if (processGroup.getParentGroupId() != null && !flowController.areGroupsSame(processGroup.getParentGroupId(), parentGroupId)) {
throw new IllegalArgumentException("Cannot specify a different Parent Group ID than the Group to which the Process Group is being added.");
}
// get the parent group
ProcessGroup parentGroup = locateProcessGroup(flowController, parentGroupId);
// create the process group
ProcessGroup group = flowController.createProcessGroup(processGroup.getId());
if (processGroup.getName() != null) {
group.setName(processGroup.getName());
}
if (processGroup.getPosition() != null) {
group.setPosition(new Position(processGroup.getPosition().getX(), processGroup.getPosition().getY()));
}
// add the process group
group.setParent(parentGroup);
parentGroup.addProcessGroup(group);
return group;
}
Aggregations