Skip to content

Commit

Permalink
Don't disseminate join list
Browse files Browse the repository at this point in the history
  • Loading branch information
Wieger Steggerda authored and jwolski committed Nov 24, 2015
1 parent cc0671a commit 286e5d9
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
8 changes: 8 additions & 0 deletions lib/gossip/dissemination.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ Dissemination.prototype.resetMaxPiggybackCount = function resetMaxPiggybackCount
this.maxPiggybackCount = Dissemination.Defaults.maxPiggybackCount;
};

Dissemination.prototype.getChangeByAddress = function getChangeByAddress(address) {
return this.changes[address];
};

Dissemination.prototype.getChangesCount = function getChangesCount() {
return Object.keys(this.changes).length;
};

Dissemination.prototype._issueAs = function _issueAs(filterChange, mapChanges) {
var changesToDisseminate = [];

Expand Down
2 changes: 0 additions & 2 deletions lib/on_membership_event.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ function createSetHandler(ringpop) {
serversToAdd.push(update.address);
ringpop.suspicion.start(update);
}

ringpop.dissemination.recordChange(update);
}

// Must add/remove servers from ring in batch. There are
Expand Down
29 changes: 22 additions & 7 deletions test/integration/join-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var testRingpopCluster = require('../lib/test-ringpop-cluster.js');
test('bootstrap with self is ok', function t(assert) {
var ringpop = allocRingpop();

ringpop.bootstrap([ringpop.hostPort], onBootstrap);
ringpop.bootstrap([ringpop.whoami()], onBootstrap);

function onBootstrap(err) {
assert.ifError(err);
Expand All @@ -40,7 +40,7 @@ testRingpopCluster({
size: 1,
waitForConvergence: false
}, 'one node can join', function t(bootRes, cluster, assert) {
assert.ifErr(bootRes[cluster[0].hostPort].err, 'no error occurred');
assert.ifErr(bootRes[cluster[0].whoami()].err, 'no error occurred');
assert.end();
});

Expand Down Expand Up @@ -74,11 +74,11 @@ testRingpopCluster({
}, 'three nodes, one of them bad, join size equals one', function t(bootRes, cluster, assert) {
assert.equal(cluster.length, 3, 'cluster of 3');

var badNode = cluster[2].hostPort;
var badNode = cluster[2].whoami();

cluster.forEach(function eachNode(node) {
assert.ok(node.isReady, 'node is ready');
var nodesJoined = bootRes[node.hostPort].nodesJoined;
var nodesJoined = bootRes[node.whoami()].nodesJoined;
assert.ok(nodesJoined.length >= 1, 'joined at least one other node');
assert.ok(nodesJoined.indexOf(badNode) === -1, 'no one can join bad node');
});
Expand All @@ -99,14 +99,29 @@ testRingpopCluster({

cluster.forEach(function eachNode(node) {
assert.notok(node.isReady, 'node is not ready');
assert.equal(bootRes[node.hostPort].err.type,
assert.equal(bootRes[node.whoami()].err.type,
'ringpop.join-duration-exceeded',
'join duration exceeded error');
});

assert.end();
});

testRingpopCluster({
// We disable gossip because we don't want to exhaust the changes through pings
autoGossip: false,
waitForConvergence: false
}, 'do not disseminate join list', function t(bootRes, cluster, assert) {
assert.plan(9);
cluster.forEach(function eachNode(node) {
assert.equal(node.dissemination.getChangesCount(), 1, 'only one change to be disseminated');
var change = node.dissemination.getChangeByAddress(node.whoami());
assert.ok(change, 'changes should contain this node\'s address');
assert.equal(change.address, node.whoami(), 'address matches');
});
assert.end();
});

testRingpopCluster({
size: 25
}, 'mega cluster', function t(bootRes, cluster, assert) {
Expand All @@ -129,7 +144,7 @@ testRingpopCluster({
res.headers.as = 'raw';
res.sendOk(null, JSON.stringify({
app: 'test',
coordinator: cluster[1].hostPort,
coordinator: cluster[1].whoami(),
membership: cluster[1].dissemination.fullSync()
}));
}, 100);
Expand All @@ -141,7 +156,7 @@ testRingpopCluster({

var slowJoiner = cluster[0];
assert.notok(slowJoiner.isReady, 'node one is not ready');
assert.equal(bootRes[slowJoiner.hostPort].err.type, 'ringpop.join-aborted',
assert.equal(bootRes[slowJoiner.whoami()].err.type, 'ringpop.join-aborted',
'join aborted error');

assert.ok(cluster[1].isReady, 'node two is ready');
Expand Down

0 comments on commit 286e5d9

Please sign in to comment.