refactor: remove max_write_errors and max_faults

This commit is contained in:
Yureka 2024-03-04 18:37:00 +01:00
parent bbde9bc912
commit 6760895926
5 changed files with 5 additions and 19 deletions

View file

@ -247,7 +247,6 @@ impl Garage {
let control_rep_param = TableFullReplication {
system: system.clone(),
max_faults: replication_mode.control_write_max_faults(),
};
info!("Initialize block manager...");

View file

@ -21,13 +21,6 @@ impl ReplicationMode {
}
}
pub fn control_write_max_faults(&self) -> usize {
match self {
Self::None => 0,
_ => 1,
}
}
pub fn replication_factor(&self) -> usize {
match self {
Self::None => 1,

View file

@ -21,8 +21,6 @@ use crate::replication::*;
pub struct TableFullReplication {
/// The membership manager of this node
pub system: Arc<System>,
/// Max number of faults allowed while replicating a record
pub max_faults: usize,
}
impl TableReplication for TableFullReplication {
@ -45,15 +43,15 @@ impl TableReplication for TableFullReplication {
}
fn write_quorum(&self) -> usize {
let nmembers = self.system.cluster_layout().current().all_nodes().len();
if nmembers > self.max_faults {
nmembers - self.max_faults
let max_faults = if nmembers > 1 { 1 } else { 0 };
if nmembers > max_faults {
nmembers - max_faults
} else {
1
}
}
fn max_write_errors(&self) -> usize {
self.max_faults
}
fn partition_of(&self, _hash: &Hash) -> Partition {
0u16

View file

@ -20,7 +20,6 @@ pub trait TableReplication: Send + Sync + 'static {
fn write_sets(&self, hash: &Hash) -> Self::WriteSets;
/// Responses needed to consider a write succesfull in each set
fn write_quorum(&self) -> usize;
fn max_write_errors(&self) -> usize;
// Accessing partitions, for Merkle tree & sync
/// Get partition for data with given hash

View file

@ -44,9 +44,6 @@ impl TableReplication for TableShardedReplication {
fn write_quorum(&self) -> usize {
self.write_quorum
}
fn max_write_errors(&self) -> usize {
self.replication_factor - self.write_quorum
}
fn partition_of(&self, hash: &Hash) -> Partition {
self.system.cluster_layout().current().partition_of(hash)