From bbcaa76510495a6232c32e2c40df283b5f04af12 Mon Sep 17 00:00:00 2001 From: Christopher Mooney Date: Sat, 18 Feb 2012 16:19:52 -0800 Subject: [PATCH 01/10] Added support for node-gossip to be run from within a project's directory. This means that one can use git submodule to install it. I was unable to get the tests working because a require path problem. This problem was so bad I can only assume my environment is incorrect for running expresso tests. Please run tests and make sure they work. --- index.js | 3 +++ lib/gossiper.js | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 index.js diff --git a/index.js b/index.js new file mode 100644 index 0000000..f0027b6 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// This file is just added for convenience so this repository can be +// directly checked out (submodule) into a project +module.exports = require('./lib/gossiper'); diff --git a/lib/gossiper.js b/lib/gossiper.js index 68e458c..7208353 100644 --- a/lib/gossiper.js +++ b/lib/gossiper.js @@ -1,5 +1,5 @@ -var PeerState = require('peer_state').PeerState, - Scuttle = require('scuttle').Scuttle, +var PeerState = require('./peer_state').PeerState, + Scuttle = require('./scuttle').Scuttle, EventEmitter = require('events').EventEmitter, net = require('net'), sys = require('sys'), From 7ea8ee0b882c8f3eafe864fb55186b6270d94363 Mon Sep 17 00:00:00 2001 From: Christopher Mooney Date: Fri, 24 Feb 2012 21:00:53 -0800 Subject: [PATCH 02/10] fixed a typo in the documentation. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2fdf315..f79dfcd 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Check out the the scripts in the simulations/ directory for some examples. Gossiper methods: - allPeeers() + allPeers() livePeers() deadPeers() peerValue(peer, key) From dba7308bd1750525201906c03d86204d7403c72f Mon Sep 17 00:00:00 2001 From: Christopher Mooney Date: Sun, 26 Feb 2012 22:01:54 -0800 Subject: [PATCH 03/10] Fixes for some bugs in the edge cases. These were hard to find since, for the most part, things appear to work. Nevertheless, in these few edge cases, node_gossip was not doing what it was intended to. What's more, the gossip function managed to never trigger bugs based on empty results from livePeers() and deadPeers(). --- lib/gossiper.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/gossiper.js b/lib/gossiper.js index 7208353..7e04395 100644 --- a/lib/gossiper.js +++ b/lib/gossiper.js @@ -12,6 +12,7 @@ var Gossiper = exports.Gossiper = function(port, seeds, ip_to_bind) { this.peers = {}; this.ip_to_bind = ip_to_bind; this.port = port; + this.seeds = seeds; this.my_state = new PeerState(); this.scuttle = new Scuttle(this.peers, this.my_state); @@ -63,12 +64,12 @@ Gossiper.prototype.stop = function() { } -// The method of choosing whice peer(s) to gossip to is borrowed from Cassandra. +// The method of choosing which peer(s) to gossip to is borrowed from Cassandra. // They seemed to have worked out all of the edge cases // http://wiki.apache.org/cassandra/ArchitectureGossip Gossiper.prototype.gossip = function() { // Find a live peer to gossip to - if(this.livePeers() > 0) { + if(this.livePeers().length > 0) { var live_peer = this.chooseRandom(this.livePeers()); this.gossipToPeer(live_peer); } @@ -219,12 +220,12 @@ Gossiper.prototype.allPeers = function() { Gossiper.prototype.livePeers = function() { var keys = []; - for(var k in this.peers) { if(k.alive) { keys.push(k)} }; + for(var k in this.peers) { if(this.peers[k].alive) { keys.push(k)} }; return keys; } Gossiper.prototype.deadPeers = function() { var keys = []; - for(var k in this.peers) { if(!k.alive) { keys.push(k) } }; + for(var k in this.peers) { if(!this.peers[k].alive) { keys.push(k) } }; return keys; } From e219b3579ff8d1d0187eebda654e39119793b3b3 Mon Sep 17 00:00:00 2001 From: Christopher Mooney Date: Fri, 1 Jun 2012 22:20:42 -0700 Subject: [PATCH 04/10] Added package.json for npm. --- package.json | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 package.json diff --git a/package.json b/package.json new file mode 100644 index 0000000..5e5edfe --- /dev/null +++ b/package.json @@ -0,0 +1,27 @@ +{ + "name": "node-gossip", + "description": "node-gossip implements a gossip protocol", + "version": "0.0.1", + "author": "Bob Potter ", + "contributors": [ + { + "name": "Bob Potter", + "email": "bobby.potter@gmail.com" + }, + { + "name": "Christopher Mooney", + "email": "chris@dod.net" + } + ], + "repository": { + "type" : "git", + "url" : "git://github.com/bpot/node-gossip.git" + }, + "keywords": ["gossip"], + "dependencies": { + "msgpack" : "git://github.com/godsflaw/node-msgpack.git" + }, + "main": "index.js", + "scripts": { "test": "expresso -I lib test/*" }, + "engines": { "node": "0.4.x || 0.5.x || 0.6.x || 0.7.x" } +} From b5b50f5218ea2213f5ceb5a6519ecaa4f5503077 Mon Sep 17 00:00:00 2001 From: Christopher Mooney Date: Fri, 1 Jun 2012 22:23:51 -0700 Subject: [PATCH 05/10] So it installs as gossiper. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5e5edfe..ab345e0 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "node-gossip", + "name": "gossiper", "description": "node-gossip implements a gossip protocol", "version": "0.0.1", "author": "Bob Potter ", From ca500e283b4ae0e4ccf1d5bcdb6fc40ea19b07fe Mon Sep 17 00:00:00 2001 From: Christopher Mooney Date: Fri, 1 Jun 2012 22:27:41 -0700 Subject: [PATCH 06/10] Stop yammering about sys being called util now. --- lib/gossiper.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/gossiper.js b/lib/gossiper.js index 7e04395..d4318a1 100644 --- a/lib/gossiper.js +++ b/lib/gossiper.js @@ -1,11 +1,11 @@ -var PeerState = require('./peer_state').PeerState, - Scuttle = require('./scuttle').Scuttle, - EventEmitter = require('events').EventEmitter, - net = require('net'), - sys = require('sys'), +var PeerState = require('./peer_state').PeerState, + Scuttle = require('./scuttle').Scuttle, + EventEmitter = require('events').EventEmitter, + net = require('net'), + util = require('util'), child_process = require('child_process'), - dns = require('dns'), - msgpack = require('msgpack'); + dns = require('dns'), + msgpack = require('msgpack'); var Gossiper = exports.Gossiper = function(port, seeds, ip_to_bind) { EventEmitter.call(this); @@ -19,7 +19,7 @@ var Gossiper = exports.Gossiper = function(port, seeds, ip_to_bind) { this.handleNewPeers(seeds); } -sys.inherits(Gossiper, EventEmitter); +util.inherits(Gossiper, EventEmitter); Gossiper.prototype.start = function(callback) { var self = this; @@ -113,7 +113,7 @@ Gossiper.prototype.gossipToPeer = function(peer) { mp_stream.send(self.requestMessage()); }); gosipee.on('error', function(exception) { -// console.log(self.peer_name + " received " + sys.inspect(exception)); +// console.log(self.peer_name + " received " + util.inspect(exception)); }); } From ed7bb424a5736f26c6ebf6a1a4db4d23e8e9c198 Mon Sep 17 00:00:00 2001 From: Christopher Mooney Date: Fri, 1 Jun 2012 22:29:38 -0700 Subject: [PATCH 07/10] A few more changes to convert sys to util. --- lib/peer_state.js | 8 ++++---- simulation/s3.js | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/peer_state.js b/lib/peer_state.js index 19aa16f..b5e6705 100644 --- a/lib/peer_state.js +++ b/lib/peer_state.js @@ -1,6 +1,6 @@ -var AccrualFailureDetector = require('./accrual_failure_detector').AccrualFailureDetector, - EventEmitter = require('events').EventEmitter, - sys = require('sys'); +var AccrualFailureDetector = require('./accrual_failure_detector').AccrualFailureDetector, + EventEmitter = require('events').EventEmitter, + util = require('util'); var PeerState = exports.PeerState = function(name) { EventEmitter.call(this); @@ -13,7 +13,7 @@ var PeerState = exports.PeerState = function(name) { this.name = name; }; -sys.inherits(PeerState, EventEmitter); +util.inherits(PeerState, EventEmitter); PeerState.prototype.updateWithDelta = function(k,v,n) { // It's possibly to get the same updates more than once if we're gossiping with multiple peers at once diff --git a/simulation/s3.js b/simulation/s3.js index 9a7e2a8..56888b3 100644 --- a/simulation/s3.js +++ b/simulation/s3.js @@ -1,5 +1,4 @@ var Gossiper = require('gossiper').Gossiper; -var sys = require('sys'); var seed1 = new Gossiper(9000, []); seed1.start(); From bbacd6e90918c30f8a872552f47cb22f03d84d77 Mon Sep 17 00:00:00 2001 From: Christopher Mooney Date: Tue, 28 Aug 2012 16:42:09 -0700 Subject: [PATCH 08/10] Testing new node versions. Testing new version of node and msgpack. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ab345e0..3689627 100644 --- a/package.json +++ b/package.json @@ -23,5 +23,5 @@ }, "main": "index.js", "scripts": { "test": "expresso -I lib test/*" }, - "engines": { "node": "0.4.x || 0.5.x || 0.6.x || 0.7.x" } + "engines": { "node": "0.4.x || 0.5.x || 0.6.x || 0.7.x || 0.8.x || 0.9.x" } } From 91aaa7cdd6c610922b2787f490c195351ef82945 Mon Sep 17 00:00:00 2001 From: Christopher Mooney Date: Wed, 29 Aug 2012 11:04:31 -0700 Subject: [PATCH 09/10] Tested with node-msgpack. Runs good. --- .gitignore | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 45d62d8..54ba1b3 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.sw? +node_modules diff --git a/package.json b/package.json index 3689627..c16c2d5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "gossiper", "description": "node-gossip implements a gossip protocol", - "version": "0.0.1", + "version": "0.0.2", "author": "Bob Potter ", "contributors": [ { From 372a00797d6bd897121f0d6eb51dbcbde7168af0 Mon Sep 17 00:00:00 2001 From: Christopher Mooney Date: Wed, 29 Aug 2012 15:35:35 -0700 Subject: [PATCH 10/10] Version bump for new msgpack. In addition to version bump, I guess I can publish to npm too. --- package.json | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index c16c2d5..1dd8192 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,9 @@ { "name": "gossiper", "description": "node-gossip implements a gossip protocol", - "version": "0.0.2", + "version": "0.0.3", "author": "Bob Potter ", "contributors": [ - { - "name": "Bob Potter", - "email": "bobby.potter@gmail.com" - }, { "name": "Christopher Mooney", "email": "chris@dod.net" @@ -19,7 +15,7 @@ }, "keywords": ["gossip"], "dependencies": { - "msgpack" : "git://github.com/godsflaw/node-msgpack.git" + "msgpack" : ">= 0.0.0" }, "main": "index.js", "scripts": { "test": "expresso -I lib test/*" },