Skip to content
This repository has been archived by the owner on May 18, 2023. It is now read-only.

Commit

Permalink
Merge pull request #21 from azuqua/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
kevinwilson541 committed Apr 26, 2017
2 parents b47ba1a + 67f93da commit dc16c50
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 17 deletions.
2 changes: 2 additions & 0 deletions lib/cluster_node.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ class ClusterNode extends EventEmitter {
return cb(new Error("Loaded ring ID '" + this._gossip._ringID + "' does not match '" + ringID + "'"));
}
this._comms.start("command");
// clear ring ID so that we can start the gossip server (we know they're the same, so it's a noop)
this._gossip.ringID(null);
this._gossip.start(ringID);
this._kernel.start({cookie: cookie});

Expand Down
4 changes: 2 additions & 2 deletions lib/consts.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ var vclockOpts = {
// number of elements that need to exist for trimming to occur
lowerBound: 10,
// how old the youngest member needs to be before considering trimming
youngBound: 20000,
youngBound: 20000000,
// when trimming, trim to at least this number of elements
upperBound: 50,
// when trimming, trim any members at least this old
oldBound: 86400000
oldBound: 86400000000
};

var networkHost = os.hostname();
Expand Down
20 changes: 20 additions & 0 deletions lib/gossip.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,26 @@ class GossipRing extends GenServer {
return this._vclock;
}

/**
*
* Acts as a getter/setter for the ring ID of this instance.
*
* @method ringID
* @memberof Clusterluck.GossipRing
* @instance
*
* @param {String} [ring] - Ring ID to set on this instance.
*
* @return {String} Ring ID of this instance.
*
*/
ringID(ring) {
if (ring !== undefined) {
this._ringID = ring;
}
return this._ringID;
}

/**
*
* Joins the ring `ringID` if not already a member of a ring. Otherwise, will return an error noting that this instance already belongs to a ring.
Expand Down
24 changes: 9 additions & 15 deletions test/unit/gossip.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,6 @@ var _ = require("lodash"),
EventEmitter = require("events").EventEmitter,
assert = require("chai").assert;

class MockTable extends EventEmitter {
constructor(id) {
super();
this._id = id;
}

id() {
return "foo";
}

stop() {
return this;
}
}

module.exports = function (mocks, lib) {
describe("Gossip unit tests", function () {
var VectorClock = lib.vclock,
Expand Down Expand Up @@ -92,6 +77,15 @@ module.exports = function (mocks, lib) {
assert.deepEqual(gossip._vclock, clock);
});

it("Should grab ring ID of gossip ring", function () {
assert.equal(gossip.ringID(), undefined);
});

it("Should set ring ID of gossip ring", function () {
gossip.ringID("foo");
assert.equal(gossip._ringID, "foo");
});

it("Should grab kernel of gossip ring", function () {
assert.deepEqual(gossip.kernel(), kernel);
});
Expand Down

0 comments on commit dc16c50

Please sign in to comment.