aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/layout/schema.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2023-11-14 12:48:38 +0100
committerAlex Auvolat <alex@adnab.me>2023-11-14 12:48:38 +0100
commit8e292e06b3fde1d3b5b019a26eabd4f0d9ac22c3 (patch)
treec4d252eaf122d9dd583cb755dffeb7d776ae4b66 /src/rpc/layout/schema.rs
parent9a491fa1372a23e91c793ee1d2b313607752826a (diff)
downloadgarage-8e292e06b3fde1d3b5b019a26eabd4f0d9ac22c3.tar.gz
garage-8e292e06b3fde1d3b5b019a26eabd4f0d9ac22c3.zip
layout: some refactoring of nongateway nodes
Diffstat (limited to 'src/rpc/layout/schema.rs')
-rw-r--r--src/rpc/layout/schema.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/rpc/layout/schema.rs b/src/rpc/layout/schema.rs
index 89f5c361..db298ee6 100644
--- a/src/rpc/layout/schema.rs
+++ b/src/rpc/layout/schema.rs
@@ -212,6 +212,8 @@ mod v010 {
/// see comment in v08::ClusterLayout
pub node_id_vec: Vec<Uuid>,
+ /// number of non-gateway nodes, which are the first ids in node_id_vec
+ pub nongateway_node_count: usize,
/// see comment in v08::ClusterLayout
#[serde(with = "serde_bytes")]
pub ring_assignment_data: Vec<CompactNodeType>,
@@ -265,6 +267,18 @@ mod v010 {
type Previous = v09::ClusterLayout;
fn migrate(previous: Self::Previous) -> Self {
+ let nongateway_node_count = previous
+ .node_id_vec
+ .iter()
+ .enumerate()
+ .filter(|(_, uuid)| {
+ let role = previous.roles.get(uuid);
+ matches!(role, Some(NodeRoleV(Some(role))) if role.capacity.is_some())
+ })
+ .map(|(i, _)| i)
+ .max()
+ .unwrap_or(0);
+
let version = LayoutVersion {
version: previous.version,
replication_factor: previous.replication_factor,
@@ -272,11 +286,14 @@ mod v010 {
parameters: previous.parameters,
roles: previous.roles,
node_id_vec: previous.node_id_vec,
+ nongateway_node_count,
ring_assignment_data: previous.ring_assignment_data,
};
let update_tracker = UpdateTracker(
version
.nongateway_nodes()
+ .iter()
+ .copied()
.map(|x| (x, version.version))
.collect::<BTreeMap<Uuid, u64>>(),
);