Distribute key-value system, Base on Raft protocol and in memory storage, still developing
- Election function
- Add/Remove cluster node dynamically
- Log synchronize
- Backup data
- Clone this project to your idea
- Build and run
then start the first node:
mvn clean package
start the second node:port=8000 java -jar target/kvs.jar
start the third node:port=8001 java -jar target/kvs.jar
port=8002 java -jar target/kvs.jar
- After elected, shutdown the follower node, cluster will work nominally
- After elected, shutdown the leader node, cluster will reelect successfully
- Bootstrap node1, node2 and node3 manually
- Find the test case class AppTest.java
- Run method addPeer1And2() notify node1 and node2 each other
- Run method addPeer3() notify node2 to add a peer node3, so node2 will be leader theoretically
- Congratulations, you already learned how to add a peer to a cluster
- Run method removePeer1() remove peer the cluster leader will notify the followers to remove this node, and node3 will power off atomically, at the same time, the cluster keep working properly
- Enjoy, you can try to edit the nodes which one you want to add and remove dynamically!