Skip to content

rascio/zattera

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Zattera

Build

I'm too lazy to find a better name, so it is just a translation

What is it?

A "bad" implementation of a raft consensus algorithm, just for fun.

Testing

scripts/ folder contains scripts to start nodes/cluster and clients:

  • start-node.sh: Starts a node with the given parameters, support a simple counter and a KV store
  • kv-shell.sh: CLI to interact with the KV store

both support -h to show the help message.

KV store example usage

Start cluster nodes

./scripts/start-node.sh -id 1 -cluster-size 3 -kv

-id can be any number, but it must be unique in the cluster. -cluster-size make the node aware of the first N nodes in the cluster.

Start the KV store CLI

./scripts/kv-shell.sh

Type help to see the available commands

Interact with Server

Read the log

curl http://localhost:8081/entries

Register a new node to the cluster

This needs to be done before starting it

curl -v http://localhost:8081/raft/request -d '{"type":"io.r.raft.protocol.LogEntry.ConfigurationChange","new":[{"id":"N4","host":"localhost","port":8084}]}' -H 'Content-Type: application/json'

and then

./scripts/start-node.sh -id 4 -cluster-size 3 -kv

Debug

RaftMachine Logs

# Get logs for a single node
cat .logs/test-logs.out| grep -E "NodeId=T1" | pbcopy

RaftMachineTest

# Get Raft log dumps
cat .logs/test-logs.out | ggrep -oPz "(?s)Dump_log.*?End_Dump\s" | pbcopy
# Entries applied to state machine (replace T1 with actual node id)
cat .logs/test-logs.out| grep -E "NodeId=T1 \| _event=\"(Applied|Set-A)" | pbcopy

About

(bad) Raft protocol implementation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published