Permalink
Browse files

[test] cleanup

  • Loading branch information...
1 parent a71f592 commit 3a2216c3017318c4c8fa21cce5f6ffd879c9fadf @0x00A committed Oct 31, 2012
View
@@ -1,5 +1,4 @@
-
# What are distributed systems
A collection of independent processes running on an any computers running
@@ -16,7 +15,7 @@ structures in order to support heterogeneous computers and networks.
distributed across multiple computers.
-# What is the gossip protocol
+# What is the Gossip Protocol
The gossip protocol helps to manage inconsistencies due to partition loss and
process failure in a distributed system.
@@ -33,7 +32,7 @@ process failure in a distributed system.
## Assumptions
- Each peer has membership. In this protocol, the knowledge of membership is
-distributed to each member at a regular interval.
+distributed to each member at a regular interval.
## Considerations
@@ -42,14 +41,55 @@ Convergence rate is the randomization algorithm combind with the frequency
at which it is applied. Gossip protocols can be adapted to tolerate process
crashes by adjusting the convergence rate.
-# Reference Papers and Articles
+# What is the Quorum Consensus Protocol
+TODO
+
+## Charactarizations
+TODO
+
+## Assumptions
+TODO
+
+## Considerations
+TODO
+
+# Research Papers
+TODO
[How robust are gossip-based communication protocols?][0]
[An Efficient Implementation of the Quorum Consensus Protocol][1]
[Distributed systems principles and paradigms 2nd edition][2]
+
+# Architectural Design
+TODO
+
+# Usage
+TODO
+
+A computer at `192.168.0.2`
+
+```js
+ var vine = Vine()
+
+ vine
+ .listen(8000)
+ .set('foo', 'hello, world')
+```
+
+A computer at `192.168.0.3`
+
+```js
+ var vine = Vine()
+
+ vine
+ .listen(8000)
+ .join(8000, '192.168.0.2')
+ .on('data', 'foo')
+```
+
[0]:http://www.cs.utexas.edu/~lorenzo/papers/p14-alvisi.pdf
[1]:http://citeseerx.ist.psu.edu/viewdoc/download;jsessionid=5A7801DAF5FBEDD7D15599DEA8AA2677?doi=10.1.1.34.9524&rep=rep1&type=pdf
[2]:http://net.pku.edu.cn/~course/cs501/2011/resource/2006-Book-distributed%20systems%20principles%20and%20paradigms%202nd%20edition.pdf
View
18 Vine.js
@@ -375,7 +375,13 @@ Vine.prototype.vote = function(topic, value) {
if (result.closed) {
- var event = result.expired ? 'deadline' : 'quorum';
+ var event = result.expired ? 'expire' : 'quorum';
+
+ //
+ // TODO: workflow does not end here. need to contact the
+ // origin; the election must still be open, if it is,
+ // close it, if we can do this then we can emit quorum.
+ //
return this.emit(
event,
@@ -439,20 +445,14 @@ Vine.prototype.listen = function(port, address) {
return this;
};
-//
-// be done.
-//
-Vine.prototype.clear = function() {
+Vine.prototype.close = function() {
+
clearInterval(this.heartbeatInterval);
clearInterval(this.listInterval);
clearInterval(this.hashInterval);
clearTimers();
-};
-Vine.prototype.close = function() {
-
- this.clear();
this.server.close();
return this;
View
@@ -46,16 +46,16 @@ BallotBox.prototype.vote = function(uuid, topic, data) {
return election;
}
- if (election.deadline) {
+ if (election.expire) {
var now = new Date(Date.now());
- var deadline = new Date(election.deadline);
+ var expire = new Date(election.expire);
- if (now > deadline) {
+ if (now > expire) {
//
// if the current date/time is greater than the
- // deadline, this is an automatic win for aborting.
+ // expire, this is an automatic win for aborting.
//
election.result = null;
election.closed = true;
@@ -211,7 +211,7 @@ BallotBox.prototype.decide = function(uuid, topic) {
//
// @@total {Number} the total number of systems known
// @@min {Number} minimum votes needed to satisfy an election
-// @@deadline {String} represents a serialized future date
+// @@expire {String} represents a serialized future date
//
BallotBox.prototype.election = function(opts) {
@@ -234,7 +234,7 @@ BallotBox.prototype.election = function(opts) {
total: opts.total || null,
ctime: String(new Date(Date.now())),
- deadline: opts.deadline || null,
+ expire: opts.expire || null,
expired: false,
votes: {},
No changes.
File renamed without changes.
@@ -14,9 +14,9 @@ module.exports = {
var now = new Date(Date.now())
- var election1 = {
+ var electionCriteria = {
topic: 'a',
- deadline: String(new Date(now.setMinutes(now.getMinutes() + 1))),
+ expire: String(new Date(now.setMinutes(now.getMinutes() + 1))),
min: 2, // in the real world, this would be a percentage of the total
total: 3 // in the real world, this would be discovered dynamically
}
@@ -36,19 +36,21 @@ module.exports = {
vine1 = Vine()
.listen(8005)
- .election(election1)
+ .election(electionCriteria)
.on('quorum', onQuorum)
;
vine2 = Vine()
.listen(8006)
.join(8005)
+ .election(electionCriteria)
.on('quorum', onQuorum)
;
vine3 = Vine()
.listen(8007)
.join(8005)
+ .election(electionCriteria)
.on('quorum', onQuorum)
;
@@ -57,18 +59,18 @@ module.exports = {
setTimeout(function() { vine3.vote('a', true) }, 300)
},
- "An election exceeding its deadline should never reach quorum": function(test) {
+ "An expired election should never reach quorum": function(test) {
test.plan(1)
var vines = {}
- var dead = false;
+ var expired = false
var now = new Date(Date.now())
- var election1 = {
+ var electionCriteria = {
topic: 'b',
- deadline: 60,
+ expire: 60,
min: Math.floor(Object.keys(vines).length/1.5),
total: Object.keys(vines).length
}
@@ -82,12 +84,12 @@ module.exports = {
}
}
- var onDeadline = function(key, data) {
+ var onExpire = function(key, data) {
- if (key === 'b' && dead === false) {
+ if (key === 'b' && expired === false) {
- dead = true;
- test.equal(key, 'b', 'Should emit the deadline event only once')
+ expired = true;
+ test.equal(key, 'b', 'Should emit the expire event')
//
// close all of the open servers
@@ -100,36 +102,36 @@ module.exports = {
vines.vine1 = Vine()
.listen(8008)
- .election(election1)
- .on('deadline', onDeadline)
+ .election(electionCriteria)
+ .on('expire', onExpire)
.on('quorum', onQuorum)
;
vines.vine2 = Vine()
.listen(8009)
.join(8008)
- .on('deadline', onDeadline)
+ .on('expire', onExpire)
.on('quorum', onQuorum)
;
vines.vine3 = Vine()
.listen(8010)
.join(8008)
- .on('deadline', onDeadline)
+ .on('expire', onExpire)
.on('quorum', onQuorum)
;
vines.vine4 = Vine()
.listen(8011)
.join(8009)
- .on('deadline', onDeadline)
+ .on('expire', onExpire)
.on('quorum', onQuorum)
;
vines.vine5 = Vine()
.listen(8012)
.join(8009)
- .on('deadline', onDeadline)
+ .on('expire', onExpire)
.on('quorum', onQuorum)
;

0 comments on commit 3a2216c

Please sign in to comment.