Table of Contents
An implementation of the raft consensus algorithm that includes:
- Leader Election
- Log replication
- Simple Client for testing
First you will need to install the dependencies in the requirements.txt file by running the following command in your terminal.
pip install -r requirements.txt
Then run the following code in the terminal
python3 -m grpc_tools.protoc raft.proto --proto_path=. --python_out=. --grpc_python_out=.
For testing you need to update the Config.conf
file with the desired server addresses and ports.
It follows the following schema: [id] [address] [port]
Then you can run multiple servers in different terminals, for example:
gnome-terminal --window -x python3 client.py & gnome-terminal --window -x python3 server.py 0 & gnome-terminal --window -x python3 server.py 1 & gnome-terminal --window -x python3 server.py 2
This command will run the client and 3 servers with ids 0, 1, 2. in different terminal windows.
Then you can use the client terminal to run commands such as: [getleader, suspend, quit, getval, setval]
Where:
getleader
: returns the current leader id and address
suspend
: takes one integer as an argument and suspends a server for that amount of time (in seconds)
quit
: terminates the client
getval
: takes one string as an argument and returns the value of the key with that key
setval
: takes a string and an integer as arguments and sets the value of the first key to the second value
Distributed under the MIT License. See LICENSE.txt
for more information.
Mosab Mohamed - @IVIosab - [email protected]
Project Link: https://github.com/IVIosab/raft