CapriWits / JRaftKV

Raft key-value instance in Java

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JRaftKV

JRaftKV is a KV-storage based on Raft Consensus Algorithm(CP) in Java.

Project implementation design and details refer to the paper.

Achievement

  • Leader election
  • Log replication
  • Membership changes

Architecture

![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.

Verification

Leader election

  1. Start JRaftKV clusters with five nodes(JRaftNodeApplication). VM options: -DserverPort=8775 -DserverPort=8776 -DserverPort=8777 -DserverPort=8778 -DserverPort=8779 .

  2. Watch terminal operation log to check the Leader election process.

  3. Candidate send RequestVotes and become Leader if it receives more than half of votes.

  4. Leader send AppendEntries empty package for heartbeat.

Log replication

  1. Start JRaftKV clusters with five nodes(JRaftNodeApplication). VM options: -DserverPort=8775 -DserverPort=8776 -DserverPort=8777 -DserverPort=8778 -DserverPort=8779 .
  2. Start Client and send request to leader or redirect to leader to handle it.
  3. Leader will replicate log to all of Followers eventually.

Reference

About

Raft key-value instance in Java

License:MIT License


Languages

Language:Java 100.0%