aboutsummaryrefslogtreecommitdiff
path: root/src/server.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2020-04-19 13:22:28 +0200
committerAlex Auvolat <alex@adnab.me>2020-04-19 13:22:28 +0200
commit7131553c53d4414d2da0e9b60e6e3425f1b46ec2 (patch)
tree22c4f225ebdbc600c9cbe38e11a01dbc228c5c11 /src/server.rs
parent4ba54ccfca2ff8e56c58d0a652de256428282490 (diff)
downloadgarage-7131553c53d4414d2da0e9b60e6e3425f1b46ec2.tar.gz
garage-7131553c53d4414d2da0e9b60e6e3425f1b46ec2.zip
Refactor sharding logic; coming next: full replication with epidemic dissemination
Diffstat (limited to 'src/server.rs')
-rw-r--r--src/server.rs22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/server.rs b/src/server.rs
index e728c667..6b4b5b6b 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -2,7 +2,6 @@ use std::io::{Read, Write};
use std::net::SocketAddr;
use std::path::PathBuf;
use std::sync::Arc;
-use std::time::Duration;
pub use futures_util::future::FutureExt;
use serde::Deserialize;
@@ -14,6 +13,7 @@ use crate::error::Error;
use crate::membership::System;
use crate::rpc_server::RpcServer;
use crate::table::*;
+use crate::table_sharded::*;
use crate::block::*;
use crate::block_ref_table::*;
@@ -22,8 +22,6 @@ use crate::version_table::*;
use crate::api_server;
-pub const DEFAULT_TIMEOUT: Duration = Duration::from_secs(10);
-
#[derive(Deserialize, Debug, Clone)]
pub struct Config {
pub metadata_dir: PathBuf,
@@ -59,9 +57,9 @@ pub struct Garage {
pub system: Arc<System>,
pub block_manager: Arc<BlockManager>,
- pub object_table: Arc<Table<ObjectTable>>,
- pub version_table: Arc<Table<VersionTable>>,
- pub block_ref_table: Arc<Table<BlockRefTable>>,
+ pub object_table: Arc<Table<ObjectTable, TableShardedReplication>>,
+ pub version_table: Arc<Table<VersionTable, TableShardedReplication>>,
+ pub block_ref_table: Arc<Table<BlockRefTable, TableShardedReplication>>,
}
impl Garage {
@@ -79,18 +77,16 @@ impl Garage {
let block_manager =
BlockManager::new(&db, config.data_dir.clone(), system.clone(), rpc_server);
- let data_rep_param = TableReplicationParams {
+ let data_rep_param = TableShardedReplication {
replication_factor: system.config.data_replication_factor,
write_quorum: (system.config.data_replication_factor + 1) / 2,
read_quorum: 1,
- timeout: DEFAULT_TIMEOUT,
};
- let meta_rep_param = TableReplicationParams {
+ let meta_rep_param = TableShardedReplication {
replication_factor: system.config.meta_replication_factor,
write_quorum: (system.config.meta_replication_factor + 1) / 2,
read_quorum: (system.config.meta_replication_factor + 1) / 2,
- timeout: DEFAULT_TIMEOUT,
};
println!("Initialize block_ref_table...");
@@ -99,10 +95,10 @@ impl Garage {
background: background.clone(),
block_manager: block_manager.clone(),
},
+ data_rep_param.clone(),
system.clone(),
&db,
"block_ref".to_string(),
- data_rep_param.clone(),
rpc_server,
)
.await;
@@ -113,10 +109,10 @@ impl Garage {
background: background.clone(),
block_ref_table: block_ref_table.clone(),
},
+ meta_rep_param.clone(),
system.clone(),
&db,
"version".to_string(),
- meta_rep_param.clone(),
rpc_server,
)
.await;
@@ -127,10 +123,10 @@ impl Garage {
background: background.clone(),
version_table: version_table.clone(),
},
+ meta_rep_param.clone(),
system.clone(),
&db,
"object".to_string(),
- meta_rep_param.clone(),
rpc_server,
)
.await;