diff options
author | Alex Auvolat <alex@adnab.me> | 2021-05-28 12:36:22 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2021-05-28 14:07:36 +0200 |
commit | b490ebc7f6058719bd22c86fd0db95b09dc027d6 (patch) | |
tree | e1c59ce1c348c2c63e1b2604369997216ef554d1 /src/rpc/membership.rs | |
parent | c8aa1eb481c18b1a35ef45d37071ab1af804a382 (diff) | |
download | garage-b490ebc7f6058719bd22c86fd0db95b09dc027d6.tar.gz garage-b490ebc7f6058719bd22c86fd0db95b09dc027d6.zip |
Many improvements on ring/replication and its configuration:
- Explicit "replication_mode" configuration parameters that takes
either "none", "2" or "3" as values, instead of letting user configure
replication factor themselves. These are presets whose corresponding
replication/quorum values can be found in replication/mode.rs
- Explicit support for single-node and two-node deployments
(number of nodes must be at least "replication_mode", with "none"
we can have only one node)
- Ring is now stored much more compactly with 256*8 + n*32 bytes,
instead of 256*32 bytes
- Support for gateway-only nodes that do not store data
(these nodes still need a metadata_directory to store the list
of bucket and keys since those are stored on all nodes; it also
technically needs a data_directory to start but it will stay
empty unless we have bugs)
Diffstat (limited to 'src/rpc/membership.rs')
-rw-r--r-- | src/rpc/membership.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/rpc/membership.rs b/src/rpc/membership.rs index da7dcf8f..37cf8105 100644 --- a/src/rpc/membership.rs +++ b/src/rpc/membership.rs @@ -95,6 +95,7 @@ pub struct System { rpc_http_client: Arc<RpcHttpClient>, rpc_client: Arc<RpcClient<Message>>, + replication_factor: usize, pub(crate) status: watch::Receiver<Arc<Status>>, /// The ring pub ring: watch::Receiver<Arc<Ring>>, @@ -228,6 +229,7 @@ impl System { rpc_http_client: Arc<RpcHttpClient>, background: Arc<BackgroundRunner>, rpc_server: &mut RpcServer, + replication_factor: usize, ) -> Arc<Self> { let id = gen_node_id(&metadata_dir).expect("Unable to read or generate node ID"); info!("Node ID: {}", hex::encode(&id)); @@ -259,7 +261,7 @@ impl System { .unwrap_or_else(|_| "<invalid utf-8>".to_string()), }; - let ring = Ring::new(net_config); + let ring = Ring::new(net_config, replication_factor); let (update_ring, ring) = watch::channel(Arc::new(ring)); let rpc_path = MEMBERSHIP_RPC_PATH.to_string(); @@ -277,6 +279,7 @@ impl System { state_info, rpc_http_client, rpc_client, + replication_factor, status, ring, update_lock: Mutex::new(Updaters { @@ -543,7 +546,7 @@ impl System { let ring: Arc<Ring> = self.ring.borrow().clone(); if adv.version > ring.config.version { - let ring = Ring::new(adv.clone()); + let ring = Ring::new(adv.clone(), self.replication_factor); update_lock.update_ring.send(Arc::new(ring))?; drop(update_lock); |