JRaftKV is a KV-storage based on Raft Consensus Algorithm(CP) in Java.
Project implementation design and details refer to the paper.
- Leader election
- Log replication
- Membership changes
![JRaftKV architecture](.\doc\JraftKV achietecture.svg)
-
StateMachine: Log persistence module.
-
LogModule: Focus on maintaining log index.
-
Consensus: Including
RequestVotes
&AppendEntries
. -
A
NodeImpl
contains StateMachine, LogModule, Consensus modules. Default indentity is 'Follower'. Nodes communicate with each other through RPC module.
-
Start JRaftKV clusters with five nodes(
JRaftNodeApplication
). VM options:-DserverPort=8775 -DserverPort=8776 -DserverPort=8777 -DserverPort=8778 -DserverPort=8779
. -
Watch terminal operation log to check the Leader election process.
-
Candidate send
RequestVotes
and become Leader if it receives more than half of votes. -
Leader send
AppendEntries
empty package for heartbeat.
- Start JRaftKV clusters with five nodes(
JRaftNodeApplication
). VM options:-DserverPort=8775 -DserverPort=8776 -DserverPort=8777 -DserverPort=8778 -DserverPort=8779
. - Start Client and send request to leader or redirect to leader to handle it.
- Leader will replicate log to all of Followers eventually.