Search in sources :

Example 46 with ProcessGroup

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;
}
Also used : HashMap(java.util.HashMap) ProcessGroup(org.apache.nifi.groups.ProcessGroup) VersionedProcessGroup(org.apache.nifi.registry.flow.VersionedProcessGroup) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) ResourceNotFoundException(org.apache.nifi.web.ResourceNotFoundException)

Example 47 with ProcessGroup

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;
}
Also used : StandardVersionControlInformation(org.apache.nifi.registry.flow.StandardVersionControlInformation) FlowRegistry(org.apache.nifi.registry.flow.FlowRegistry) NiFiRegistryFlowMapper(org.apache.nifi.registry.flow.mapping.NiFiRegistryFlowMapper) ProcessGroup(org.apache.nifi.groups.ProcessGroup) VersionedProcessGroup(org.apache.nifi.registry.flow.VersionedProcessGroup) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) VersionedProcessGroup(org.apache.nifi.registry.flow.VersionedProcessGroup)

Example 48 with ProcessGroup

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;
}
Also used : RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) StandardVersionControlInformation(org.apache.nifi.registry.flow.StandardVersionControlInformation) ProcessGroup(org.apache.nifi.groups.ProcessGroup) VersionedProcessGroup(org.apache.nifi.registry.flow.VersionedProcessGroup) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup)

Example 49 with ProcessGroup

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;
}
Also used : Connectable(org.apache.nifi.connectable.Connectable) RemoteGroupPort(org.apache.nifi.remote.RemoteGroupPort) ProcessGroup(org.apache.nifi.groups.ProcessGroup) VersionedProcessGroup(org.apache.nifi.registry.flow.VersionedProcessGroup) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup)

Example 50 with ProcessGroup

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;
}
Also used : Position(org.apache.nifi.connectable.Position) ProcessGroup(org.apache.nifi.groups.ProcessGroup) VersionedProcessGroup(org.apache.nifi.registry.flow.VersionedProcessGroup) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup)

Aggregations

ProcessGroup (org.apache.nifi.groups.ProcessGroup)185 RemoteProcessGroup (org.apache.nifi.groups.RemoteProcessGroup)97 VersionedProcessGroup (org.apache.nifi.registry.flow.VersionedProcessGroup)68 ProcessorNode (org.apache.nifi.controller.ProcessorNode)50 Port (org.apache.nifi.connectable.Port)40 RootGroupPort (org.apache.nifi.remote.RootGroupPort)37 Connection (org.apache.nifi.connectable.Connection)36 ArrayList (java.util.ArrayList)35 InstantiatedVersionedProcessGroup (org.apache.nifi.registry.flow.mapping.InstantiatedVersionedProcessGroup)35 Test (org.junit.Test)35 RemoteGroupPort (org.apache.nifi.remote.RemoteGroupPort)34 HashSet (java.util.HashSet)32 ControllerServiceNode (org.apache.nifi.controller.service.ControllerServiceNode)32 ResourceNotFoundException (org.apache.nifi.web.ResourceNotFoundException)29 FlowController (org.apache.nifi.controller.FlowController)27 Connectable (org.apache.nifi.connectable.Connectable)26 VersionControlInformation (org.apache.nifi.registry.flow.VersionControlInformation)25 Funnel (org.apache.nifi.connectable.Funnel)24 List (java.util.List)22 Label (org.apache.nifi.controller.label.Label)22