diff options
author | Alex Auvolat <alex@adnab.me> | 2023-11-14 14:28:16 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2023-11-14 14:28:16 +0100 |
commit | 3b361d2959e3d577bdae6f8a5ccb0c9d5526b7ea (patch) | |
tree | f5448d44c7d5705c1e31912ca6d101c5998523ef /src/rpc/layout/history.rs | |
parent | 866196750fca74c1911ade2a90611f3663e60046 (diff) | |
download | garage-3b361d2959e3d577bdae6f8a5ccb0c9d5526b7ea.tar.gz garage-3b361d2959e3d577bdae6f8a5ccb0c9d5526b7ea.zip |
layout: prepare for write sets
Diffstat (limited to 'src/rpc/layout/history.rs')
-rw-r--r-- | src/rpc/layout/history.rs | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/rpc/layout/history.rs b/src/rpc/layout/history.rs index 69348873..dce492c9 100644 --- a/src/rpc/layout/history.rs +++ b/src/rpc/layout/history.rs @@ -98,13 +98,26 @@ impl LayoutHistory { .find(|x| x.version == sync_min) .or(self.versions.last()) .unwrap(); - version.nodes_of(position, version.replication_factor) + version + .nodes_of(position, version.replication_factor) + .collect() } - pub fn write_sets_of<'a>(&'a self, position: &'a Hash) -> impl Iterator<Item = Vec<Uuid>> + 'a { + pub fn write_sets_of(&self, position: &Hash) -> Vec<Vec<Uuid>> { self.versions .iter() - .map(move |x| x.nodes_of(position, x.replication_factor)) + .map(|x| x.nodes_of(position, x.replication_factor).collect()) + .collect() + } + + pub fn storage_nodes_of(&self, position: &Hash) -> Vec<Uuid> { + let mut ret = vec![]; + for version in self.versions.iter() { + ret.extend(version.nodes_of(position, version.replication_factor)); + } + ret.sort(); + ret.dedup(); + ret } // ------------------ update tracking --------------- |