mirror of
https://github.com/apache/nifi.git
synced 2025-02-17 15:36:36 +00:00
NIFI-4518:
- When the URI is too long, invoking the bulletin board multiple times for all specified component ids.
This commit is contained in:
parent
10f27cd5f0
commit
32c0e2be3b
@ -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 TWO_PI = 2 * Math.PI;
|
||||||
|
|
||||||
var binarySearch = function (length, comparator) {
|
var binarySearch = function (length, comparator) {
|
||||||
@ -245,16 +247,83 @@
|
|||||||
* @returns {deferred}
|
* @returns {deferred}
|
||||||
*/
|
*/
|
||||||
queryBulletins: function (componentIds) {
|
queryBulletins: function (componentIds) {
|
||||||
var ids = componentIds.join('|');
|
var queries = [];
|
||||||
|
|
||||||
return $.ajax({
|
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',
|
type: 'GET',
|
||||||
url: '../nifi-api/flow/bulletin-board',
|
url: endpoint,
|
||||||
data: {
|
|
||||||
sourceId: ids
|
|
||||||
},
|
|
||||||
dataType: 'json'
|
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);
|
}).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.
|
* Set the parameters of the URL.
|
||||||
*
|
*
|
||||||
|
@ -71,6 +71,8 @@
|
|||||||
}(this, function ($, d3, Slick, nfCanvas, nfCanvasUtils, nfErrorHandler, nfDialog, nfClient, nfCommon, nfNgBridge, nfProcessor, nfProcessGroup, nfProcessGroupConfiguration) {
|
}(this, function ($, d3, Slick, nfCanvas, nfCanvasUtils, nfErrorHandler, nfDialog, nfClient, nfCommon, nfNgBridge, nfProcessor, nfProcessGroup, nfProcessGroupConfiguration) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
var lastSelectedId = null;
|
||||||
|
|
||||||
// text editor
|
// text editor
|
||||||
var textEditor = function (args) {
|
var textEditor = function (args) {
|
||||||
var scope = this;
|
var scope = this;
|
||||||
@ -568,9 +570,15 @@
|
|||||||
var variableIndex = args.rows[0];
|
var variableIndex = args.rows[0];
|
||||||
var variable = variablesGrid.getDataItem(variableIndex);
|
var variable = variablesGrid.getDataItem(variableIndex);
|
||||||
|
|
||||||
|
// 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
|
// update the details for this variable
|
||||||
$('#affected-components-context').removeClass('unset').text(variable.name);
|
$('#affected-components-context').removeClass('unset').text(variable.name);
|
||||||
populateAffectedComponents(variable.affectedComponents);
|
populateAffectedComponents(variable.affectedComponents);
|
||||||
|
|
||||||
|
// update the last selected id
|
||||||
|
lastSelectedId = variable.id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user