diff options
author | Alex Auvolat <alex@adnab.me> | 2022-07-08 10:39:41 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-07-08 10:39:41 +0200 |
commit | d1cf1a0fa6952e84874f36f1dc66e4a978959d8f (patch) | |
tree | f65135f725b9f22ac2eac54e5023ab6a548549ec /src/block | |
parent | 0f660b086c23d13c91b0c55fd4d43017a09c1f4b (diff) | |
download | garage-d1cf1a0fa6952e84874f36f1dc66e4a978959d8f.tar.gz garage-d1cf1a0fa6952e84874f36f1dc66e4a978959d8f.zip |
Rename WorkerStatus to WorkerState
because it's a state in a state machine
Diffstat (limited to 'src/block')
-rw-r--r-- | src/block/manager.rs | 10 | ||||
-rw-r--r-- | src/block/repair.rs | 32 |
2 files changed, 21 insertions, 21 deletions
diff --git a/src/block/manager.rs b/src/block/manager.rs index 17d4a72d..e54fb992 100644 --- a/src/block/manager.rs +++ b/src/block/manager.rs @@ -776,16 +776,16 @@ impl Worker for ResyncWorker { async fn work( &mut self, _must_exit: &mut watch::Receiver<bool>, - ) -> Result<WorkerStatus, Error> { + ) -> Result<WorkerState, Error> { self.tranquilizer.reset(); match self.manager.resync_iter().await { Ok(ResyncIterResult::BusyDidSomething) => Ok(self .tranquilizer .tranquilize_worker(self.manager.background_tranquility)), - Ok(ResyncIterResult::BusyDidNothing) => Ok(WorkerStatus::Busy), + Ok(ResyncIterResult::BusyDidNothing) => Ok(WorkerState::Busy), Ok(ResyncIterResult::IdleFor(delay)) => { self.next_delay = delay; - Ok(WorkerStatus::Idle) + Ok(WorkerState::Idle) } Err(e) => { // The errors that we have here are only Sled errors @@ -799,12 +799,12 @@ impl Worker for ResyncWorker { } } - async fn wait_for_work(&mut self, _must_exit: &watch::Receiver<bool>) -> WorkerStatus { + async fn wait_for_work(&mut self, _must_exit: &watch::Receiver<bool>) -> WorkerState { select! { _ = tokio::time::sleep(self.next_delay) => (), _ = self.manager.resync_notify.notified() => (), }; - WorkerStatus::Busy + WorkerState::Busy } } diff --git a/src/block/repair.rs b/src/block/repair.rs index 26d1bd8f..cd5afe44 100644 --- a/src/block/repair.rs +++ b/src/block/repair.rs @@ -65,7 +65,7 @@ impl Worker for RepairWorker { async fn work( &mut self, _must_exit: &mut watch::Receiver<bool>, - ) -> Result<WorkerStatus, Error> { + ) -> Result<WorkerState, Error> { match self.block_iter.as_mut() { None => { // Phase 1: Repair blocks from RC table. @@ -101,7 +101,7 @@ impl Worker for RepairWorker { if batch_of_hashes.is_empty() { // move on to phase 2 self.block_iter = Some(BlockStoreIterator::new(&self.manager)); - return Ok(WorkerStatus::Busy); + return Ok(WorkerState::Busy); } for hash in batch_of_hashes.into_iter() { @@ -109,7 +109,7 @@ impl Worker for RepairWorker { self.next_start = Some(hash) } - Ok(WorkerStatus::Busy) + Ok(WorkerState::Busy) } Some(bi) => { // Phase 2: Repair blocks actually on disk @@ -118,15 +118,15 @@ impl Worker for RepairWorker { // so that we can offload them if necessary and then delete them locally. if let Some(hash) = bi.next().await? { self.manager.put_to_resync(&hash, Duration::from_secs(0))?; - Ok(WorkerStatus::Busy) + Ok(WorkerState::Busy) } else { - Ok(WorkerStatus::Done) + Ok(WorkerState::Done) } } } } - async fn wait_for_work(&mut self, _must_exit: &watch::Receiver<bool>) -> WorkerStatus { + async fn wait_for_work(&mut self, _must_exit: &watch::Receiver<bool>) -> WorkerState { unreachable!() } } @@ -282,10 +282,10 @@ impl Worker for ScrubWorker { async fn work( &mut self, _must_exit: &mut watch::Receiver<bool>, - ) -> Result<WorkerStatus, Error> { + ) -> Result<WorkerState, Error> { match self.rx_cmd.try_recv() { Ok(cmd) => self.handle_cmd(cmd).await, - Err(mpsc::error::TryRecvError::Disconnected) => return Ok(WorkerStatus::Done), + Err(mpsc::error::TryRecvError::Disconnected) => return Ok(WorkerState::Done), Err(mpsc::error::TryRecvError::Empty) => (), }; @@ -310,16 +310,16 @@ impl Worker for ScrubWorker { self.persister.save_async(&self.persisted).await?; self.work = ScrubWorkerState::Finished; self.tranquilizer.clear(); - Ok(WorkerStatus::Idle) + Ok(WorkerState::Idle) } } - _ => Ok(WorkerStatus::Idle), + _ => Ok(WorkerState::Idle), } } - async fn wait_for_work(&mut self, _must_exit: &watch::Receiver<bool>) -> WorkerStatus { + async fn wait_for_work(&mut self, _must_exit: &watch::Receiver<bool>) -> WorkerState { let (wait_until, command) = match &self.work { - ScrubWorkerState::Running(_) => return WorkerStatus::Busy, + ScrubWorkerState::Running(_) => return WorkerState::Busy, ScrubWorkerState::Paused(_, resume_time) => (*resume_time, ScrubWorkerCommand::Resume), ScrubWorkerState::Finished => ( self.persisted.time_last_complete_scrub + SCRUB_INTERVAL.as_millis() as u64, @@ -330,7 +330,7 @@ impl Worker for ScrubWorker { let now = now_msec(); if now >= wait_until { self.handle_cmd(command).await; - return WorkerStatus::Busy; + return WorkerState::Busy; } let delay = Duration::from_millis(wait_until - now); select! { @@ -338,13 +338,13 @@ impl Worker for ScrubWorker { cmd = self.rx_cmd.recv() => if let Some(cmd) = cmd { self.handle_cmd(cmd).await; } else { - return WorkerStatus::Done; + return WorkerState::Done; } } match &self.work { - ScrubWorkerState::Running(_) => WorkerStatus::Busy, - _ => WorkerStatus::Idle, + ScrubWorkerState::Running(_) => WorkerState::Busy, + _ => WorkerState::Idle, } } } |