Struct garage_rpc::layout::LayoutVersion
source · pub struct LayoutVersion {
pub version: u64,
pub roles: LwwMap<Uuid, NodeRoleV>,
pub parameters: LayoutParameters,
pub replication_factor: usize,
pub partition_size: u64,
pub node_id_vec: Vec<Uuid>,
pub nongateway_node_count: usize,
pub ring_assignment_data: Vec<CompactNodeType>,
}
Expand description
A version of the layout of the cluster, i.e. the list of roles which are assigned to each cluster node
Fields§
§version: u64
The number of this version
roles: LwwMap<Uuid, NodeRoleV>
Roles assigned to nodes in this version
parameters: LayoutParameters
Parameters used to compute the assignment currently given by ring_assignment_data
replication_factor: usize
The number of replicas for each data partition
partition_size: u64
This attribute is only used to retain the previously computed partition size, to know to what extent does it change with the layout update.
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)
nongateway_node_count: usize
number of non-gateway nodes, which are the first ids in node_id_vec
ring_assignment_data: Vec<CompactNodeType>
The assignation of data partitions to nodes, the values are indices in node_id_vec
Implementations§
source§impl LayoutVersion
impl LayoutVersion
pub fn new(replication_factor: usize) -> Self
sourcepub fn all_nodes(&self) -> &[Uuid]
pub fn all_nodes(&self) -> &[Uuid]
Returns a list of IDs of nodes that have a role in this version of the cluster layout, including gateway nodes
sourcepub fn nongateway_nodes(&self) -> &[Uuid]
pub fn nongateway_nodes(&self) -> &[Uuid]
Returns a list of IDs of nodes that have a storage capacity assigned in this version of the cluster layout
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, if it has one
sourcepub fn get_node_capacity(&self, uuid: &Uuid) -> Option<u64>
pub fn get_node_capacity(&self, uuid: &Uuid) -> Option<u64>
Returns the capacity of a node in the layout, if it has one
sourcepub fn get_node_zone(&self, uuid: &Uuid) -> Option<&str>
pub fn get_node_zone(&self, uuid: &Uuid) -> Option<&str>
Given a node uuids, this function returns the label of its zone if it has one
sourcepub fn get_node_usage(&self, uuid: &Uuid) -> Result<usize, Error>
pub fn get_node_usage(&self, uuid: &Uuid) -> Result<usize, Error>
Returns the number of partitions associated to this node in the ring
sourcepub fn partition_of(&self, position: &Hash) -> Partition
pub fn partition_of(&self, position: &Hash) -> Partition
Get the partition in which data would fall on
sourcepub fn partitions(&self) -> impl Iterator<Item = (Partition, Hash)> + '_
pub fn partitions(&self) -> impl Iterator<Item = (Partition, Hash)> + '_
Get the list of partitions and the first hash of a partition key that would fall in it
Trait Implementations§
source§impl Clone for LayoutVersion
impl Clone for LayoutVersion
source§fn clone(&self) -> LayoutVersion
fn clone(&self) -> LayoutVersion
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for LayoutVersion
impl Debug for LayoutVersion
source§impl<'de> Deserialize<'de> for LayoutVersion
impl<'de> Deserialize<'de> for LayoutVersion
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>,
source§impl PartialEq for LayoutVersion
impl PartialEq for LayoutVersion
source§fn eq(&self, other: &LayoutVersion) -> bool
fn eq(&self, other: &LayoutVersion) -> bool
self
and other
values to be equal, and is used
by ==
.