From 4f2607244423df678f39d29bff7e74aadb26073c Mon Sep 17 00:00:00 2001 From: Matt Gilman Date: Thu, 14 Jul 2016 12:43:18 -0400 Subject: [PATCH] NIFI-2261 - Addressed issue enabling/disabling controller services where the wrong URI was referenced. - Addressed with the update revisions in the controller service references. - Addressed issue with showing the disconnected from cluster dialog on page load. - Addressed issue with URI when adding a dynamic property. This closes #654. --- .../org/apache/nifi/web/StandardNiFiServiceFacade.java | 10 ++++++++++ .../src/main/webapp/js/nf/canvas/nf-canvas.js | 2 +- .../main/webapp/js/nf/canvas/nf-controller-service.js | 10 ++++++---- .../webapp/js/nf/canvas/nf-processor-configuration.js | 3 ++- 4 files changed, 19 insertions(+), 6 deletions(-) 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 07b4c13b1d..31087c9308 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 @@ -1556,6 +1556,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { final Set updated = controllerServiceDAO.updateControllerServiceReferencingComponents(controllerServiceId, scheduledState, controllerServiceState); final ControllerServiceReference updatedReference = controllerServiceDAO.getControllerService(controllerServiceId).getReferences(); + // get the revisions of the updated components final Map updatedRevisions = new HashMap<>(); for (final ConfiguredComponent component : updated) { final Revision currentRevision = revisionManager.getRevision(component.getIdentifier()); @@ -1563,6 +1564,15 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { updatedRevisions.put(component.getIdentifier(), currentRevision.incrementRevision(requestRevision.getClientId())); } + // return the current revision if the component wasn't updated + for (final Map.Entry entry : referenceRevisions.entrySet()) { + final String componentId = entry.getKey(); + if (!updatedRevisions.containsKey(componentId)) { + final Revision currentRevision = revisionManager.getRevision(componentId); + updatedRevisions.put(componentId, currentRevision); + } + } + final ControllerServiceReferencingComponentsEntity entity = createControllerServiceReferencingComponentsEntity(updatedReference, updatedRevisions); return new StandardRevisionUpdate<>(entity, null, new HashSet<>(updatedRevisions.values())); } diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas.js index 664a3a1884..819aac11a2 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas.js @@ -873,7 +873,7 @@ nf.Canvas = (function () { var clusterSummary = clusterSummaryResponse.clusterSummary; // show disconnected message on load if necessary - if (clusterSummary.connectedToCluster === false) { + if (clusterSummary.clustered && !clusterSummary.connectedToCluster) { nf.Canvas.showDisconnectedFromClusterMessage(); } 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 7413c0a89f..adec624f22 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 @@ -613,7 +613,7 @@ nf.ControllerService = (function () { // wait until the polling of each service finished return $.Deferred(function (deferred) { updated.done(function () { - var serviceUpdated = pollService(controllerServiceEntity.component, function (service, bulletins) { + var serviceUpdated = pollService(controllerServiceEntity, function (service, bulletins) { if ($.isArray(bulletins)) { if (enabled) { updateBulletins(bulletins, $('#enable-controller-service-bulletins')); @@ -746,12 +746,14 @@ nf.ControllerService = (function () { * Polls the specified services referencing components to see if the * specified condition is satisfied. * - * @param {object} controllerService + * @param {object} controllerServiceEntity * @param {function} completeCondition * @param {function} bulletinDeferred * @param {function} pollCondition */ - var pollService = function (controllerService, completeCondition, bulletinDeferred, pollCondition) { + var pollService = function (controllerServiceEntity, completeCondition, bulletinDeferred, pollCondition) { + var controllerService = controllerServiceEntity.component; + // we want to keep polling until the condition is met return $.Deferred(function (deferred) { var current = 2; @@ -769,7 +771,7 @@ nf.ControllerService = (function () { var bulletins = bulletinDeferred(controllerService); var service = $.ajax({ type: 'GET', - url: controllerService.uri, + url: controllerServiceEntity.uri, dataType: 'json' }); diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-configuration.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-configuration.js index 3201a5ae1c..aaac0c5d49 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-configuration.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-configuration.js @@ -548,9 +548,10 @@ nf.ProcessorConfiguration = (function () { dialogContainer: '#new-processor-property-container', descriptorDeferred: function (propertyName) { var processor = $('#processor-configuration').data('processorDetails'); + var d = nf.Processor.get(processor.id); return $.ajax({ type: 'GET', - url: processor.uri + '/descriptors', + url: d.uri + '/descriptors', data: { propertyName: propertyName },