nifi-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [nifi] markap14 commented on a change in pull request #3553: NIFI-5856: When exporting a flow that references a Controller Service…
Date Mon, 08 Jul 2019 18:16:47 GMT
markap14 commented on a change in pull request #3553: NIFI-5856: When exporting a flow that
references a Controller Service…
URL: https://github.com/apache/nifi/pull/3553#discussion_r301234300
 
 

 ##########
 File path: nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java
 ##########
 @@ -3071,6 +3076,99 @@ public void discoverCompatibleBundles(VersionedProcessGroup versionedGroup)
{
         BundleUtils.discoverCompatibleBundles(controllerFacade.getExtensionManager(), versionedGroup);
     }
 
+    @Override
+    public void resolveInheritedControllerServices(final VersionedFlowSnapshot versionedFlowSnapshot,
final String processGroupId) {
+        final VersionedProcessGroup versionedGroup = versionedFlowSnapshot.getFlowContents();
+        resolveInheritedControllerServices(versionedGroup, processGroupId, versionedFlowSnapshot.getExternalControllerServices());
+    }
+
+    private void resolveInheritedControllerServices(final VersionedProcessGroup versionedGroup,
final String processGroupId,
+                                                    final Map<String, ExternalControllerServiceReference>
externalControllerServiceReferences) {
+        final Set<String> availableControllerServiceIds = findAllControllerServiceIds(versionedGroup);
+        final ProcessGroup parentGroup = processGroupDAO.getProcessGroup(processGroupId);
+        final Set<ControllerServiceNode> serviceNodes = parentGroup.getControllerServices(true);
+
+        for (final VersionedProcessor processor : versionedGroup.getProcessors()) {
+            resolveInheritedControllerServices(processor, availableControllerServiceIds,
serviceNodes, externalControllerServiceReferences);
+        }
+
+        for (final VersionedControllerService service : versionedGroup.getControllerServices())
{
+            resolveInheritedControllerServices(service, availableControllerServiceIds, serviceNodes,
externalControllerServiceReferences);
+        }
+
+        for (final VersionedProcessGroup child : versionedGroup.getProcessGroups()) {
+            resolveInheritedControllerServices(child, processGroupId, externalControllerServiceReferences);
+        }
+    }
+
+
+    private void resolveInheritedControllerServices(final VersionedConfigurableComponent
component, final Set<String> availableControllerServiceIds,
+                                                    final Set<ControllerServiceNode>
availableControllerServices,
+                                                    final Map<String, ExternalControllerServiceReference>
externalControllerServiceReferences) {
+        final Map<String, VersionedPropertyDescriptor> descriptors = component.getPropertyDescriptors();
+        final Map<String, String> properties = component.getProperties();
+
+        resolveInheritedControllerServices(descriptors, properties, availableControllerServiceIds,
availableControllerServices, externalControllerServiceReferences);
+    }
+
+
+    private void resolveInheritedControllerServices(final Map<String, VersionedPropertyDescriptor>
propertyDescriptors, final Map<String, String> componentProperties,
+                                                    final Set<String> availableControllerServiceIds,
final Set<ControllerServiceNode> availableControllerServices,
+                                                    final Map<String, ExternalControllerServiceReference>
externalControllerServiceReferences) {
+
+        for (final Map.Entry<String, String> entry : new HashMap<>(componentProperties).entrySet())
{
+            final String propertyName = entry.getKey();
+            final String propertyValue = entry.getValue();
+
+            final VersionedPropertyDescriptor propertyDescriptor = propertyDescriptors.get(propertyName);
+            if (propertyDescriptor == null) {
+                continue;
+            }
+
+            if (!propertyDescriptor.getIdentifiesControllerService()) {
+                continue;
+            }
+
+            // If the referenced Controller Service is available in this flow, there is nothing
to resolve.
+            if (availableControllerServiceIds.contains(propertyValue)) {
+                continue;
+            }
+
+            final ExternalControllerServiceReference externalServiceReference = externalControllerServiceReferences
== null ? null : externalControllerServiceReferences.get(propertyValue);
+            final String externalControllerServiceName = externalServiceReference == null
? null : externalServiceReference.getName();
+
+            final List<ControllerServiceNode> matchingControllerServices = availableControllerServices.stream()
+                .filter(service -> service.getName().equals(externalControllerServiceName))
 
 Review comment:
   Fair enough.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message