Struct garage_rpc::layout::ClusterLayout
source · pub struct ClusterLayout {
pub version: u64,
pub replication_factor: usize,
pub roles: LwwMap<Uuid, NodeRoleV>,
pub node_id_vec: Vec<Uuid>,
pub ring_assignation_data: Vec<CompactNodeType>,
pub staging: LwwMap<Uuid, NodeRoleV>,
pub staging_hash: Hash,
}
Expand description
The layout of the cluster, i.e. the list of roles which are assigned to each cluster node
Fields§
§version: u64
§replication_factor: usize
§roles: LwwMap<Uuid, NodeRoleV>
§node_id_vec: Vec<Uuid>
node_id_vec: a vector of node IDs with a role assigned
in the system (this includes gateway nodes).
The order here is different than the vec stored by roles
, because:
- non-gateway nodes are first so that they have lower numbers
- nodes that don’t have a role are excluded (but they need to stay in the CRDT as tombstones)
ring_assignation_data: Vec<CompactNodeType>
the assignation of data partitions to node, the values are indices in node_id_vec
staging: LwwMap<Uuid, NodeRoleV>
Role changes which are staged for the next version of the layout
staging_hash: Hash
Implementations§
source§impl ClusterLayout
impl ClusterLayout
pub fn new(replication_factor: usize) -> Self
pub fn merge(&mut self, other: &ClusterLayout) -> bool
pub fn apply_staged_changes(self, version: Option<u64>) -> Result<Self, Error>
pub fn revert_staged_changes(self, version: Option<u64>) -> Result<Self, Error>
sourcepub fn node_ids(&self) -> &[Uuid]
pub fn node_ids(&self) -> &[Uuid]
Returns a list of IDs of nodes that currently have a role in the cluster
pub fn num_nodes(&self) -> usize
sourcepub fn node_role(&self, node: &Uuid) -> Option<&NodeRole>
pub fn node_role(&self, node: &Uuid) -> Option<&NodeRole>
Returns the role of a node in the layout
sourcepub fn check(&self) -> bool
pub fn check(&self) -> bool
Check a cluster layout for internal consistency returns true if consistent, false if error
sourcepub fn calculate_partition_assignation(&mut self) -> bool
pub fn calculate_partition_assignation(&mut self) -> bool
Calculate an assignation of partitions to nodes
Trait Implementations§
source§impl Clone for ClusterLayout
impl Clone for ClusterLayout
source§fn clone(&self) -> ClusterLayout
fn clone(&self) -> ClusterLayout
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for ClusterLayout
impl Debug for ClusterLayout
source§impl<'de> Deserialize<'de> for ClusterLayout
impl<'de> Deserialize<'de> for ClusterLayout
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more