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: ReplicationFactor) -> 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
Sourcepub fn nodes_of(&self, position: &Hash) -> impl Iterator<Item = Uuid> + '_
pub fn nodes_of(&self, position: &Hash) -> impl Iterator<Item = Uuid> + '_
Return the n servers in which data for this hash should be replicated
pub fn replication_factor(&self) -> ReplicationFactor
pub fn read_quorum(&self, consistency_mode: ConsistencyMode) -> usize
pub fn write_quorum(&self, consistency_mode: ConsistencyMode) -> usize
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§impl Serialize for LayoutVersion
impl Serialize for LayoutVersion
impl StructuralPartialEq for LayoutVersion
Auto Trait Implementations§
impl Freeze for LayoutVersion
impl RefUnwindSafe for LayoutVersion
impl Send for LayoutVersion
impl Sync for LayoutVersion
impl Unpin for LayoutVersion
impl UnwindSafe for LayoutVersion
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more