Struct openraft::MembershipState
source · pub struct MembershipState<NID, N>{ /* private fields */ }
Expand description
The state of membership configs a raft node needs to know.
A raft node needs to store at most 2 membership config log:
- The first(committed) one must have been committed, because (1): raft allows to propose new membership only when the previous one is committed.
- The second(effective) may be committed or not.
From (1) we have: (2) there is at most one outstanding, uncommitted membership log. On either leader or follower, the second last one must have been committed. A committed log must be consistent with the leader.
(3) By raft design, the last membership takes effect.
When handling append-entries RPC: (4) a raft follower will delete logs that are inconsistent with the leader.
From (3) and (4), a follower needs to revert the effective membership to the previous one.
From (2), a follower only need to revert at most one membership log.
Thus a raft node will only need to store at most two recent membership logs.
Implementations§
source§impl<NID, N> MembershipState<NID, N>
impl<NID, N> MembershipState<NID, N>
sourcepub fn committed(&self) -> &Arc<EffectiveMembership<NID, N>>
pub fn committed(&self) -> &Arc<EffectiveMembership<NID, N>>
Returns a reference to the last committed membership config.
A committed membership config may or may not be the same as the effective one.
sourcepub fn effective(&self) -> &Arc<EffectiveMembership<NID, N>>
pub fn effective(&self) -> &Arc<EffectiveMembership<NID, N>>
Returns a reference to the presently effective membership config.
In openraft the last seen membership config, whether committed or not, is the effective one.
A committed membership config may or may not be the same as the effective one.
Trait Implementations§
source§impl<NID, N> Clone for MembershipState<NID, N>
impl<NID, N> Clone for MembershipState<NID, N>
source§fn clone(&self) -> MembershipState<NID, N>
fn clone(&self) -> MembershipState<NID, N>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<NID, N> Debug for MembershipState<NID, N>
impl<NID, N> Debug for MembershipState<NID, N>
source§impl<NID, N> Default for MembershipState<NID, N>
impl<NID, N> Default for MembershipState<NID, N>
source§fn default() -> MembershipState<NID, N>
fn default() -> MembershipState<NID, N>
source§impl<NID, N> MessageSummary<MembershipState<NID, N>> for MembershipState<NID, N>
impl<NID, N> MessageSummary<MembershipState<NID, N>> for MembershipState<NID, N>
source§impl<NID, N> PartialEq for MembershipState<NID, N>
impl<NID, N> PartialEq for MembershipState<NID, N>
source§fn eq(&self, other: &MembershipState<NID, N>) -> bool
fn eq(&self, other: &MembershipState<NID, N>) -> bool
self
and other
values to be equal, and is used
by ==
.