A Clojure library that implements the Raft distributed consensus algorithm.
Clojure
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
doc
src/raft
test/raft
.gitignore
.travis.yml
README.md
project.clj

README.md

raft-clj

A Clojure library that implements the Raft consensus algorithm.

See In Search of an Understandable Consensus Algorithm [PDF] by Diego Ongaro and John Ousterhout for more information.

This is a work in progress.

Build Status

It doesn't work yet. I'm happy to review pull requests and I am likely to accept those with passing tests and that have some style.

See doc/intro.md for some additional notes.

TODO

  • For demo

    • Add send command command

    • Add cluster config commands (add/remove nodes)

  • Implement configuration change mechanism (major missing capability)

  • More/better documentation

  • Use tools.trace rather than the ugly things I'm doing now in various places to log out what's happening (but still using tools.logging for output).

  • Refactor raft.leader and raft.log functions

    • Poorly documented

    • Overly long

Usage

Requires Leiningen.

You can run the demo with Leiningen:

$ lein run start

You can run the demo with multiple nodes:

$ lein run -- start -A tcp://localhost:2104 -X tcp://localhost:2105 tcp://localhost:2106 tcp://localhost:2108
$ lein run -- start -A tcp://localhost:2106 -X tcp://localhost:2107 tcp://localhost:2104 tcp://localhost:2108
$ lein run -- start -A tcp://localhost:2108 -X tcp://localhost:2109 tcp://localhost:2104 tcp://localhost:2106

You can send an :is-leader command to a node:

First start two nodes:

$ lein run -- start -A tcp://localhost:2104 -X tcp://localhost:2105 tcp://localhost:2106
$ lein run -- start -A tcp://localhost:2106 -X tcp://localhost:2107 tcp://localhost:2104

Then send the command:

$ lein run -- send tcp://localhost:2104 :is-leader

(Coming soon) You can send other commands to a node:

$ lein run -- send tcp://localhost:2105 my_command

You can see some information about command-line arguments:

$ lein run -- --help

You can run the test suite using Leiningen:

$ lein midje

License

Copyright © 2013-2014 John Weaver

Distributed under the Eclipse Public License, the same as Clojure.