| 276 | } |
| 277 | |
| 278 | bool TabletNodeImpl::InitCacheSystem() { |
| 279 | sysinfo_.SetPersistentCacheSize(0); |
| 280 | if (!io::GetCachePaths().empty()) { |
| 281 | if (FLAGS_tera_enable_persistent_cache) { |
| 282 | LOG(INFO) << "Enable persistent cache."; |
| 283 | std::shared_ptr<leveldb::PersistentCache> persistent_cache; |
| 284 | auto status = ::tera::io::GetPersistentCache(&persistent_cache); |
| 285 | |
| 286 | if (!status.ok() || !persistent_cache) { |
| 287 | LOG(ERROR) << "Init persistent cache failed: " << status.ToString() << ", exit on error."; |
| 288 | return false; |
| 289 | } |
| 290 | sysinfo_.SetPersistentCacheSize(persistent_cache->GetCapacity()); |
| 291 | } else { |
| 292 | LOG(INFO) << "Enable flash env."; |
| 293 | // compitable with legacy FlashEnv |
| 294 | leveldb::FlashEnv* flash_env = (leveldb::FlashEnv*)io::LeveldbFlashEnv(); |
| 295 | if (FLAGS_tera_tabletnode_clean_persistent_cache_paths) { |
| 296 | for (const auto& path : io::GetCachePaths()) { |
| 297 | auto s = leveldb::Env::Default()->DeleteDirRecursive(path); |
| 298 | if (!s.ok()) { |
| 299 | LOG(WARNING) << "Remove persistent cache paths " << path << " failed: " << s.ToString(); |
| 300 | } |
| 301 | } |
| 302 | } |
| 303 | assert(flash_env); |
| 304 | flash_env->SetFlashPath(FLAGS_tera_tabletnode_cache_paths, |
| 305 | FLAGS_tera_io_cache_path_vanish_allowed); |
| 306 | flash_env->SetUpdateFlashThreadNumber(FLAGS_tera_tabletnode_cache_update_thread_num); |
| 307 | flash_env->SetIfForceReadFromCache(FLAGS_tera_tabletnode_cache_force_read_from_cache); |
| 308 | flash_env->TryRollbackPersistentCacheFiles(); |
| 309 | } |
| 310 | } |
| 311 | return true; |
| 312 | } |
| 313 | |
| 314 | bool TabletNodeImpl::Exit() { |
| 315 | running_ = false; |
nothing calls this directly
no test coverage detected