Struct openraft::Membership
source · pub struct Membership<NID, N>where
N: Node,
NID: NodeId,{ /* private fields */ }
Expand description
The membership configuration of the cluster.
It could be a joint of one, two or more configs, i.e., a quorum is a node set that is superset of a majority of every config.
Implementations§
source§impl<NID, N> Membership<NID, N>where
N: Node,
NID: NodeId,
impl<NID, N> Membership<NID, N>where N: Node, NID: NodeId,
sourcepub fn new<T>(config: Vec<BTreeSet<NID>>, nodes: T) -> Selfwhere
T: IntoNodes<NID, N>,
pub fn new<T>(config: Vec<BTreeSet<NID>>, nodes: T) -> Selfwhere T: IntoNodes<NID, N>,
Create a new Membership from a joint config of voter-ids and a collection of all
Node
(voter nodes and learner nodes).
A node id that is in nodes
but is not in config
is a learner.
A node presents in config
but not in nodes
is filled with default value.
The nodes
can be:
- a simple
()
, if there are no learner nodes, BTreeSet<NodeId>
provides learner node ids whoseNode
data areNode::default()
,BTreeMap<NodeId, Node>
provides nodes for every node id. Node ids that are not inconfigs
are learners.
sourcepub fn is_in_joint_consensus(&self) -> bool
pub fn is_in_joint_consensus(&self) -> bool
Check to see if the config is currently in joint consensus.
source§impl<NID, N> Membership<NID, N>where
N: Node,
NID: NodeId,
impl<NID, N> Membership<NID, N>where N: Node, NID: NodeId,
Membership API
sourcepub fn voter_ids(&self) -> impl Iterator<Item = NID>
pub fn voter_ids(&self) -> impl Iterator<Item = NID>
Returns an Iterator of all voter node ids. Learners are not included.
sourcepub fn learner_ids(&self) -> impl Iterator<Item = NID> + '_
pub fn learner_ids(&self) -> impl Iterator<Item = NID> + '_
Returns an Iterator of all learner node ids. Voters are not included.
sourcepub fn nodes(&self) -> impl Iterator<Item = (&NID, &N)>
pub fn nodes(&self) -> impl Iterator<Item = (&NID, &N)>
Returns an Iterator of all nodes(voters and learners).
sourcepub fn get_node(&self, node_id: &NID) -> Option<&N>
pub fn get_node(&self, node_id: &NID) -> Option<&N>
Get a the node(either voter or learner) by node id.
sourcepub fn get_joint_config(&self) -> &Vec<BTreeSet<NID>>
pub fn get_joint_config(&self) -> &Vec<BTreeSet<NID>>
Returns reference to the joint config.
Membership is defined by a joint of multiple configs. Each config is a vec of node-id.
Trait Implementations§
source§impl<NID, N> Clone for Membership<NID, N>where
N: Node + Clone,
NID: NodeId + Clone,
impl<NID, N> Clone for Membership<NID, N>where N: Node + Clone, NID: NodeId + Clone,
source§fn clone(&self) -> Membership<NID, N>
fn clone(&self) -> Membership<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> Default for Membership<NID, N>where
N: Node + Default,
NID: NodeId + Default,
impl<NID, N> Default for Membership<NID, N>where N: Node + Default, NID: NodeId + Default,
source§fn default() -> Membership<NID, N>
fn default() -> Membership<NID, N>
source§impl<NID, N> From<BTreeMap<NID, N, Global>> for Membership<NID, N>where
N: Node,
NID: NodeId,
impl<NID, N> From<BTreeMap<NID, N, Global>> for Membership<NID, N>where N: Node, NID: NodeId,
source§impl<NID, N> MessageSummary<Membership<NID, N>> for Membership<NID, N>where
N: Node,
NID: NodeId,
impl<NID, N> MessageSummary<Membership<NID, N>> for Membership<NID, N>where N: Node, NID: NodeId,
source§impl<NID, N> PartialEq<Membership<NID, N>> for Membership<NID, N>where
N: Node + PartialEq,
NID: NodeId + PartialEq,
impl<NID, N> PartialEq<Membership<NID, N>> for Membership<NID, N>where N: Node + PartialEq, NID: NodeId + PartialEq,
source§fn eq(&self, other: &Membership<NID, N>) -> bool
fn eq(&self, other: &Membership<NID, N>) -> bool
self
and other
values to be equal, and is used
by ==
.impl<NID, N> Eq for Membership<NID, N>where N: Node + Eq, NID: NodeId + Eq,
impl<NID, N> StructuralEq for Membership<NID, N>where N: Node, NID: NodeId,
impl<NID, N> StructuralPartialEq for Membership<NID, N>where N: Node, NID: NodeId,
Auto Trait Implementations§
impl<NID, N> RefUnwindSafe for Membership<NID, N>where N: RefUnwindSafe, NID: RefUnwindSafe,
impl<NID, N> Send for Membership<NID, N>
impl<NID, N> Sync for Membership<NID, N>
impl<NID, N> Unpin for Membership<NID, N>
impl<NID, N> UnwindSafe for Membership<NID, N>where N: RefUnwindSafe, NID: RefUnwindSafe,
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.