2023-11-08 14:41:24 +00:00
|
|
|
use garage_rpc::layout::*;
|
2021-03-11 15:54:15 +00:00
|
|
|
use garage_util::data::*;
|
|
|
|
|
2021-03-26 18:41:46 +00:00
|
|
|
/// Trait to describe how a table shall be replicated
|
2023-01-03 14:08:37 +00:00
|
|
|
pub trait TableReplication: Send + Sync + 'static {
|
2023-12-07 09:55:15 +00:00
|
|
|
type WriteSets: AsRef<Vec<Vec<Uuid>>> + AsMut<Vec<Vec<Uuid>>> + Send + Sync + 'static;
|
2023-11-15 14:40:44 +00:00
|
|
|
|
2021-03-11 15:54:15 +00:00
|
|
|
// See examples in table_sharded.rs and table_fullcopy.rs
|
|
|
|
// To understand various replication methods
|
|
|
|
|
2023-11-14 13:28:16 +00:00
|
|
|
/// The entire list of all nodes that store a partition
|
|
|
|
fn storage_nodes(&self, hash: &Hash) -> Vec<Uuid>;
|
|
|
|
|
2021-03-26 18:41:46 +00:00
|
|
|
/// Which nodes to send read requests to
|
2021-10-15 09:05:09 +00:00
|
|
|
fn read_nodes(&self, hash: &Hash) -> Vec<Uuid>;
|
2021-03-26 18:41:46 +00:00
|
|
|
/// Responses needed to consider a read succesfull
|
2021-03-11 15:54:15 +00:00
|
|
|
fn read_quorum(&self) -> usize;
|
|
|
|
|
2021-03-26 18:41:46 +00:00
|
|
|
/// Which nodes to send writes to
|
2023-11-15 14:40:44 +00:00
|
|
|
fn write_sets(&self, hash: &Hash) -> Self::WriteSets;
|
2023-11-14 13:28:16 +00:00
|
|
|
/// Responses needed to consider a write succesfull in each set
|
2021-03-16 10:14:27 +00:00
|
|
|
fn write_quorum(&self) -> usize;
|
2021-03-11 15:54:15 +00:00
|
|
|
fn max_write_errors(&self) -> usize;
|
|
|
|
|
2021-03-16 11:18:03 +00:00
|
|
|
// Accessing partitions, for Merkle tree & sync
|
2021-03-26 18:41:46 +00:00
|
|
|
/// Get partition for data with given hash
|
2021-03-16 11:18:03 +00:00
|
|
|
fn partition_of(&self, hash: &Hash) -> Partition;
|
2023-11-11 11:08:32 +00:00
|
|
|
/// List of partitions and nodes to sync with in current layout
|
|
|
|
fn sync_partitions(&self) -> SyncPartitions;
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct SyncPartitions {
|
|
|
|
pub layout_version: u64,
|
|
|
|
pub partitions: Vec<SyncPartition>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct SyncPartition {
|
|
|
|
pub partition: Partition,
|
|
|
|
pub first_hash: Hash,
|
|
|
|
pub last_hash: Hash,
|
2023-12-07 10:16:10 +00:00
|
|
|
pub storage_sets: Vec<Vec<Uuid>>,
|
2021-03-11 15:54:15 +00:00
|
|
|
}
|