diff options
author | Alex Auvolat <alex@adnab.me> | 2023-11-09 11:19:43 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2023-11-09 11:19:43 +0100 |
commit | 523d2ecb9511f74e144cd116b942d6c1bf0f546d (patch) | |
tree | 7ba0323fb691eac4f05308676cd24771a8a6a8bb /src/rpc/layout/version.rs | |
parent | 1da0a5676edcd20fc5c7412596edb5772da9f606 (diff) | |
download | garage-523d2ecb9511f74e144cd116b942d6c1bf0f546d.tar.gz garage-523d2ecb9511f74e144cd116b942d6c1bf0f546d.zip |
layout: use separate CRDT for staged layout changes
Diffstat (limited to 'src/rpc/layout/version.rs')
-rw-r--r-- | src/rpc/layout/version.rs | 54 |
1 files changed, 3 insertions, 51 deletions
diff --git a/src/rpc/layout/version.rs b/src/rpc/layout/version.rs index 363bc204..6918fdf9 100644 --- a/src/rpc/layout/version.rs +++ b/src/rpc/layout/version.rs @@ -1,69 +1,21 @@ use std::collections::HashMap; use std::collections::HashSet; -use std::fmt; +use std::convert::TryInto; use bytesize::ByteSize; use itertools::Itertools; -use garage_util::crdt::{AutoCrdt, LwwMap}; +use garage_util::crdt::LwwMap; use garage_util::data::*; use garage_util::error::*; -use crate::graph_algo::*; - -use std::convert::TryInto; - +use super::graph_algo::*; use super::schema::*; use super::*; // The Message type will be used to collect information on the algorithm. pub type Message = Vec<String>; -impl AutoCrdt for LayoutParameters { - const WARN_IF_DIFFERENT: bool = true; -} - -impl AutoCrdt for NodeRoleV { - const WARN_IF_DIFFERENT: bool = true; -} - -impl NodeRole { - pub fn capacity_string(&self) -> String { - match self.capacity { - Some(c) => ByteSize::b(c).to_string_as(false), - None => "gateway".to_string(), - } - } - - pub fn tags_string(&self) -> String { - self.tags.join(",") - } -} - -impl fmt::Display for ZoneRedundancy { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - ZoneRedundancy::Maximum => write!(f, "maximum"), - ZoneRedundancy::AtLeast(x) => write!(f, "{}", x), - } - } -} - -impl core::str::FromStr for ZoneRedundancy { - type Err = &'static str; - fn from_str(s: &str) -> Result<Self, Self::Err> { - match s { - "none" | "max" | "maximum" => Ok(ZoneRedundancy::Maximum), - x => { - let v = x - .parse::<usize>() - .map_err(|_| "zone redundancy must be 'none'/'max' or an integer")?; - Ok(ZoneRedundancy::AtLeast(v)) - } - } - } -} - impl LayoutVersion { pub fn new(replication_factor: usize) -> Self { // We set the default zone redundancy to be Maximum, meaning that the maximum |