You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by sc...@apache.org on 2017/05/02 13:44:49 UTC

nifi git commit: NIFI-3762: - Addressing issue when enabling/disabling controller services when referencing services are not in scope. - Fixing enabled/disabled icons for referencing services. - Rendering when a reference cycle is detected.

Repository: nifi
Updated Branches:
  refs/heads/master 3bfe323a5 -> 82829927a


NIFI-3762:
- Addressing issue when enabling/disabling controller services when referencing services are not in scope.
- Fixing enabled/disabled icons for referencing services.
- Rendering when a reference cycle is detected.

Signed-off-by: Scott Aslan <sc...@gmail.com>

This closes #1725


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

Branch: refs/heads/master
Commit: 82829927aed904434c18cb55d589209a9aa02a46
Parents: 3bfe323
Author: Matt Gilman <ma...@gmail.com>
Authored: Mon May 1 15:32:46 2017 -0400
Committer: Scott Aslan <sc...@gmail.com>
Committed: Tue May 2 09:43:54 2017 -0400

----------------------------------------------------------------------
 .../nifi/web/StandardNiFiServiceFacade.java     | 12 +--
 .../src/main/webapp/css/common-ui.css           |  4 +-
 .../nifi-web-ui/src/main/webapp/css/main.css    | 10 +++
 .../js/nf/canvas/nf-controller-service.js       | 80 ++++++++++++++------
 4 files changed, 73 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi/blob/82829927/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 b9b208e..dbb2aaf 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
@@ -62,7 +62,6 @@ import org.apache.nifi.connectable.Connection;
 import org.apache.nifi.connectable.Funnel;
 import org.apache.nifi.connectable.Port;
 import org.apache.nifi.controller.ConfiguredComponent;
-import org.apache.nifi.controller.ControllerService;
 import org.apache.nifi.controller.Counter;
 import org.apache.nifi.controller.FlowController;
 import org.apache.nifi.controller.ProcessorNode;
@@ -85,7 +84,6 @@ import org.apache.nifi.groups.RemoteProcessGroup;
 import org.apache.nifi.history.History;
 import org.apache.nifi.history.HistoryQuery;
 import org.apache.nifi.history.PreviousValue;
-import org.apache.nifi.processor.Processor;
 import org.apache.nifi.remote.RootGroupPort;
 import org.apache.nifi.reporting.Bulletin;
 import org.apache.nifi.reporting.BulletinQuery;
@@ -1981,7 +1979,9 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
      */
     private ControllerServiceReferencingComponentsEntity createControllerServiceReferencingComponentsEntity(
             final ControllerServiceReference reference, final Map<String, Revision> revisions) {
-        return createControllerServiceReferencingComponentsEntity(reference, revisions, new HashSet<>());
+        final Set<ControllerServiceNode> visited = new HashSet<>();
+        visited.add(reference.getReferencedComponent());
+        return createControllerServiceReferencingComponentsEntity(reference, revisions, visited);
     }
 
     /**
@@ -2016,6 +2016,9 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
                 // indicate if we've hit a cycle
                 dto.setReferenceCycle(visited.contains(node));
 
+                // mark node as visited before building the reference cycle
+                visited.add(node);
+
                 // if we haven't encountered this service before include it's referencing components
                 if (!dto.getReferenceCycle()) {
                     final ControllerServiceReference refReferences = node.getReferences();
@@ -2026,9 +2029,6 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
                     final ControllerServiceReferencingComponentsEntity references = createControllerServiceReferencingComponentsEntity(refReferences, referencingRevisions, visited);
                     dto.setReferencingComponents(references.getControllerServiceReferencingComponents());
                 }
-
-                // mark node as visited
-                visited.add(node);
             }
 
             componentEntities.add(entityFactory.createControllerServiceReferencingComponentEntity(dto, revisionDto, permissions));

http://git-wip-us.apache.org/repos/asf/nifi/blob/82829927/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/common-ui.css
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/common-ui.css b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/common-ui.css
index 6810e52..627802a 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/common-ui.css
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/common-ui.css
@@ -285,9 +285,9 @@ div.ajax-complete:before {
 
 div.ajax-error:before {
     font-family: FontAwesome;
-    content: "\f1f8";
+    content: "\f00d";
     font-size: 16px;
-    color: #004849;
+    color: #D18686;
 }
 
 .refresh-button {

http://git-wip-us.apache.org/repos/asf/nifi/blob/82829927/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/main.css
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/main.css b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/main.css
index 1554356..94dae84 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/main.css
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/main.css
@@ -91,6 +91,11 @@ div.context-menu-provenance {
     text-shadow: 0 0 4px rgba(255,255,255,1);
 }
 
+.disabled:before {
+    content: '\e802';
+    font-family: flowfont;
+}
+
 .enabled {
     float: left;
     color: #44a3cf !important;
@@ -100,6 +105,11 @@ div.context-menu-provenance {
     text-shadow: 0 0 4px rgba(255,255,255,1);
 }
 
+.enabled:before {
+    content: '\f0e7';
+    font-family: FontAwesome;
+}
+
 .stopped {
     float: left;
     color: #d18686 !important;

http://git-wip-us.apache.org/repos/asf/nifi/blob/82829927/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js
index 0274e46..52ba4f1 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js
@@ -507,13 +507,19 @@
                     var referencingServiceReferencesContainer = $('<div class="referencing-component-references hidden"></div>');
                     var serviceTwist = $('<div class="service expansion-button collapsed pointer"></div>').on('click', function () {
                         if (serviceTwist.hasClass('collapsed')) {
-                            var controllerServiceGrid = serviceTable.data('gridInstance');
-                            var controllerServiceData = controllerServiceGrid.getData();
-                            var referencingServiceEntity = controllerServiceData.getItemById(referencingComponent.id);
-                            var referencingService = referencingServiceEntity.component;
-
                             // create the markup for the references
-                            createReferencingComponents(serviceTable, referencingServiceReferencesContainer, referencingService.referencingComponents);
+                            if (referencingComponent.referenceCycle === true) {
+                                referencingServiceReferencesContainer.append('<div class="unset">Reference cycle detected.</div>');
+                            } else {
+                                var controllerServiceGrid = serviceTable.data('gridInstance');
+                                var controllerServiceData = controllerServiceGrid.getData();
+
+                                // get the controller service and expand its referencing services
+                                getControllerService(referencingComponent.id, controllerServiceData).done(function (controllerServiceEntity) {
+                                    var cs = controllerServiceEntity.component;
+                                    createReferencingComponents(serviceTable, referencingServiceReferencesContainer, cs.referencingComponents);
+                                });
+                            }
                         } else {
                             referencingServiceReferencesContainer.empty();
                         }
@@ -783,7 +789,7 @@
 
         // Note: updated revisions will be retrieved after updateReferencingSchedulableComponents is invoked
 
-        // wait unil the polling of each service finished
+        // wait until the polling of each service finished
         return $.Deferred(function (deferred) {
             updated.done(function (response) {
                 // update the controller service
@@ -803,8 +809,9 @@
                     // start polling for each controller service
                     var polling = [];
                     services.forEach(function (controllerServiceId) {
-                        var referencingService = controllerServiceData.getItemById(controllerServiceId);
-                        polling.push(stopReferencingSchedulableComponents(referencingService, pollCondition));
+                        getControllerService(controllerServiceId, controllerServiceData).done(function(controllerServiceEntity) {
+                            polling.push(stopReferencingSchedulableComponents(controllerServiceEntity, pollCondition));
+                        });
                     });
 
                     // wait until polling has finished
@@ -821,6 +828,29 @@
     };
 
     /**
+     * Gets the controller service with the specified id. If the service is present in the specified
+     * controllerServiceData it will be used. Otherwise it will query for it.
+     *
+     * @param controllerServiceId   service id
+     * @param controllerServiceData service table data
+     * @returns {deferred} the controller service entity
+     */
+    var getControllerService = function (controllerServiceId, controllerServiceData) {
+        var controllerServiceEntity = controllerServiceData.getItemById(controllerServiceId);
+        if (nfCommon.isDefinedAndNotNull(controllerServiceEntity)) {
+            return $.Deferred(function (deferred) {
+                deferred.resolve(controllerServiceEntity);
+            });
+        } else {
+            return $.ajax({
+                type: 'GET',
+                url: '../nifi-api/controller-services/' + encodeURIComponent(controllerServiceId),
+                dataType: 'json'
+            }).fail(nfErrorHandler.handleAjaxError);
+        }
+    };
+
+    /**
      * Polls the specified services referencing components to see if the
      * specified condition is satisfied.
      *
@@ -890,12 +920,12 @@
      * Continues to poll the specified controller service until all referencing schedulable
      * components are stopped (not scheduled and 0 active threads).
      *
-     * @param {object} controllerService
+     * @param {object} controllerServiceEntity
      * @param {function} pollCondition
      */
