eslint errors
This commit is contained in:
parent
fddc76b542
commit
ac4d1c4e28
@ -42,7 +42,7 @@ Locker.prototype.unlock = function (resource, callback) {
|
||||
|
||||
Locker.prototype.startRenewal = function (resource) {
|
||||
var self = this;
|
||||
if (!this.intervalIds.hasOwnProperty(resource)) {
|
||||
if (!Object.prototype.hasOwnProperty.call(this.intervalIds, resource)) {
|
||||
this.intervalIds[resource] = setInterval(function () {
|
||||
debug('Trying to extend lock resource=%s', resource);
|
||||
self.locker.lock(resource, self.ttl, function (err, _lock) {
|
||||
@ -59,7 +59,7 @@ Locker.prototype.startRenewal = function (resource) {
|
||||
};
|
||||
|
||||
Locker.prototype.stopRenewal = function (resource) {
|
||||
if (this.intervalIds.hasOwnProperty(resource)) {
|
||||
if (Object.prototype.hasOwnProperty.call(this.intervalIds, resource)) {
|
||||
clearInterval(this.intervalIds[resource]);
|
||||
delete this.intervalIds[resource];
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ RedisDistlockLocker.prototype.unlock = function (resource, callback) {
|
||||
};
|
||||
|
||||
RedisDistlockLocker.prototype._getLock = function (resource) {
|
||||
if (this._locks.hasOwnProperty(resource)) {
|
||||
if (Object.prototype.hasOwnProperty.call(this._locks, resource)) {
|
||||
return this._locks[resource];
|
||||
}
|
||||
return null;
|
||||
|
@ -27,6 +27,9 @@ module.exports = HostUserQueueMover;
|
||||
HostUserQueueMover.prototype.moveOldJobs = function (callback) {
|
||||
var self = this;
|
||||
this.getOldQueues(function (err, hosts) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
var async = asyncQ(4);
|
||||
hosts.forEach(function (host) {
|
||||
async.defer(self.moveOldQueueJobs.bind(self), host);
|
||||
@ -78,6 +81,9 @@ HostUserQueueMover.prototype.processNextJob = function (host, callback) {
|
||||
}
|
||||
|
||||
client.lpop(QUEUE.OLD.PREFIX + host, function (err, jobId) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
self.pool.release(QUEUE.OLD.DB, client);
|
||||
debug('Found jobId=%s at queue=%s', jobId, host);
|
||||
if (!jobId) {
|
||||
|
@ -38,7 +38,7 @@ async function scan () {
|
||||
const jobs = [];
|
||||
const initialCursor = '0';
|
||||
|
||||
return await _scan(initialCursor, jobs);
|
||||
return _scan(initialCursor, jobs);
|
||||
};
|
||||
|
||||
async function _scan (cursor, jobs) {
|
||||
@ -53,7 +53,7 @@ async function _scan (cursor, jobs) {
|
||||
return jobs;
|
||||
}
|
||||
|
||||
return await _scan(_cursor, jobs);
|
||||
return _scan(_cursor, jobs);
|
||||
}
|
||||
|
||||
async function getJob (key) {
|
||||
|
@ -266,12 +266,12 @@ function parseQueryId (queryId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
function elapsedTime (started_at, ended_at) {
|
||||
if (!started_at || !ended_at) {
|
||||
function elapsedTime (startedAt, endedAt) {
|
||||
if (!startedAt || !endedAt) {
|
||||
return;
|
||||
}
|
||||
|
||||
var start = new Date(started_at);
|
||||
var end = new Date(ended_at);
|
||||
var start = new Date(startedAt);
|
||||
var end = new Date(endedAt);
|
||||
return end.getTime() - start.getTime();
|
||||
}
|
||||
|
@ -13,9 +13,9 @@ function hasDBParams (dbparams) {
|
||||
return (dbparams.user && dbparams.host && dbparams.port && dbparams.dbname && dbparams.pass);
|
||||
}
|
||||
|
||||
QueryRunner.prototype.run = function (job_id, sql, user, timeout, dbparams, callback) {
|
||||
QueryRunner.prototype.run = function (jobId, sql, user, timeout, dbparams, callback) {
|
||||
if (hasDBParams(dbparams)) {
|
||||
return this._run(dbparams, job_id, sql, timeout, callback);
|
||||
return this._run(dbparams, jobId, sql, timeout, callback);
|
||||
}
|
||||
|
||||
const dbConfigurationError = new Error('Batch Job DB misconfiguration');
|
||||
@ -23,8 +23,8 @@ QueryRunner.prototype.run = function (job_id, sql, user, timeout, dbparams, call
|
||||
return callback(dbConfigurationError);
|
||||
};
|
||||
|
||||
QueryRunner.prototype._run = function (dbparams, job_id, sql, timeout, callback) {
|
||||
QueryRunner.prototype._run = function (dbparams, jobId, sql, timeout, callback) {
|
||||
var pg = new PSQL(dbparams);
|
||||
this.logger.debug('Running query [timeout=%d] %s', timeout, sql);
|
||||
pg.query(`/* ${job_id} */ ${sql}`, callback, false, timeout);
|
||||
pg.query(`/* ${jobId} */ ${sql}`, callback, false, timeout);
|
||||
};
|
||||
|
@ -64,7 +64,7 @@ HostScheduler.prototype.lock = function (host, callback) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
if (!self.schedulers.hasOwnProperty(host)) {
|
||||
if (!Object.prototype.hasOwnProperty.call(self.schedulers, host)) {
|
||||
var scheduler = new Scheduler(self.getCapacityProvider(host), self.taskRunner);
|
||||
scheduler.on('done', self.unlock.bind(self, host));
|
||||
self.schedulers[host] = scheduler;
|
||||
@ -77,7 +77,7 @@ HostScheduler.prototype.lock = function (host, callback) {
|
||||
|
||||
HostScheduler.prototype.unlock = function (host) {
|
||||
debug('[%s] unlock(%s)', this.name, host);
|
||||
if (this.schedulers.hasOwnProperty(host)) {
|
||||
if (Object.prototype.hasOwnProperty.call(this.schedulers, host)) {
|
||||
// TODO stop scheduler?
|
||||
delete this.schedulers[host];
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ Scheduler.prototype.schedule = function () {
|
||||
forever(
|
||||
function (next) {
|
||||
debug('Waiting for task');
|
||||
self.acquire(function (err, taskEntity) {
|
||||
self.acquire(function (_err, taskEntity) {
|
||||
debug('Acquired user=%j', taskEntity);
|
||||
|
||||
if (!taskEntity) {
|
||||
@ -157,7 +157,7 @@ Scheduler.prototype.acquire = function (callback) {
|
||||
});
|
||||
};
|
||||
|
||||
Scheduler.prototype.release = function (err, taskEntity) {
|
||||
Scheduler.prototype.release = function (_err, taskEntity) {
|
||||
debug('Released %j', taskEntity);
|
||||
if (taskEntity.is(STATUS.PENDING)) {
|
||||
this.tasksTree.insert(taskEntity);
|
||||
|
@ -20,20 +20,20 @@ CartodbRequest.prototype.userByReq = function (req) {
|
||||
return userByHostName(req.headers.host);
|
||||
};
|
||||
|
||||
var re_userFromHost = new RegExp(
|
||||
var userFromHostRegex = new RegExp(
|
||||
global.settings.user_from_host || '^([^\\.]+)\\.' // would extract "strk" from "strk.cartodb.com"
|
||||
);
|
||||
|
||||
function userByHostName (host) {
|
||||
var mat = host.match(re_userFromHost);
|
||||
var mat = host.match(userFromHostRegex);
|
||||
if (!mat) {
|
||||
console.error("ERROR: user pattern '" + re_userFromHost + "' does not match hostname '" + host + "'");
|
||||
console.error("ERROR: user pattern '" + userFromHostRegex + "' does not match hostname '" + host + "'");
|
||||
return;
|
||||
}
|
||||
|
||||
if (mat.length !== 2) {
|
||||
console.error(
|
||||
"ERROR: pattern '" + re_userFromHost + "' gave unexpected matches against '" + host + "': " + mat
|
||||
"ERROR: pattern '" + userFromHostRegex + "' gave unexpected matches against '" + host + "': " + mat
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user