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