Skip to content

Commit

Permalink
Add timestamps to membership update rollups
Browse files Browse the repository at this point in the history
  • Loading branch information
jwolski committed Mar 3, 2015
1 parent 96f9d8f commit 52fe2a6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/membership_update_rollup.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
// THE SOFTWARE.
'use strict';

var _ = require('underscore');
var EventEmitter = require('events').EventEmitter;
var util = require('util');

Expand All @@ -43,14 +44,18 @@ function MembershipUpdateRollup(options) {
util.inherits(MembershipUpdateRollup, EventEmitter);

MembershipUpdateRollup.prototype.addUpdates = function addUpdates(updates) {
var ts = Date.now();

for (var i = 0; i < updates.length; i++) {
var update = updates[i];

if (!this.buffer[update.address]) {
this.buffer[update.address] = [];
}

this.buffer[update.address].push(update);
// TODO Replace _.extend with extend module
var updateWithTimestamp = _.extend({ ts: ts }, update);
this.buffer[update.address].push(updateWithTimestamp);
}
};

Expand All @@ -68,6 +73,7 @@ MembershipUpdateRollup.prototype.flushBuffer = function flushBuffer() {

var numUpdates = this.getNumUpdates();
this.ringpop.logger.info('ringpop flushed membership update buffer', {
local: this.ringpop.whoami(),
checksum: this.ringpop.membership.checksum,
sinceFirstUpdate: this.lastUpdateTime && (this.lastUpdateTime - this.firstUpdateTime),
sinceLastFlush: this.lastFlushTime && (now - this.lastFlushTime),
Expand Down

0 comments on commit 52fe2a6

Please sign in to comment.