Compare commits

..

No commits in common. "8b870a069c24702ad05a0d6bcbe17e0b58a54b0c" and "f43f76dd42e091ea825888261c1a535416acc4a5" have entirely different histories.

4 changed files with 9 additions and 12 deletions

View File

@ -17,12 +17,10 @@ pub struct FileSyncGoal {
pub index_start: u64, pub index_start: u64,
/// Chunk index to sync to (exclusive). /// Chunk index to sync to (exclusive).
pub index_end: u64, pub index_end: u64,
/// `true` if we are syncing all the needed data of this file.
pub all_chunks: bool,
} }
impl FileSyncGoal { impl FileSyncGoal {
pub fn new(num_chunks: u64, index_start: u64, index_end: u64, all_chunks: bool) -> Self { pub fn new(num_chunks: u64, index_start: u64, index_end: u64) -> Self {
assert!( assert!(
index_start < index_end && index_end <= num_chunks, index_start < index_end && index_end <= num_chunks,
"invalid index_end" "invalid index_end"
@ -31,16 +29,15 @@ impl FileSyncGoal {
num_chunks, num_chunks,
index_start, index_start,
index_end, index_end,
all_chunks,
} }
} }
pub fn new_file(num_chunks: u64) -> Self { pub fn new_file(num_chunks: u64) -> Self {
Self::new(num_chunks, 0, num_chunks, true) Self::new(num_chunks, 0, num_chunks)
} }
pub fn is_all_chunks(&self) -> bool { pub fn is_all_chunks(&self) -> bool {
self.all_chunks self.index_start == 0 && self.index_end == self.num_chunks
} }
} }

View File

@ -139,7 +139,7 @@ impl SerialSyncController {
if let Some((start, end)) = maybe_range { if let Some((start, end)) = maybe_range {
// Sync new chunks regardless of previously downloaded file or chunks. // Sync new chunks regardless of previously downloaded file or chunks.
// It's up to client to avoid duplicated chunks sync. // It's up to client to avoid duplicated chunks sync.
self.goal = FileSyncGoal::new(self.goal.num_chunks, start, end, false); self.goal = FileSyncGoal::new(self.goal.num_chunks, start, end);
self.next_chunk = start; self.next_chunk = start;
} else if self.goal.is_all_chunks() { } else if self.goal.is_all_chunks() {
// retry the failed file sync at break point // retry the failed file sync at break point

View File

@ -635,8 +635,8 @@ impl SyncService {
bail!("File already exists"); bail!("File already exists");
} }
let (index_start, index_end, all_chunks) = match maybe_range { let (index_start, index_end) = match maybe_range {
Some((start, end)) => (start, end, false), Some((start, end)) => (start, end),
None => { None => {
let start = match Self::tx_sync_start_index(&self.store, &tx).await? { let start = match Self::tx_sync_start_index(&self.store, &tx).await? {
Some(s) => s, Some(s) => s,
@ -646,7 +646,7 @@ impl SyncService {
return Ok(()); return Ok(());
} }
}; };
(start, num_chunks, true) (start, num_chunks)
} }
}; };
@ -658,7 +658,7 @@ impl SyncService {
self.config, self.config,
tx.id(), tx.id(),
tx.start_entry_index(), tx.start_entry_index(),
FileSyncGoal::new(num_chunks, index_start, index_end, all_chunks), FileSyncGoal::new(num_chunks, index_start, index_end),
self.ctx.clone(), self.ctx.clone(),
self.store.clone(), self.store.clone(),
self.file_location_cache.clone(), self.file_location_cache.clone(),

View File

@ -68,7 +68,7 @@ class ZgsNode(TestNode):
os.mkdir(self.data_dir) os.mkdir(self.data_dir)
log_config_path = os.path.join(self.data_dir, self.config["log_config_file"]) log_config_path = os.path.join(self.data_dir, self.config["log_config_file"])
with open(log_config_path, "w") as f: with open(log_config_path, "w") as f:
f.write("trace,hyper=info,h2=info") f.write("debug,hyper=info,h2=info")
initialize_toml_config(self.config_file, self.config) initialize_toml_config(self.config_file, self.config)