Java implementation of the raft protocol as described by the paper https://raft.github.io/raft.pdf
- Log replication
- Leader election
- Client API to submit log entries
- Embeddable into your distributed application
- Redirect to leader from follower/candidate
- Consistency check
mvn clean install
java -cp target/mjraft-1.0-SNAPSHOT.jar com.mj.distributed.peertopeer.server.PeerServer 5001
java -cp target/mjraft-1.0-SNAPSHOT.jar com.mj.distributed.peertopeer.server.PeerServer 5002 localhost:5001
java -cp target/mjraft-1.0-SNAPSHOT.jar com.mj.distributed.peertopeer.server.PeerServer 5003 localhost:5001
java -cp target/mjraft-1.0-SNAPSHOT.jar com.mj.raft.client.RaftClient localhost 5001
PeerServer leader = new PeerServer(5001);
leader.start() ;
String[] seeds = new String[1];
seeds[0] = "localhost:5001"; // can connect to any server
PeerServer server1 = new PeerServer(5002, seeds);
server1.start();
PeerServer server2 = new PeerServer(5003, seeds);
server2.start();
RaftClient raftClient = new RaftClient("localhost", 5001); // can connect to any server
raftClient.connect();
raftClient.send(23);
List<byte[]> serverValues = raftClient.get(0,1);