aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/ring.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2021-05-28 13:58:47 +0200
committerAlex Auvolat <alex@adnab.me>2021-05-28 15:29:58 +0200
commitb9127dd6f88d3c66181ef6748167efd94283ff41 (patch)
treea05030f4e16678b3dc997c6d2ec057ff9e7a19fb /src/rpc/ring.rs
parentddb2b29bfd1da75a9035fecf15169891be5bcafd (diff)
downloadgarage-b9127dd6f88d3c66181ef6748167efd94283ff41.tar.gz
garage-b9127dd6f88d3c66181ef6748167efd94283ff41.zip
Prepare for v0.3.0 and add migration path from v0.2.1.xv0.3.0
Diffstat (limited to 'src/rpc/ring.rs')
-rw-r--r--src/rpc/ring.rs28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/rpc/ring.rs b/src/rpc/ring.rs
index a5e5d4af..90db8fd2 100644
--- a/src/rpc/ring.rs
+++ b/src/rpc/ring.rs
@@ -38,6 +38,31 @@ impl NetworkConfig {
version: 0,
}
}
+
+ pub(crate) fn migrate_from_021(old: garage_rpc_021::ring::NetworkConfig) -> Self {
+ let members = old
+ .members
+ .into_iter()
+ .map(|(id, conf)| {
+ (
+ Hash::try_from(id.as_slice()).unwrap(),
+ NetworkConfigEntry {
+ zone: conf.datacenter,
+ capacity: if conf.capacity == 0 {
+ None
+ } else {
+ Some(conf.capacity)
+ },
+ tag: conf.tag,
+ },
+ )
+ })
+ .collect();
+ Self {
+ members,
+ version: old.version,
+ }
+ }
}
/// The overall configuration of one (possibly remote) node
@@ -178,8 +203,7 @@ impl Ring {
.iter()
.map(|(_id, info)| info.zone.as_str())
.collect::<HashSet<&str>>();
- if (p_zns.len() < n_zones
- && !p_zns.contains(&node_info.zone.as_str()))
+ if (p_zns.len() < n_zones && !p_zns.contains(&node_info.zone.as_str()))
|| (p_zns.len() == n_zones
&& !partitions[qv].iter().any(|(id, _i)| id == node_id))
{