Make store() generic over chunk submission target
This commit is contained in:
parent
202c7c57fd
commit
752b07e0b1
@ -35,7 +35,7 @@ pub const FASTCDC_AVG: usize = 1024 * 1024;
|
||||
// 8 MiB
|
||||
pub const FASTCDC_MAX: usize = 8 * 1024 * 1024;
|
||||
|
||||
pub trait ChunkSubmissionTarget {
|
||||
pub trait ChunkSubmissionTarget: Sync {
|
||||
fn submit(&self, chunk_id: ChunkId, chunk_data: &[u8]) -> anyhow::Result<()>;
|
||||
}
|
||||
|
||||
|
@ -35,10 +35,10 @@ use crate::progress::ProgressTracker;
|
||||
use crate::tree::{create_uidgid_lookup_tables, differentiate_node_in_place};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
pub fn store<RP: RawPile, PT: ProgressTracker>(
|
||||
pub fn store<CST: ChunkSubmissionTarget, PT: ProgressTracker>(
|
||||
root_path: &Path,
|
||||
root: &mut TreeNode,
|
||||
pile: &Pile<RP>,
|
||||
target: &CST,
|
||||
progress_bar: &mut PT,
|
||||
num_workers: u8,
|
||||
) -> anyhow::Result<()> {
|
||||
@ -57,7 +57,7 @@ pub fn store<RP: RawPile, PT: ProgressTracker>(
|
||||
s.builder()
|
||||
.name(format!("yama chunker {}", worker_num))
|
||||
.spawn(move |_| {
|
||||
if let Err(e) = store_worker(root_path, pile, paths_recv, results_send) {
|
||||
if let Err(e) = store_worker(root_path, target, paths_recv, results_send) {
|
||||
error!("[critical!] Storage worker {} FAILED: {:?}", worker_num, e);
|
||||
critical_failures.fetch_add(1, Ordering::Relaxed);
|
||||
}
|
||||
@ -252,7 +252,7 @@ pub fn store_fully<PT: ProgressTracker>(
|
||||
differentiate_node_in_place(&mut root_node, &parent_node.node)?;
|
||||
}
|
||||
|
||||
store(&root_dir, &mut root_node, &pile, progress_bar, num_workers)?;
|
||||
store(&root_dir, &mut root_node, pile, progress_bar, num_workers)?;
|
||||
|
||||
let mut uid_lookup = BTreeMap::new();
|
||||
let mut gid_lookup = BTreeMap::new();
|
||||
|
Loading…
Reference in New Issue
Block a user