-    var stopReferencingSchedulableComponents = function (controllerService, pollCondition) {
+    var stopReferencingSchedulableComponents = function (controllerServiceEntity, pollCondition) {
         // continue to poll the service until all schedulable components have stopped
-        return pollService(controllerService, function (service, bulletins) {
+        return pollService(controllerServiceEntity, function (service, bulletins) {
             var referencingComponents = service.referencingComponents;
 
             var stillRunning = false;
@@ -938,12 +968,12 @@
     /**
      * Continues to poll until all referencing services are enabled.
      *
-     * @param {object} controllerService
+     * @param {object} controllerServiceEntity
      * @param {function} pollCondition
      */
-    var enableReferencingServices = function (controllerService, pollCondition) {
+    var enableReferencingServices = function (controllerServiceEntity, pollCondition) {
         // continue to poll the service until all referencing services are enabled
-        return pollService(controllerService, function (service, bulletins) {
+        return pollService(controllerServiceEntity, function (service, bulletins) {
             var referencingComponents = service.referencingComponents;
 
             var notEnabled = false;
@@ -983,12 +1013,12 @@
     /**
      * Continues to poll until all referencing services are disabled.
      *
-     * @param {object} controllerService
+     * @param {object} controllerServiceEntity
      * @param {function} pollCondition
      */
-    var disableReferencingServices = function (controllerService, pollCondition) {
+    var disableReferencingServices = function (controllerServiceEntity, pollCondition) {
         // continue to poll the service until all referencing services are disabled
-        return pollService(controllerService, function (service, bulletins) {
+        return pollService(controllerServiceEntity, function (service, bulletins) {
             var referencingComponents = service.referencingComponents;
 
             var notDisabled = false;
@@ -1071,13 +1101,13 @@
                 // start polling for each controller service
                 var polling = [];
                 services.forEach(function (controllerServiceId) {
-                    var referencingService = controllerServiceData.getItemById(controllerServiceId);
-
-                    if (enabled) {
-                        polling.push(enableReferencingServices(referencingService, pollCondition));
-                    } else {
-                        polling.push(disableReferencingServices(referencingService, pollCondition));
-                    }
+                    getControllerService(controllerServiceId, controllerServiceData).done(function(controllerServiceEntity) {
+                        if (enabled) {
+                            polling.push(enableReferencingServices(controllerServiceEntity, pollCondition));
+                        } else {
+                            polling.push(disableReferencingServices(controllerServiceEntity, pollCondition));
+                        }
+                    });
                 });
 
                 $.when.apply(window, polling).done(function () {