aboutsummaryrefslogtreecommitdiff
path: root/src/api
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2023-11-08 19:28:36 +0100
committerAlex Auvolat <alex@adnab.me>2023-11-08 19:28:36 +0100
commit8dccee3ccfe7793c42203f28c1e91c6f989b6899 (patch)
tree0a3fdb60229d9e3c9d61c7f01d40ed74159f1b2c /src/api
parentfe9af1dcaae31a117528a9cfa10c422c9a850201 (diff)
downloadgarage-8dccee3ccfe7793c42203f28c1e91c6f989b6899.tar.gz
garage-8dccee3ccfe7793c42203f28c1e91c6f989b6899.zip
cluster layout: adapt all uses of ClusterLayout to LayoutHistory
Diffstat (limited to 'src/api')
-rw-r--r--src/api/admin/cluster.rs9
-rw-r--r--src/api/k2v/index.rs9
2 files changed, 11 insertions, 7 deletions
diff --git a/src/api/admin/cluster.rs b/src/api/admin/cluster.rs
index 01ff9885..6dd2e8da 100644
--- a/src/api/admin/cluster.rs
+++ b/src/api/admin/cluster.rs
@@ -89,8 +89,9 @@ pub async fn handle_get_cluster_layout(garage: &Arc<Garage>) -> Result<Response<
Ok(json_ok_response(&res)?)
}
-fn format_cluster_layout(layout: &layout::ClusterLayout) -> GetClusterLayoutResponse {
+fn format_cluster_layout(layout: &layout::LayoutHistory) -> GetClusterLayoutResponse {
let roles = layout
+ .current()
.roles
.items()
.iter()
@@ -107,7 +108,7 @@ fn format_cluster_layout(layout: &layout::ClusterLayout) -> GetClusterLayoutResp
.staging_roles
.items()
.iter()
- .filter(|(k, _, v)| layout.roles.get(k) != Some(v))
+ .filter(|(k, _, v)| layout.current().roles.get(k) != Some(v))
.map(|(k, _, v)| match &v.0 {
None => NodeRoleChange {
id: hex::encode(k),
@@ -125,7 +126,7 @@ fn format_cluster_layout(layout: &layout::ClusterLayout) -> GetClusterLayoutResp
.collect::<Vec<_>>();
GetClusterLayoutResponse {
- version: layout.version,
+ version: layout.current().version,
roles,
staged_role_changes,
}
@@ -209,7 +210,7 @@ pub async fn handle_update_cluster_layout(
let mut layout = garage.system.cluster_layout().as_ref().clone();
- let mut roles = layout.roles.clone();
+ let mut roles = layout.current().roles.clone();
roles.merge(&layout.staging_roles);
for change in updates {
diff --git a/src/api/k2v/index.rs b/src/api/k2v/index.rs
index 3fc39de6..a9bc3826 100644
--- a/src/api/k2v/index.rs
+++ b/src/api/k2v/index.rs
@@ -5,7 +5,7 @@ use serde::Serialize;
use garage_util::data::*;
-use garage_rpc::layout::ClusterLayout;
+use garage_rpc::layout::LayoutHistory;
use garage_table::util::*;
use garage_model::garage::Garage;
@@ -26,7 +26,7 @@ pub async fn handle_read_index(
) -> Result<Response<Body>, Error> {
let reverse = reverse.unwrap_or(false);
- let layout: Arc<ClusterLayout> = garage.system.cluster_layout().clone();
+ let layout: Arc<LayoutHistory> = garage.system.cluster_layout().clone();
let (partition_keys, more, next_start) = read_range(
&garage.k2v.counter_table.table,
@@ -35,7 +35,10 @@ pub async fn handle_read_index(
&start,
&end,
limit,
- Some((DeletedFilter::NotDeleted, layout.node_id_vec.clone())),
+ Some((
+ DeletedFilter::NotDeleted,
+ layout.current().node_id_vec.clone(),
+ )),
EnumerationOrder::from_reverse(reverse),
)
.await?;