From 2377a92f6b64165be84f53722f30c21e9c8a0b3e Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Thu, 24 Feb 2022 14:59:49 +0100 Subject: Add wrapper over sled tree to count items (used for big queues) --- src/model/block.rs | 4 +++- src/model/block_metrics.rs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src/model') diff --git a/src/model/block.rs b/src/model/block.rs index d97e64a8..97e06f0e 100644 --- a/src/model/block.rs +++ b/src/model/block.rs @@ -22,6 +22,7 @@ use opentelemetry::{ use garage_util::data::*; use garage_util::error::*; use garage_util::metrics::RecordDuration; +use garage_util::sled_counter::SledCountedTree; use garage_util::time::*; use garage_util::tranquilizer::Tranquilizer; @@ -155,7 +156,7 @@ pub struct BlockManager { rc: sled::Tree, - resync_queue: sled::Tree, + resync_queue: SledCountedTree, resync_notify: Notify, system: Arc, @@ -184,6 +185,7 @@ impl BlockManager { let resync_queue = db .open_tree("block_local_resync_queue") .expect("Unable to open block_local_resync_queue tree"); + let resync_queue = SledCountedTree::new(resync_queue); let endpoint = system .netapp diff --git a/src/model/block_metrics.rs b/src/model/block_metrics.rs index 7ef9a117..819af241 100644 --- a/src/model/block_metrics.rs +++ b/src/model/block_metrics.rs @@ -1,5 +1,7 @@ use opentelemetry::{global, metrics::*}; +use garage_util::sled_counter::SledCountedTree; + /// TableMetrics reference all counter used for metrics pub struct BlockManagerMetrics { pub(crate) _resync_queue_len: ValueObserver, @@ -20,7 +22,7 @@ pub struct BlockManagerMetrics { } impl BlockManagerMetrics { - pub fn new(resync_queue: sled::Tree) -> Self { + pub fn new(resync_queue: SledCountedTree) -> Self { let meter = global::meter("garage_model/block"); Self { _resync_queue_len: meter -- cgit v1.2.3