8000 3 3 fixed gathering of coordinator statistics in a cluster environmen… · Mars2018/arangodb@6a31068 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6a31068

Browse files
hkernbachjsteemann
authored andcommitted
3 3 fixed gathering of coordinator statistics in a cluster environment (arangodb#6936)
1 parent be5ca64 commit 6a31068

File tree

2 files changed

+59
-41
lines changed

2 files changed

+59
-41
lines changed

CHANGELOG

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
v3.3.19 (XXXX-XX-XX)
2+
--------------------
3+
4+
* An aardvark statistics route could not collect and sum up the statistics of
5+
all coordinators if one of them was ahead and had more results than the others
6+
7+
18
v3.3.18 (2018-10-17)
29
--------------------
310

js/apps/system/_admin/aardvark/APP/statistics.js

Lines changed: 52 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ function computeStatisticsRaw (result, start, clusterId) {
163163
for (let key in STAT_SERIES) {
164164
if (STAT_SERIES.hasOwnProperty(key)) {
165165
path = STAT_SERIES[key];
166-
167166
result[key].push(stat[path[0]][path[1]]);
168167
}
169168
}
@@ -316,6 +315,7 @@ function computeStatisticsShort (start, clusterId) {
316315
const result = {};
317316

318317
computeStatisticsRaw(result, start, clusterId);
318+
319319
computeStatisticsRaw15M(result, start, clusterId);
320320

321321
return result;
@@ -405,13 +405,12 @@ router.use((req, res, next) => {
405405
next();
406406
});
407407

408-
router.get("/coordshort", function(req, res) {
408+
router.get('/coordshort', function (req, res) {
409409
var merged = {
410410
http: {}
411411
};
412412

413-
var mergeHistory = function(data) {
414-
413+
var mergeHistory = function (data) {
415414
var onetime = ['times'];
416415
var values = [
417416
'physicalMemory',
@@ -435,56 +434,58 @@ router.get("/coordshort", function(req, res) {
435434
'avgRequestTime'
436435
];
437436

438-
var counter = 0, counter2;
439-
440-
_.each(data, function(stat) {
441-
//if (stat.enabled) {
442-
// self.statsEnabled = true;
443-
// }
444-
//else {
445-
// self.statsEnabled = false;
446-
//}
437+
var counter = 0;
438+
var counter2;
447439

440+
_.each(data, function (stat) {
448441
if (typeof stat === 'object') {
449442
if (counter === 0) {
450-
//one time value
451-
_.each(onetime, function(value) {
443+
// one time value
444+
_.each(onetime, function (value) {
452445
merged[value] = stat[value];
453446
});
454447

455-
//values
456-
_.each(values, function(value) {
448+
// values
449+
_.each(values, function (value) {
457450
merged[value] = stat[value];
458451
});
459452

460-
//http requests arrays
461-
_.each(http, function(value) {
453+
// http requests arrays
454+
_.each(http, function (value) {
462455
merged.http[value] = stat[value];
463456
});
464457

465-
//arrays
466-
_.each(arrays, function(value) {
458+
// arrays
459+
_.each(arrays, function (value) {
467460
merged[value] = stat[value];
468461
});
469-
470-
}
471-
else A3DB {
472-
//values
473-
_.each(values, function(value) {
462+
} else {
463+
// values
464+
_.each(values, function (value) {
474465
merged[value] = merged[value] + stat[value];
475466
});
476-
//http requests arrays
477-
_.each(http, function(value) {
467+
// http requests arrays
468+
_.each(http, function (value) {
478469
counter2 = 0;
479-
_.each(stat[value], function(x) {
480-
merged.http[value][counter2] = merged.http[value][counter2] + x;
470+
_.each(stat[value], function (x) {
471+
if (merged.http[value][counter2] === undefined) {
472+
// this will hit if a previous coordinater was not able to deliver
473+
// proper current statistics, but the current one already has statistics.
474+
merged.http[value][counter2] = x;
475+
} else {
476+
merged.http[value][counter2] = merged.http[value][counter2] + x;
477+
}
481478
counter2++;
482479
});
483480
});
484-
_.each(arrays, function(value) {
481+
_.each(arrays, function (value) {
485482
counter2 = 0;
486-
_.each(stat[value], function(x) {
487-
merged[value][counter2] = merged[value][counter2] + x;
483+
_.each(stat[value], function (x) {
484+
if (merged[value][counter2] === undefined) {
485+
merged[value][counter2] = 0;
486+
} else {
487+
merged[value][counter2] = merged[value][counter2] + x;
488+
}
488489
counter2++;
489490
});
490491
});
@@ -495,17 +496,18 @@ router.get("/coordshort", function(req, res) {
495496
};
496497

497498
var coordinators = global.ArangoClusterInfo.getCoordinators();
499+
var coordinatorStats;
498500
if (Array.isArray(coordinators)) {
499-
var coordinatorStats = coordinators.map(coordinator => {
501+
coordinatorStats = coordinators.map(coordinator => {
500502
var endpoint = global.ArangoClusterInfo.getServerEndpoint(coordinator);
501503
if (endpoint.substring(0, 3) === 'ssl') {
502504
// if protocol ssl is returned, change it to https
503505
endpoint = 'https' + endpoint.substring(3);
504506
}
505-
if (endpoint !== "") {
506-
var response = download(endpoint.replace(/^tcp/, "http") + "/_db/_system/_admin/aardvark/statistics/short?count=" + coordinators.length, '', {headers: {}});
507+
if (endpoint !== '') {
508+
var response = download(endpoint.replace(/^tcp/, 'http') + '/_db/_system/_admin/aardvark/statistics/short?count=' + coordinators.length, '', {headers: {}});
507509
if (response.body === undefined) {
508-
console.warn("cannot contact coordinator " + coordinator + " on endpoint " + endpoint);
510+
console.warn('cannot contact coordinator ' + coordinator + ' on endpoint ' + endpoint);
509511
} else {
510512
try {
511513
return JSON.parse(response.body);
@@ -518,12 +520,21 @@ router.get("/coordshort", function(req, res) {
518520
return false;
519521
});
520522

521-
mergeHistory(coordinatorStats);
523+
if (coordinatorStats) {
524+
mergeHistory(coordinatorStats);
525+
}
526+
}
527+
if (coordinatorStats) {
528+
res.json({'enabled': coordinatorStats.some(stat => stat.enabled), 'data': merged});
529+
} else {
530+
res.json({
531+
'enabled': false,
532+
'data': {}
533+
});
522534
}
523-
res.json({"enabled": coordinatorStats.some(stat => stat.enabled), "data": merged});
524535
})
525-
.summary("Short term history for all coordinators")
526-
.description("This function is used to get the statistics history.");
536+
.summary('Short term history for all coordinators')
537+
.description('This function is used to get the statistics history.');
527538

528539
router.get("/short", function (req, res) {
529540
const start = req.queryParams.start;

0 commit comments

Comments
 (0)
0