aboutsummaryrefslogtreecommitdiff
path: root/src/garage
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-06-02 16:58:00 +0200
committerAlex Auvolat <alex@adnab.me>2022-06-02 16:58:00 +0200
commit9f0f5b2e372a720a807914747fd48ddc93928e04 (patch)
treea4346766c46469758b9138a09c65fa052e9ad253 /src/garage
parent04901093e7315558bdc147d27adc3f56ec2c98a1 (diff)
downloadgarage-9f0f5b2e372a720a807914747fd48ddc93928e04.tar.gz
garage-9f0f5b2e372a720a807914747fd48ddc93928e04.zip
Adapt Garage to use new DB abstraction
Diffstat (limited to 'src/garage')
-rw-r--r--src/garage/Cargo.toml1
-rw-r--r--src/garage/admin.rs2
-rw-r--r--src/garage/repair.rs22
-rw-r--r--src/garage/server.rs1
4 files changed, 21 insertions, 5 deletions
diff --git a/src/garage/Cargo.toml b/src/garage/Cargo.toml
index 902f67f8..d34a7fa4 100644
--- a/src/garage/Cargo.toml
+++ b/src/garage/Cargo.toml
@@ -21,6 +21,7 @@ path = "tests/lib.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
+garage_db = { version = "0.8.0", path = "../db" }
garage_api = { version = "0.7.0", path = "../api" }
garage_model = { version = "0.7.0", path = "../model" }
garage_rpc = { version = "0.7.0", path = "../rpc" }
diff --git a/src/garage/admin.rs b/src/garage/admin.rs
index bc1f494a..cce88b35 100644
--- a/src/garage/admin.rs
+++ b/src/garage/admin.rs
@@ -727,7 +727,7 @@ impl AdminRpcHandler {
{
writeln!(to, "\nTable stats for {}", F::TABLE_NAME).unwrap();
if opt.detailed {
- writeln!(to, " number of items: {}", t.data.store.len()).unwrap();
+ writeln!(to, " number of items: {}", t.data.store.len().unwrap()).unwrap(); // TODO fix len unwrap
writeln!(
to,
" Merkle tree size: {}",
diff --git a/src/garage/repair.rs b/src/garage/repair.rs
index 830eac71..04d9ee72 100644
--- a/src/garage/repair.rs
+++ b/src/garage/repair.rs
@@ -1,3 +1,4 @@
+use core::ops::Bound;
use std::sync::Arc;
use tokio::sync::watch;
@@ -65,9 +66,15 @@ impl Repair {
async fn repair_versions(&self, must_exit: &watch::Receiver<bool>) -> Result<(), Error> {
let mut pos = vec![];
- while let Some((item_key, item_bytes)) =
- self.garage.version_table.data.store.get_gt(&pos)?
+ while let Some(item) = self
+ .garage
+ .version_table
+ .data
+ .store
+ .range((Bound::Excluded(pos), Bound::Unbounded))?
+ .next()
{
+ let (item_key, item_bytes) = item?;
pos = item_key.to_vec();
let version = rmp_serde::decode::from_read_ref::<_, Version>(item_bytes.as_ref())?;
@@ -109,9 +116,16 @@ impl Repair {
async fn repair_block_ref(&self, must_exit: &watch::Receiver<bool>) -> Result<(), Error> {
let mut pos = vec![];
- while let Some((item_key, item_bytes)) =
- self.garage.block_ref_table.data.store.get_gt(&pos)?
+ while let Some(item) = self
+ .garage
+ .block_ref_table
+ .data
+ .store
+ .range((Bound::Excluded(pos), Bound::Unbounded))?
+ .next()
{
+ let (item_key, item_bytes) = item?;
+
pos = item_key.to_vec();
let block_ref = rmp_serde::decode::from_read_ref::<_, BlockRef>(item_bytes.as_ref())?;
diff --git a/src/garage/server.rs b/src/garage/server.rs
index b58ad286..69f5d60c 100644
--- a/src/garage/server.rs
+++ b/src/garage/server.rs
@@ -38,6 +38,7 @@ pub async fn run_server(config_file: PathBuf) -> Result<(), Error> {
.flush_every_ms(Some(config.sled_flush_every_ms))
.open()
.expect("Unable to open sled DB");
+ let db = garage_db::sled_adapter::SledDb::new(db);
info!("Initializing background runner...");
let watch_cancel = netapp::util::watch_ctrl_c();