Search in sources :

Example 86 with ControllerServiceNode

use of org.apache.nifi.controller.service.ControllerServiceNode in project nifi by apache.

the class StandardControllerServiceDAO method getControllerServices.

@Override
public Set<ControllerServiceNode> getControllerServices(final String groupId, final boolean includeAncestorGroups, final boolean includeDescendantGroups) {
    if (groupId == null) {
        return flowController.getRootControllerServices();
    } else {
        final String searchId = groupId.equals(ROOT_GROUP_ID_ALIAS) ? flowController.getRootGroupId() : groupId;
        final ProcessGroup procGroup = flowController.getGroup(flowController.getRootGroupId()).findProcessGroup(searchId);
        if (procGroup == null) {
            throw new ResourceNotFoundException("Could not find Process Group with ID " + groupId);
        }
        final Set<ControllerServiceNode> serviceNodes = procGroup.getControllerServices(includeAncestorGroups);
        if (includeDescendantGroups) {
            serviceNodes.addAll(procGroup.findAllControllerServices());
        }
        return serviceNodes;
    }
}
Also used : ControllerServiceNode(org.apache.nifi.controller.service.ControllerServiceNode) ProcessGroup(org.apache.nifi.groups.ProcessGroup) ResourceNotFoundException(org.apache.nifi.web.ResourceNotFoundException)

Example 87 with ControllerServiceNode

use of org.apache.nifi.controller.service.ControllerServiceNode in project nifi by apache.

the class LocalComponentLifecycle method determineEnablingOrder.

private static void determineEnablingOrder(final Map<String, ControllerServiceNode> serviceNodeMap, final ControllerServiceNode contextNode, final List<ControllerServiceNode> orderedNodes, final Set<ControllerServiceNode> visited) {
    if (visited.contains(contextNode)) {
        return;
    }
    for (final Map.Entry<PropertyDescriptor, String> entry : contextNode.getProperties().entrySet()) {
        if (entry.getKey().getControllerServiceDefinition() != null) {
            final String referencedServiceId = entry.getValue();
            if (referencedServiceId != null) {
                final ControllerServiceNode referencedNode = serviceNodeMap.get(referencedServiceId);
                if (!orderedNodes.contains(referencedNode)) {
                    visited.add(contextNode);
                    determineEnablingOrder(serviceNodeMap, referencedNode, orderedNodes, visited);
                }
            }
        }
    }
    if (!orderedNodes.contains(contextNode)) {
        orderedNodes.add(contextNode);
    }
}
Also used : PropertyDescriptor(org.apache.nifi.components.PropertyDescriptor) ControllerServiceNode(org.apache.nifi.controller.service.ControllerServiceNode) Map(java.util.Map)

Example 88 with ControllerServiceNode

use of org.apache.nifi.controller.service.ControllerServiceNode in project nifi by apache.

the class SnippetUtils method getControllerServices.

private Set<ControllerServiceDTO> getControllerServices(final Map<PropertyDescriptor, String> componentProperties) {
    final Set<ControllerServiceDTO> serviceDtos = new HashSet<>();
    for (final Map.Entry<PropertyDescriptor, String> entry : componentProperties.entrySet()) {
        final PropertyDescriptor descriptor = entry.getKey();
        if (descriptor.getControllerServiceDefinition() != null) {
            final String controllerServiceId = entry.getValue();
            if (controllerServiceId != null) {
                final ControllerServiceNode serviceNode = flowController.getControllerServiceNode(controllerServiceId);
                if (serviceNode != null) {
                    serviceDtos.add(dtoFactory.createControllerServiceDto(serviceNode));
                    final Set<ControllerServiceDTO> recursiveRefs = getControllerServices(serviceNode.getProperties());
                    serviceDtos.addAll(recursiveRefs);
                }
            }
        }
    }
    return serviceDtos;
}
Also used : ControllerServiceDTO(org.apache.nifi.web.api.dto.ControllerServiceDTO) PropertyDescriptor(org.apache.nifi.components.PropertyDescriptor) ControllerServiceNode(org.apache.nifi.controller.service.ControllerServiceNode) Map(java.util.Map) HashMap(java.util.HashMap) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Aggregations

ControllerServiceNode (org.apache.nifi.controller.service.ControllerServiceNode)88 HashSet (java.util.HashSet)29 ProcessGroup (org.apache.nifi.groups.ProcessGroup)26 HashMap (java.util.HashMap)25 PropertyDescriptor (org.apache.nifi.components.PropertyDescriptor)25 ArrayList (java.util.ArrayList)24 Map (java.util.Map)24 LinkedHashSet (java.util.LinkedHashSet)22 Test (org.junit.Test)19 BundleCoordinate (org.apache.nifi.bundle.BundleCoordinate)18 ProcessorNode (org.apache.nifi.controller.ProcessorNode)18 ConfiguredComponent (org.apache.nifi.controller.ConfiguredComponent)17 VersionedProcessGroup (org.apache.nifi.registry.flow.VersionedProcessGroup)17 Set (java.util.Set)16 Connection (org.apache.nifi.connectable.Connection)16 List (java.util.List)15 Port (org.apache.nifi.connectable.Port)15 Label (org.apache.nifi.controller.label.Label)15 RemoteProcessGroup (org.apache.nifi.groups.RemoteProcessGroup)15 RemoteGroupPort (org.apache.nifi.remote.RemoteGroupPort)15