MCPcopy Create free account
hub / github.com/baidu/tera / UpdateFlashFile

Method UpdateFlashFile

src/leveldb/util/env_flash.cc:573–608  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

571}
572
573void FlashEnv::UpdateFlashFile(const std::string& fname, uint64_t fsize) {
574 std::string local_fname = FlashEnv::FlashPath(fname) + fname;
575 Status copy_status = CopyToLocal(local_fname, dfs_env_, fname, fsize, vanish_allowed_);
576
577 MutexLock l(&update_flash_mutex_);
578 if (copy_status.ok()) {
579 UpdateFlashTask& task = update_flash_waiting_files_[fname];
580 LOG(INFO) << "[env_flash] copy to local success, id: " << task.id << ", prio: " << task.priority
581 << ", file: " << local_fname.c_str()
582 << ", pend: " << update_flash_threads_.GetPendingTaskNum();
583 update_flash_waiting_files_.erase(fname);
584 } else {
585 UpdateFlashTask& task = update_flash_waiting_files_[fname];
586 LOG(WARNING) << "[env_flash] copy to local fail [" << copy_status.ToString().c_str()
587 << "], id: " << task.id << ", prio: " << task.priority
588 << ", file: " << local_fname.c_str()
589 << ", pend: " << update_flash_threads_.GetPendingTaskNum();
590
591 task.priority >>= 1; // cut down priority to half
592 if (task.priority > 0) {
593 UpdateFlashFileParam* param = new UpdateFlashFileParam;
594 param->flash_env = this;
595 param->fname = fname;
596 param->fsize = fsize;
597
598 task.id = update_flash_threads_.Schedule(UpdateFlashFileFunc, param, (double)task.priority,
599 update_flash_retry_interval_millis_);
600 LOG(INFO) << "[env_flash] schedule copy to local after "
601 << update_flash_retry_interval_millis_ << " ms, id: " << task.id
602 << ", prio: " << task.priority << ", file: " << local_fname.c_str();
603 } else {
604 LOG(INFO) << "[env_flash] abort schedule copy to local, file: " << local_fname.c_str();
605 update_flash_waiting_files_.erase(fname);
606 }
607 }
608}
609
610void FlashEnv::TryRollbackPersistentCacheFiles() {
611 for (auto& flash_path : flash_paths_) {

Callers 1

UpdateFlashFileFuncFunction · 0.80

Calls 5

CopyToLocalFunction · 0.85
GetPendingTaskNumMethod · 0.80
okMethod · 0.45
ToStringMethod · 0.45
ScheduleMethod · 0.45

Tested by

no test coverage detected