Skip to content
/ trabica Public

Raft Consensus Algorithm implementation in Scala

License

Notifications You must be signed in to change notification settings

hkarim/trabica

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Trabica

Raft Consensus Algorithm implementation in Scala. This is pretty much still Work in progress.

Modules

Implemented features:

  • Leader election
  • Log replication (pluggable with a sample implementation)
  • Persistence (pluggable with a sample implementation)
  • Membership changes

A sample node initialization and a persistent log store is under opt/node-template

There are several modules currently implemented under the mod directory:

  • lib-trabica-model Data models for node states and auxiliary data
  • lib-trabica-net Abstraction for client and server networking
  • lib-trabica-node Core Raft implementation
  • lib-trabica-proto Protobuf model of client and server messages
  • lib-trabica-rpc Protobuf service specification, along client and server endpoint factories
  • lib-trabica-store Abstraction for pluggable Log store, a sample implementation is under opt/node-template

The code uses cats-effect and fs2 extensively.

Building

It is possible to build both a JVM and a native application. From SBT prompt run project node-template, then:

  • stage for a JVM build, or
  • native for a native image build

Running

Several shell scripts can be found under bin to start and experiment with a cluster, if you are initializing a new cluster, start with bin/bootstrap-00.sh. This will start a new cluster with a fresh log store, and expects 2 other nodes to join. bin/node-{n}.sh will start instances of the node in follower mode, where n is the node id.

To test membership changes, see the scripts under etc. Those scripts use grpcurl to send gRPC requests.

Configuration of election and RPC timeouts is under mod/lib-trabica-node/src/main/resources/reference.conf, which you can override in opt/node-template/src/main/resources/application.conf

If you start the example node with the default scripts under bin, logs are written under var/{n} directory, where n is the node id.

Notes

  • The store implementation is just an example, a more robust store is needed in production situations
  • A call to RemoveServer will aggressively send a termination signal to this server if removal was successful, which will terminate the node process
  • Delivering (applying) messages to the FSM is not implemented yet

License

MIT

About

Raft Consensus Algorithm implementation in Scala

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published