NIFI-4436: Fixed bug that caused a Process Group to be 'dirty' if a processor 
that was referencing a non-existent controller service is updated to reference 
an externally available controller service

Signed-off-by: Matt Gilman <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/f702f808
Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/f702f808
Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/f702f808

Branch: refs/heads/master
Commit: f702f808a70929980f862ef62c2359b73f5e6b6b
Parents: b3e1584
Author: Mark Payne <[email protected]>
Authored: Wed Jan 3 15:29:39 2018 -0500
Committer: Bryan Bende <[email protected]>
Committed: Mon Jan 8 12:44:57 2018 -0500

----------------------------------------------------------------------
 .../nifi/controller/StandardFlowSynchronizer.java       |  2 +-
 .../org/apache/nifi/groups/StandardProcessGroup.java    | 12 +++++++++++-
 .../org/apache/nifi/web/StandardNiFiServiceFacade.java  | 12 +++++++++++-
 3 files changed, 23 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi/blob/f702f808/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowSynchronizer.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowSynchronizer.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowSynchronizer.java
index 9bb3d2f..425110c 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowSynchronizer.java
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowSynchronizer.java
@@ -240,7 +240,7 @@ public class StandardFlowSynchronizer implements 
FlowSynchronizer {
                     existingFlowEmpty = taskElements.isEmpty()
                         && unrootedControllerServiceElements.isEmpty()
                         && isEmpty(rootGroupDto)
-                        && registriesPresent;
+                        && !registriesPresent;
                     logger.debug("Existing Flow Empty = {}", 
existingFlowEmpty);
                 }
             }

http://git-wip-us.apache.org/repos/asf/nifi/blob/f702f808/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java
index 870804d..9418f40 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java
@@ -3316,7 +3316,17 @@ public final class StandardProcessGroup implements 
ProcessGroup {
             ancestorServiceIds = Collections.emptySet();
         } else {
             ancestorServiceIds = 
parentGroup.getControllerServices(true).stream()
-                .map(ControllerServiceNode::getIdentifier)
+                .map(cs -> {
+                    // We want to map the Controller Service to its Versioned 
Component ID, if it has one.
+                    // If it does not have one, we want to generate it in the 
same way that our Flow Mapper does
+                    // because this allows us to find the Controller Service 
when doing a Flow Diff.
+                    final Optional<String> versionedId = 
cs.getVersionedComponentId();
+                    if (versionedId.isPresent()) {
+                        return versionedId.get();
+                    }
+
+                    return 
UUID.nameUUIDFromBytes(cs.getIdentifier().getBytes(StandardCharsets.UTF_8)).toString();
+                })
                 .collect(Collectors.toSet());
         }
 

http://git-wip-us.apache.org/repos/asf/nifi/blob/f702f808/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java
index b7559ec..1ccced2 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java
@@ -3824,7 +3824,17 @@ public class StandardNiFiServiceFacade implements 
NiFiServiceFacade {
             ancestorServiceIds = Collections.emptySet();
         } else {
             ancestorServiceIds = 
parentGroup.getControllerServices(true).stream()
-                .map(ControllerServiceNode::getIdentifier)
+                .map(cs -> {
+                    // We want to map the Controller Service to its Versioned 
Component ID, if it has one.
+                    // If it does not have one, we want to generate it in the 
same way that our Flow Mapper does
+                    // because this allows us to find the Controller Service 
when doing a Flow Diff.
+                    final Optional<String> versionedId = 
cs.getVersionedComponentId();
+                    if (versionedId.isPresent()) {
+                        return versionedId.get();
+                    }
+
+                    return 
UUID.nameUUIDFromBytes(cs.getIdentifier().getBytes(StandardCharsets.UTF_8)).toString();
+                })
                 .collect(Collectors.toSet());
         }
 

Reply via email to