(&mut self, path: &Path)
| 206 | } |
| 207 | |
| 208 | pub fn load_event_file(&mut self, path: &Path) -> crate::Result<()> { |
| 209 | log::debug!("Loading event file {}", path.display()); |
| 210 | let mut event_reader = JournalReader::open(path)?; |
| 211 | for event in &mut event_reader { |
| 212 | let event = event.map_err(|error| { |
| 213 | crate::Error::DeserializationError(format!( |
| 214 | "Journal load error: {error:?}.\nIt appears that the journal file is corrupted." |
| 215 | )) |
| 216 | })?; |
| 217 | match event.payload { |
| 218 | EventPayload::WorkerConnected(worker_id, config) => { |
| 219 | log::debug!("Replaying: WorkerConnected {worker_id}"); |
| 220 | self.max_worker_id = self.max_worker_id.max(worker_id.as_num()); |
| 221 | |
| 222 | // If we see a worker connected from an allocation, it should have occurred |
| 223 | // in the log *after* the corresponding allocation has been submitted from a |
| 224 | // queue. |
| 225 | if let Some(info) = config.get_manager_info() |
| 226 | && let Some(queue_id) = self.allocation_to_queue_id.get(&info.allocation_id) |
| 227 | { |
| 228 | self.queue_to_worker_resources |
| 229 | .insert(*queue_id, config.resources); |
| 230 | } |
| 231 | } |
| 232 | EventPayload::WorkerLost(worker_id, reason) => { |
| 233 | if reason.is_failure() { |
| 234 | for job in self.jobs.values_mut() { |
| 235 | job.increase_crash_counters(worker_id); |
| 236 | } |
| 237 | } |
| 238 | } |
| 239 | EventPayload::WorkerOverviewReceived(_) => {} |
| 240 | EventPayload::Submit { |
| 241 | job_id, |
| 242 | closed_job, |
| 243 | serialized_desc, |
| 244 | } => { |
| 245 | log::debug!("Replaying: JobTasksCreated {job_id}"); |
| 246 | let submit_request: SubmitRequest = serialized_desc.deserialize()?; |
| 247 | if closed_job { |
| 248 | let mut job = RestorerJob::new(submit_request.job_desc, false); |
| 249 | job.add_submit(SubmittedJobDescription::at( |
| 250 | event.time, |
| 251 | submit_request.submit_desc, |
| 252 | )); |
| 253 | self.add_job(job_id, job); |
| 254 | } else if let Some(job) = self.get_job_mut(job_id) { |
| 255 | job.add_submit(SubmittedJobDescription::at( |
| 256 | event.time, |
| 257 | submit_request.submit_desc, |
| 258 | )); |
| 259 | } else { |
| 260 | log::warn!("Ignoring submit attachment to an non-existing job") |
| 261 | } |
| 262 | } |
| 263 | EventPayload::JobCompleted(job_id) => { |
| 264 | log::debug!("Replaying: JobCompleted {job_id}"); |
| 265 | self.jobs.remove(&job_id); |
no test coverage detected