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:

  1. non-gateway nodes are first so that they have lower numbers
  2. 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

source

pub fn new(replication_factor: usize) -> Self

source

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

source

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

source

pub fn node_role(&self, node: &Uuid) -> Option<&NodeRole>

Returns the role of a node in the layout, if it has one

source

pub fn get_node_capacity(&self, uuid: &Uuid) -> Option<u64>

Returns the capacity of a node in the layout, if it has one

source

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

source

pub fn get_node_usage(&self, uuid: &Uuid) -> Result<usize, Error>

Returns the number of partitions associated to this node in the ring

source

pub fn partition_of(&self, position: &Hash) -> Partition

Get the partition in which data would fall on

source

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

source

pub fn nodes_of( &self, position: &Hash, n: usize ) -> impl Iterator<Item = Uuid> + '_

Return the n servers in which data for this hash should be replicated

source

pub fn check(&self) -> Result<(), String>

Check a cluster layout for internal consistency (assignment, roles, parameters, partition size) returns true if consistent, false if error

Trait Implementations§

source§

impl Clone for LayoutVersion

source§

fn clone(&self) -> LayoutVersion

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for LayoutVersion

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for LayoutVersion

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl PartialEq for LayoutVersion

source§

fn eq(&self, other: &LayoutVersion) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for LayoutVersion

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl StructuralPartialEq for LayoutVersion

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> FutureExt for T

source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,