Repository: nifi
Updated Branches:
  refs/heads/master 10f27cd5f -> 1625f719e


NIFI-4518:
- When the URI is too long, invoking the bulletin board multiple times for all 
specified component ids.


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

Branch: refs/heads/master
Commit: 32c0e2be3b824deaf749278718d9ca35e43e33e3
Parents: 10f27cd
Author: Matt Gilman <[email protected]>
Authored: Thu Oct 26 10:27:57 2017 -0400
Committer: Matt Gilman <[email protected]>
Committed: Thu Oct 26 10:27:57 2017 -0400

----------------------------------------------------------------------
 .../main/webapp/js/nf/canvas/nf-canvas-utils.js | 89 +++++++++++++++++---
 .../webapp/js/nf/canvas/nf-variable-registry.js | 14 ++-
 2 files changed, 89 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi/blob/32c0e2be/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-utils.js
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-utils.js
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-utils.js
index 4ead97b..f9178e2 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-utils.js
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-utils.js
@@ -65,6 +65,8 @@
         }
     };
 
+    var MAX_URL_LENGTH = 2000;  // the maximum (suggested) safe string length 
of a URL supported by all browsers and application servers
+
     var TWO_PI = 2 * Math.PI;
 
     var binarySearch = function (length, comparator) {
@@ -245,16 +247,83 @@
          * @returns {deferred}
          */
         queryBulletins: function (componentIds) {
-            var ids = componentIds.join('|');
+            var queries = [];
 
-            return $.ajax({
-                type: 'GET',
-                url: '../nifi-api/flow/bulletin-board',
-                data: {
-                    sourceId: ids
-                },
-                dataType: 'json'
-            }).fail(nfErrorHandler.handleAjaxError);
+            var query = function (ids) {
+                var url = new URL(window.location);
+                var endpoint = url.origin + '/nifi-api/flow/bulletin-board?' + 
$.param({
+                    sourceId: ids.join('|')
+                });
+
+                if (endpoint.length > MAX_URL_LENGTH) {
+                    // split into two arrays and recurse with both halves
+                    var mid = Math.ceil(ids.length / 2);
+
+                    // left half
+                    var left = ids.slice(0, mid);
+                    if (left.length > 0) {
+                        query(left);
+                    }
+
+                    // right half
+                    var right = ids.slice(mid);
+                    if (right.length > 0) {
+                        query(right);
+                    }
+                } else {
+                    queries.push($.ajax({
+                        type: 'GET',
+                        url: endpoint,
+                        dataType: 'json'
+                    }));
+                }
+            };
+
+            // initiate the queries
+            query(componentIds);
+
+            if (queries.length === 1) {
+                // if there was only one query, return it
+                return queries[0].fail(nfErrorHandler.handleAjaxError);
+            } else {
+                // if there were multiple queries, wait for each to complete
+                return $.Deferred(function (deferred) {
+                    $.when.apply(window, queries).done(function () {
+                        var results = $.makeArray(arguments);
+
+                        var generated = null;
+                        var bulletins = [];
+
+                        $.each(results, function (_, result) {
+                            var response = result[0];
+                            var bulletinBoard = response.bulletinBoard;
+
+                            // use the first generated timestamp
+                            if (generated === null) {
+                                generated = bulletinBoard.generated;
+                            }
+
+                            // build up all the bulletins
+                            Array.prototype.push.apply(bulletins, 
bulletinBoard.bulletins);
+                        });
+
+                        // sort all the bulletins
+                        bulletins.sort(function (a, b) {
+                            return b.id - a.id;
+                        });
+
+                        // resolve with a aggregated result
+                        deferred.resolve({
+                            bulletinBoard: {
+                                generated: generated,
+                                bulletins: bulletins
+                            }
+                        });
+                    }).fail(function () {
+                        deferred.reject();
+                    }).fail(nfErrorHandler.handleAjaxError);
+                }).promise();
+            }
         },
 
         /**
@@ -418,8 +487,6 @@
             }
         },
 
-        MAX_URL_LENGTH: 2000,  // the maximum (suggested) safe string length 
of a URL supported by all browsers and application servers
-
         /**
          * Set the parameters of the URL.
          *

http://git-wip-us.apache.org/repos/asf/nifi/blob/32c0e2be/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-variable-registry.js
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-variable-registry.js
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-variable-registry.js
index 1614632..668d1d2 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-variable-registry.js
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-variable-registry.js
@@ -71,6 +71,8 @@
 }(this, function ($, d3, Slick, nfCanvas, nfCanvasUtils, nfErrorHandler, 
nfDialog, nfClient, nfCommon, nfNgBridge, nfProcessor, nfProcessGroup, 
nfProcessGroupConfiguration) {
     'use strict';
 
+    var lastSelectedId = null;
+
     // text editor
     var textEditor = function (args) {
         var scope = this;
@@ -568,9 +570,15 @@
                     var variableIndex = args.rows[0];
                     var variable = variablesGrid.getDataItem(variableIndex);
 
-                    // update the details for this variable
-                    
$('#affected-components-context').removeClass('unset').text(variable.name);
-                    populateAffectedComponents(variable.affectedComponents);
+                    // only populate affected components if this variable is 
different than the last selected
+                    if (lastSelectedId === null || lastSelectedId !== 
variable.id) {
+                        // update the details for this variable
+                        
$('#affected-components-context').removeClass('unset').text(variable.name);
+                        
populateAffectedComponents(variable.affectedComponents);
+
+                        // update the last selected id
+                        lastSelectedId = variable.id;
+                    }
                 }
             }
         });

Reply via email to