new layout: improve display and fix comments

This commit is contained in:
Alex Auvolat 2023-09-18 12:07:45 +02:00
parent 015ccb39aa
commit 749b4865d0
2 changed files with 10 additions and 10 deletions

View File

@ -282,7 +282,7 @@ pub async fn cmd_config_layout(
layout layout
.staging_parameters .staging_parameters
.update(LayoutParameters { zone_redundancy: r }); .update(LayoutParameters { zone_redundancy: r });
println!("The new zone redundancy has been saved ({}).", r); println!("The zone redundancy parameter has been set to '{}'.", r);
did_something = true; did_something = true;
} }
} }
@ -359,11 +359,11 @@ pub fn print_cluster_layout(layout: &ClusterLayout, empty_msg: &str) {
} }
if table.len() > 1 { if table.len() > 1 {
format_table(table); format_table(table);
println!();
println!("Zone redundancy: {}", layout.parameters.zone_redundancy);
} else { } else {
println!("{}", empty_msg); println!("{}", empty_msg);
} }
println!();
println!("Zone redundancy: {}", layout.parameters.zone_redundancy);
} }
pub fn print_staging_role_changes(layout: &ClusterLayout) -> bool { pub fn print_staging_role_changes(layout: &ClusterLayout) -> bool {

View File

@ -121,7 +121,7 @@ mod v09 {
/// Zone redundancy: if set to AtLeast(x), the layout calculation will aim to store copies /// Zone redundancy: if set to AtLeast(x), the layout calculation will aim to store copies
/// of each partition on at least that number of different zones. /// of each partition on at least that number of different zones.
/// If None, copies will be stored on the maximum possible number of zones. /// Otherwise, copies will be stored on the maximum possible number of zones.
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Debug, Serialize, Deserialize)] #[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Debug, Serialize, Deserialize)]
pub enum ZoneRedundancy { pub enum ZoneRedundancy {
AtLeast(usize), AtLeast(usize),
@ -161,7 +161,7 @@ mod v09 {
.min() .min()
.unwrap_or(0); .unwrap_or(0);
// By default, zone_redundancy is None (i.e. maximum possible value) // By default, zone_redundancy is maximum possible value
let parameters = LayoutParameters { let parameters = LayoutParameters {
zone_redundancy: ZoneRedundancy::Maximum, zone_redundancy: ZoneRedundancy::Maximum,
}; };
@ -253,7 +253,7 @@ impl core::str::FromStr for ZoneRedundancy {
// Implementation of the ClusterLayout methods unrelated to the assignment algorithm. // Implementation of the ClusterLayout methods unrelated to the assignment algorithm.
impl ClusterLayout { impl ClusterLayout {
pub fn new(replication_factor: usize) -> Self { pub fn new(replication_factor: usize) -> Self {
// We set the default zone redundancy to be None, meaning that the maximum // We set the default zone redundancy to be Maximum, meaning that the maximum
// possible value will be used depending on the cluster topology // possible value will be used depending on the cluster topology
let parameters = LayoutParameters { let parameters = LayoutParameters {
zone_redundancy: ZoneRedundancy::Maximum, zone_redundancy: ZoneRedundancy::Maximum,
@ -1005,12 +1005,12 @@ impl ClusterLayout {
msg.push("".into()); msg.push("".into());
msg.push( msg.push(
"If the percentage is too low, it might be that the \ "If the percentage is too low, it might be that the \
replication/redundancy constraints force the use of nodes/zones with small \ cluster topology and redundancy constraints are forcing the use of nodes/zones with small \
storage capacities." storage capacities."
.into(), .into(),
); );
msg.push( msg.push(
"You might want to rebalance the storage capacities or relax the constraints." "You might want to move storage capacity between zones or relax the redundancy constraint."
.into(), .into(),
); );
msg.push( msg.push(
@ -1105,8 +1105,8 @@ impl ClusterLayout {
tags_n, tags_n,
stored_partitions[*n], stored_partitions[*n],
new_partitions[*n], new_partitions[*n],
ByteSize::b(available_cap_n).to_string_as(false),
ByteSize::b(total_cap_n).to_string_as(false), ByteSize::b(total_cap_n).to_string_as(false),
ByteSize::b(available_cap_n).to_string_as(false),
(available_cap_n as f32) / (total_cap_n as f32) * 100.0, (available_cap_n as f32) / (total_cap_n as f32) * 100.0,
)); ));
} }
@ -1116,8 +1116,8 @@ impl ClusterLayout {
replicated_partitions, replicated_partitions,
stored_partitions_zone[z], stored_partitions_zone[z],
//new_partitions_zone[z], //new_partitions_zone[z],
ByteSize::b(available_cap_z).to_string_as(false),
ByteSize::b(total_cap_z).to_string_as(false), ByteSize::b(total_cap_z).to_string_as(false),
ByteSize::b(available_cap_z).to_string_as(false),
percent_cap_z percent_cap_z
)); ));
table.push("".into()); table.push("".into());