Merge pull request #577 from CartoDB/analysis-limits-configuration

Retrieve analysis limits and pass them into camshaft
This commit is contained in:
Raul Ochoa 2016-10-11 16:00:07 +02:00 committed by GitHub
commit d1928ee578
5 changed files with 888 additions and 595 deletions

View File

@ -3,6 +3,12 @@
## 2.78.2
Released 2016-mm-dd
New features:
- Retrieve analysis limits and pass them into camshaft.
Announcements:
- Upgrades camshaft to [0.45.0](https://github.com/CartoDB/camshaft/releases/tag/0.45.0).
## 2.78.1
Released 2016-09-30

View File

@ -1,7 +1,13 @@
var camshaft = require('camshaft');
var fs = require('fs');
function AnalysisBackend (options) {
var REDIS_LIMITS = {
DB: 5,
PREFIX: 'limits:analyses:' // + username
};
function AnalysisBackend (metadataBackend, options) {
this.metadataBackend = metadataBackend;
options = options || {};
this.setBatchConfig(options.batch);
this.setLoggerConfig(options.logger);
@ -46,5 +52,31 @@ AnalysisBackend.prototype.create = function(analysisConfiguration, analysisDefin
stream: this.stream ? this.stream : process.stdout
};
this.getAnalysesLimits(analysisConfiguration.user, function(err, limits) {
analysisConfiguration.limits = limits || {};
camshaft.create(analysisConfiguration, analysisDefinition, callback);
});
};
AnalysisBackend.prototype.getAnalysesLimits = function(username, callback) {
var analysesLimitsKey = REDIS_LIMITS.PREFIX + username;
this.metadataBackend.redisCmd(REDIS_LIMITS.DB, 'HGETALL', [analysesLimitsKey], function(err, analysesTimeouts) {
analysesTimeouts = analysesTimeouts || {};
var analysesLimits = {
analyses: {
// buffer: {
// timeout: 1000
// }
}
};
Object.keys(analysesTimeouts).forEach(function(analysisType) {
analysesLimits.analyses[analysisType] = {
timeout: Number.isFinite(+analysesTimeouts[analysisType]) ? +analysesTimeouts[analysisType] : 0
};
});
return callback(null, analysesLimits);
});
};

View File

@ -148,7 +148,7 @@ module.exports = function(serverOptions) {
var mapValidatorBackend = new windshaft.backend.MapValidator(tileBackend, attributesBackend);
var mapBackend = new windshaft.backend.Map(rendererCache, mapStore, mapValidatorBackend);
var analysisBackend = new AnalysisBackend(serverOptions.analysis);
var analysisBackend = new AnalysisBackend(metadataBackend, serverOptions.analysis);
var layergroupAffectedTablesCache = new LayergroupAffectedTablesCache();
app.layergroupAffectedTablesCache = layergroupAffectedTablesCache;

1315
npm-shrinkwrap.json generated

File diff suppressed because it is too large Load Diff

View File

@ -20,7 +20,7 @@
],
"dependencies": {
"body-parser": "~1.14.0",
"camshaft": "0.44.2",
"camshaft": "0.45.0",
"cartodb-psql": "~0.6.1",
"cartodb-query-tables": "~0.1.0",
"cartodb-redis": "0.13.1",