From b490ebc7f6058719bd22c86fd0db95b09dc027d6 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Fri, 28 May 2021 12:36:22 +0200 Subject: 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) --- src/rpc/membership.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/rpc/membership.rs') 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, rpc_client: Arc>, + replication_factor: usize, pub(crate) status: watch::Receiver>, /// The ring pub ring: watch::Receiver>, @@ -228,6 +229,7 @@ impl System { rpc_http_client: Arc, background: Arc, rpc_server: &mut RpcServer, + replication_factor: usize, ) -> Arc { 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(|_| "".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 = 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); -- cgit v1.2.3