mirror of
https://github.com/deuxfleurs-org/garage.git
synced 2026-09-04 11:15:41 +00:00
refactor: Use ReplicationFactor type in more places
- Remove the replication_factor.replication_factor() in favor of usize::from(replication_factor) to make the conversion more explicit. - Implement Display on ReplicationFactor so that it can be formatted without converting to usize - Use ReplicationFactor in the constructor of LayoutVersion and add a method to get a ReplicationFactor from a LayoutVersion, despite LayoutVersion still storing it as usize internally.
This commit is contained in:
@@ -46,11 +46,11 @@ impl LayoutManager {
|
||||
|
||||
let cluster_layout = match persist_cluster_layout.load() {
|
||||
Ok(x) => {
|
||||
if x.current().replication_factor != replication_factor.replication_factor() {
|
||||
if x.current().replication_factor() != replication_factor {
|
||||
return Err(Error::Message(format!(
|
||||
"Previous cluster layout has replication factor {}, which is different than the one specified in the config file ({}). The previous cluster layout can be purged, if you know what you are doing, simply by deleting the `cluster_layout` file in your metadata directory.",
|
||||
x.current().replication_factor,
|
||||
replication_factor.replication_factor()
|
||||
x.current().replication_factor(),
|
||||
replication_factor,
|
||||
)));
|
||||
}
|
||||
x
|
||||
@@ -301,11 +301,11 @@ impl LayoutManager {
|
||||
adv.update_trackers
|
||||
);
|
||||
|
||||
if adv.current().replication_factor != self.replication_factor.replication_factor() {
|
||||
if adv.current().replication_factor() != self.replication_factor {
|
||||
let msg = format!(
|
||||
"Received a cluster layout from another node with replication factor {}, which is different from what we have in our configuration ({}). Discarding the cluster layout we received.",
|
||||
adv.current().replication_factor,
|
||||
self.replication_factor.replication_factor()
|
||||
adv.current().replication_factor(),
|
||||
self.replication_factor,
|
||||
);
|
||||
error!("{}", msg);
|
||||
return Err(Error::Message(msg));
|
||||
|
||||
Reference in New Issue
Block a user