- Timer: Callback-Timer
- RPC: Third-Party library buttonrpc
- State Machine: Key-Value DataBase
- Leader election
- Replication and recovery
- Snapshot and log compaction.
- Follower tell its expect next log rather than try.
- design multi-thread architecture to accelerate
RquestVote
andAppendEntries
- set
log_increment
variable and binary search to optimizematchIndex
updating. - use copy-on-write technique (fork in Linux) for snapshot.
- cmake
- make
./make.sh
if you want to remove log and other temp file and build
./clearmake.sh
or just want to remove log and other temp file
./rmtemp.sh
bin/kvRaft/kvRaft [id] #e.g. bin/kvRaft/kvRaft 1
then you will see configure steps and run.
---- Configuring...
- server connection done.
- term&vote_for done.
- snapshot warning: no snapshot found.
- logs done.
---- Configuring done!
candidate[2] is calling request_vote, term[1], last_log-term[0]-index[0]
In Raft class, there are three virtual method, just inherit Raft class and override these to make your Distributed System.
class Raft {
virtual void apply(const string& command); //apply command to state machine.
virtual void install_snapshot(const string& filename); //install snapshot to file.
virtual void load_snapshot(const string& filename); //load snapshot from file.
}
architecture and more implementation description see in Wiki
- feature: member change.
- snapshot:
- leader must occasionally send snapshots to followers that lag behind
- let follower rather leader create snapshot send to other .