pub struct MultiPaxosReplica<V: Clone + Ord, L: VolatileLink<Carried<V>> = SessionLink<Carried<V>>> { /* private fields */ }Expand description
A totally ordered log, built on Multi-Paxos: one consensus per slot, under a stable leader that keeps phase one across all of them.
Implementations§
Source§impl<V: Clone + Ord> MultiPaxosReplica<V>
impl<V: Clone + Ord> MultiPaxosReplica<V>
Sourcepub fn new(
me: NodeId,
peers: impl IntoIterator<Item = NodeId>,
timing: Timing,
) -> Self
pub fn new( me: NodeId, peers: impl IntoIterator<Item = NodeId>, timing: Timing, ) -> Self
A replica among peers, over the session link the Synod protocol defaults to.
The re-proposal threshold is derived rather than passed: it must exceed the time a decision
legitimately takes, whose worst case is a leadership change — detect_after for Ω to move,
then phase one, then phase two. detect_after * 3 clears that with room, and it is far below
what filling a WINDOW of eight slots would take.
Sourcepub fn with_window(self, window: Slot) -> Self
pub fn with_window(self, window: Slot) -> Self
The window, for a test that needs to fill one without driving a hundred slots.
Sourcepub fn with_repropose_after(self, after: Duration) -> Self
pub fn with_repropose_after(self, after: Duration) -> Self
The re-proposal threshold, for a test that needs to reach it inside a settle window.
Sourcepub fn with_retain(self, retain: Slot) -> Self
pub fn with_retain(self, retain: Slot) -> Self
The retention window, for a test that needs to fill one without deciding sixty-four slots.
Source§impl<V: Clone + Ord, L: VolatileLink<Carried<V>>> MultiPaxosReplica<V, L>
impl<V: Clone + Ord, L: VolatileLink<Carried<V>>> MultiPaxosReplica<V, L>
Sourcepub fn entries(&self) -> impl Iterator<Item = &V>
pub fn entries(&self) -> impl Iterator<Item = &V>
The ordered sequence as this process holds it.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
How many commands this process has applied — the next [Position], as a count.
pub fn is_empty(&self) -> bool
Sourcepub fn slot_out(&self) -> Slot
pub fn slot_out(&self) -> Slot
slot_out: the next slot to apply. Diverges from MultiPaxosReplica::len by exactly the
number of commands decided in more than one slot.
Sourcepub fn slot_in(&self) -> Slot
pub fn slot_in(&self) -> Slot
slot_in: the next slot to propose for. R5 keeps it below slot_out + WINDOW.
Sourcepub fn outstanding(&self) -> usize
pub fn outstanding(&self) -> usize
How many slots this replica has proposed for and not yet applied.
Sourcepub fn proposed_slots(&self) -> impl Iterator<Item = Slot> + '_
pub fn proposed_slots(&self) -> impl Iterator<Item = Slot> + '_
The slots this replica has proposed for and not yet applied. R5’s substantive form is
asserted over these — see the module’s note on where the page’s < reads as ≤.
Sourcepub fn decisions_held(&self) -> usize
pub fn decisions_held(&self) -> usize
How many decisions this replica holds. Grows with commands handled, and is never collected —
the measurement docs/bounded-space.md wants of a transcription.
Sourcepub fn decision(&self, slot: Slot) -> Option<&Command<V>>
pub fn decision(&self, slot: Slot) -> Option<&Command<V>>
The command decided for slot, if this replica has heard.
Sourcepub fn reported_slot_out(&self) -> Slot
pub fn reported_slot_out(&self) -> Slot
How far this replica has told the consensus beneath it that it has applied.
Trait Implementations§
Source§impl<V: Debug + Clone + Ord, L: Debug + VolatileLink<Carried<V>>> Debug for MultiPaxosReplica<V, L>
impl<V: Debug + Clone + Ord, L: Debug + VolatileLink<Carried<V>>> Debug for MultiPaxosReplica<V, L>
Source§impl<V: Clone + Ord, L: VolatileLink<Carried<V>>> Protocol for MultiPaxosReplica<V, L>
impl<V: Clone + Ord, L: VolatileLink<Carried<V>>> Protocol for MultiPaxosReplica<V, L>
Source§type Msg = <MultiPaxosSynod<Command<V>, L> as Protocol>::Msg
type Msg = <MultiPaxosSynod<Command<V>, L> as Protocol>::Msg
The child’s. This layer adds no per-hop state, so it adds no wire field.
Source§type Scope = <MultiPaxosSynod<Command<V>, L> as Protocol>::Scope
type Scope = <MultiPaxosSynod<Command<V>, L> as Protocol>::Scope
Whatever the link beneath the child is conditional on. This layer bridges none of it.
Source§type Meta = Infallible
type Meta = Infallible
Keeps nothing durably, which is what makes the crash-stop boundary in the module documentation the one that applies. §4.3 is the change that alters it.
Source§fn on_timer(&mut self, id: TimerId, cx: &mut ProtoCx<'_, Self>)
fn on_timer(&mut self, id: TimerId, cx: &mut ProtoCx<'_, Self>)
An expiry is offered to every layer, so the child is given it and this layer acts only on the handle it registered itself.
Source§fn on_init(&mut self, cx: &mut ProtoCx<'_, Self>)
fn on_init(&mut self, cx: &mut ProtoCx<'_, Self>)
⟨ Init ⟩ — arm the sweep, and start the child, whose own on_init starts the leader
detector. A protocol is owed exactly one of on_init and on_recovery before its first
event, and the detector beneath is the one that has gone without twice.
Source§fn on_scope_event(&mut self, scope: Self::Scope, cx: &mut ProtoCx<'_, Self>)
fn on_scope_event(&mut self, scope: Self::Scope, cx: &mut ProtoCx<'_, Self>)
Hand the boundary to the child, which knows what it means. Leaving it to the trait’s default would take a scope event the driver raised and drop it.
Source§type Entry = Infallible
type Entry = Infallible
Source§fn on_cmd(&mut self, cmd: Cmd<V>, cx: &mut ProtoCx<'_, Self>)
fn on_cmd(&mut self, cmd: Cmd<V>, cx: &mut ProtoCx<'_, Self>)
Source§fn on_msg(&mut self, from: NodeId, msg: Self::Msg, cx: &mut ProtoCx<'_, Self>)
fn on_msg(&mut self, from: NodeId, msg: Self::Msg, cx: &mut ProtoCx<'_, Self>)
from.