diff options
author | Alex Auvolat <alex@adnab.me> | 2020-04-19 17:15:48 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2020-04-19 17:15:48 +0200 |
commit | a6129d8626f5b87462b70eadbce2db08c9761cfd (patch) | |
tree | 7e0e0d348bc8f8672db57680f8aeedf9c6c03523 /src/server.rs | |
parent | 302502f4c10b4c1cd03d3b098b3e55a3f70054f2 (diff) | |
download | garage-a6129d8626f5b87462b70eadbce2db08c9761cfd.tar.gz garage-a6129d8626f5b87462b70eadbce2db08c9761cfd.zip |
Begin implement bucket management & admin commands
Diffstat (limited to 'src/server.rs')
-rw-r--r-- | src/server.rs | 44 |
1 files changed, 37 insertions, 7 deletions
diff --git a/src/server.rs b/src/server.rs index 6b4b5b6b..979d76f9 100644 --- a/src/server.rs +++ b/src/server.rs @@ -13,13 +13,16 @@ use crate::error::Error; use crate::membership::System; use crate::rpc_server::RpcServer; use crate::table::*; +use crate::table_fullcopy::*; use crate::table_sharded::*; use crate::block::*; use crate::block_ref_table::*; +use crate::bucket_table::*; use crate::object_table::*; use crate::version_table::*; +use crate::admin_rpc::*; use crate::api_server; #[derive(Deserialize, Debug, Clone)] @@ -38,12 +41,25 @@ pub struct Config { #[serde(default = "default_replication_factor")] pub meta_replication_factor: usize, + #[serde(default = "default_epidemic_factor")] + pub meta_epidemic_factor: usize, + #[serde(default = "default_replication_factor")] pub data_replication_factor: usize, pub rpc_tls: Option<TlsConfig>, } +fn default_block_size() -> usize { + 1048576 +} +fn default_replication_factor() -> usize { + 3 +} +fn default_epidemic_factor() -> usize { + 3 +} + #[derive(Deserialize, Debug, Clone)] pub struct TlsConfig { pub ca_cert: String, @@ -57,6 +73,7 @@ pub struct Garage { pub system: Arc<System>, pub block_manager: Arc<BlockManager>, + pub bucket_table: Arc<Table<BucketTable, TableFullReplication>>, pub object_table: Arc<Table<ObjectTable, TableShardedReplication>>, pub version_table: Arc<Table<VersionTable, TableShardedReplication>>, pub block_ref_table: Arc<Table<BlockRefTable, TableShardedReplication>>, @@ -89,6 +106,11 @@ impl Garage { read_quorum: (system.config.meta_replication_factor + 1) / 2, }; + let control_rep_param = TableFullReplication::new( + system.config.meta_epidemic_factor, + (system.config.meta_epidemic_factor + 1) / 2, + ); + println!("Initialize block_ref_table..."); let block_ref_table = Table::new( BlockRefTable { @@ -131,17 +153,32 @@ impl Garage { ) .await; + println!("Initialize bucket_table..."); + let bucket_table = Table::new( + BucketTable, + control_rep_param.clone(), + system.clone(), + &db, + "bucket".to_string(), + rpc_server, + ) + .await; + println!("Initialize Garage..."); let garage = Arc::new(Self { db, system: system.clone(), block_manager, background, + bucket_table, object_table, version_table, block_ref_table, }); + println!("Crate admin RPC handler..."); + AdminRpcHandler::new(garage.clone()).register_handler(rpc_server); + println!("Start block manager background thread..."); garage.block_manager.garage.swap(Some(garage.clone())); garage.block_manager.clone().spawn_background_worker().await; @@ -150,13 +187,6 @@ impl Garage { } } -fn default_block_size() -> usize { - 1048576 -} -fn default_replication_factor() -> usize { - 3 -} - fn read_config(config_file: PathBuf) -> Result<Config, Error> { let mut file = std::fs::OpenOptions::new() .read(true) |