mransan / raft Goto Github PK
View Code? Open in Web Editor NEWImplementation of the Raft protocol in OCaml
Implementation of the Raft protocol in OCaml
The data
in the LogEntry
is not enough. We should also add a client_id
field to map the index (which is internal to the RAFT protocol) back to a client identifier. This is necessary for a RAFT application to know which data was appended to the log after it was commited.
Add unit test for #19
Right now we have 3 distinct piece of date per follower in the leader state:
They could all be consolidated.
Logs can be stored permanently by the client application. This is needed in order to be able to handle a very large number of logs.
One possible design which would keep this library pure computation is to modify the LogInterval
type used in the global_cache
.
Current version
message LogInterval {
required int32 prev_index = 1;
required int32 prev_term = 2;
repeated LogEntry rev_log_entries = 3;
required int32 last_index = 4;
}
Proposition
message LogInterval {
required int32 prev_index = 1;
required int32 prev_term = 2;
required int32 last_index = 4;
message Compacted { }
message Expanded {
repeated LogEntry rev_log_entries = 1;
}
oneof data {
Compacted compacted = 5;
Expanded expanded = 6;
}
}
The client application would then be able to compact certain log interval. The major difficulty is in the recovery scenario (ie when a follower is lagging behind drastically). When computing the AppendEntries
request the leader will find out tha the logs have been compacted. One possible solution is to augment the interface with the application to indicate that loading the data should happen.
Leader.add_logs
Raft_logic.handle_append_entries_request
Raft_logic.Message.handle_message
and Raft_logic.Message.handle_timeout
should be able to return notification. For instance:
We can see now that commit_index > prev_log_index
https://github.com/mransan/raft/blob/master/src/raft_role.ml#L179
It's likely that this iteration would need to go into the global cache to find the last_log_index. Right now it's only looking at the state.log
Currently the LeaderState is a list of index. A subset of operations are querying this data structure by receiver id so it would make sense to use map
. So far we only have a very limited number of servers so not worth it.
This is a duplicate of the data and therefore harder to maintain in the long run. Duplication means bugs.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.