Schooner - lenary/cs4414-project GitHub Wiki
It's worth reading Raft before reading this document. Also, the Glossary will help you with the specific meanings of certain words.
What Schooner Does Implement
Schooner implements:
- The Raft Algorithm (including leader election)
- The Peer-to-peer communication, including listeners and connections
- The Consistent Log
What Schooner Doesn't Implement
Schooner does not implement:
- The Application's Replicated State Machine.
- The Network endpoint that accepts Client Commands
How Schooner Is Put Together
Schooner works in a few isolated tasks (and sets of tasks):
- The Main Raft Task - implements the state machine of Raft Roles, and uses callbacks to carry out
- The Peer Manager Task - a task that manages the Peer tasks, and the Peer Listener, so that there's always one task per Peer, and they're always connected (within reason). The main raft task submits messages that are to be sent to the manager, which proxies them out to the peer tasks.
- The Peer Listener Task - a task to manage the network listener that accepts connections from other Peers, and correlates them with other Peer tasks.
- The Peer Tasks - one per peer, this is supposed to maintain the connection to a single other peer, and translate requests and responses so they can be sent over the network to and from that peer. Peer tasks have a sender so they can send recieved events to the Main Raft task.
There is a diagram in server.rs
, but this doesn't accurately portray
the seperate Peer tasks, Peer manager, or Peer listener - instead it
conflates them into a single entity.
How Schooner Integrates with An Application
The application task is spawned, passing a Receiver which
the Main Raft Task will send ClientCmdReq
(and their corresponding
Sender<ClientCmdRes>
) down. The application state machine should
loop in the task, waiting for these commands, executing them and
returning the results down the sender it was given. It should block
for as little time as possible.
The application endpoint will also be provided a
Sender<ClientCmdReq>
so that it can send Client Commands into the
Main Raft task for confirmation and submission to the Replicated State
Machine.
All the rest is handled by Schooner, though the application may want to specify which peers that Schooner considers members of the cluster - this can be done at startup.