- Hugo BOIS
- Nathan CABASSO
- Jeremy CROISET
- Ferdinand MOM
- Erwan VIVIEN
Implementation of RAFT consensus algorithm in Rust. We followed the paper.
This is a school project for the course Algorep
at EPITA (School of Engineering and Computer Science).
To run the project, you need to have cargo
installed.
Then, you can run the project by running the following command in the root directory of the project: cargo run --release
.
You can interract with servers by using the following commands:
-
REPL <server_id> <command>
with<server_id>
in the range of [0; node_count - 1] and<command>
being one of the following:CRASH
: Crash the server (ignores messages)START
: Allows the clients to send messages to the serversSHUTDOWN
: Shutdown the server (stops the server, server is no longer reachable)RECOVERY
: Reload the data from the disk and remove volatile stateTIMEOUT
: Force the server to start an electionDISPLAY
: Display the state of the server
You can act as a client by using the following commands:
-
<command> [content]
with<command>
being one of the following:LOAD <filename>
: Creates a file in the storeGET <UID>
: Get the content of the file in the storeDELETE <UID>
: Delete the key-value pair associated with the keyAPPEND <key> [message]
: Append themessage
to the content of the file in the store with a new line
Note: The client does not automaticaly retry to send a message if it fails. You need to resend the message manually. This is the design we chose for the client.
The configuration file is a RON file (Rusty Object Notation) that can be found in the config
directory and is named config.ron
.
What can be configured is the following:
- node_count: the number of nodes(servers) in the cluster
- election_timeout: a range of
ConfigTime
enum (seeconfig.rs
for more details). This range is what is used by servers to generated a random timer. - client_count: the number of clients that will be spawned by the
main.rs
file
To run the tests, you need to have cargo
installed.
Then, you can run the tests by running the following command in the root directory of the project: cargo test
.
The following tests are implemented:
should_accept_vote
: Checks if a server accepts a vote request from another server if validshould_receive_election
: Checks that a server timeouts and starts an election in the beginning of the simulationshould_retry_election
: Checks that a server timeouts and starts an election. If we reply with anAppendEntries
message with a higher term, the first server should accept itshould_elect_first
: If two servers do not have the same election timeout, the first one to timeout should be electedsetup_server_client_no_recv
: Checks that a server can be setup and a client can be setup. If no interaction the client should not receive any messageclient_send_request
: Checks that a client can send a request to a server and that the server can receive itclient_server_should_receive_entry
: Checks that a client can append an entry to a server and an other server receives the entry followed by empty entries.should_timeout
: Checks that a server timeouts if it does not receive correct messages. e.g. if a server receives anAppendEntries
message with a lower term, it should not reset it's timershould_handle_append_entries
: Checks that a server can handle anAppendEntries
message and reply with the correct message. This is the end-to-end test. A client generates requests to create/modify fiels, the server replicates them and applies them to the state machine. After that, if a client GET a file, it should receive the correct value.