| 1055 | } |
| 1056 | |
| 1057 | Status DataCache::Partition::Dump() { |
| 1058 | std::unique_lock<SpinLock> partition_lock(lock_); |
| 1059 | LOG(INFO) << Substitute("Partition $0 start dumping.", index_); |
| 1060 | DumpData dump_data; |
| 1061 | RETURN_IF_ERROR(DumpCacheFiles(dump_data)); |
| 1062 | RETURN_IF_ERROR(DumpMetaCache(dump_data)); |
| 1063 | std::ofstream file; |
| 1064 | file.open(JoinPathSegments(path_, DUMP_FILE_NAME), std::ofstream::binary); |
| 1065 | if (!file) return Status(Substitute("Failed to open $0", DUMP_FILE_NAME)); |
| 1066 | try { |
| 1067 | dump_data.serialize(file); |
| 1068 | } catch (boost::archive::archive_exception& e) { |
| 1069 | LOG(ERROR) << Substitute("Partition $0 failed to serialize dump file.", index_) |
| 1070 | << e.what(); |
| 1071 | return Status("Failed to serialize dump file."); |
| 1072 | } |
| 1073 | file.close(); |
| 1074 | LOG(INFO) << Substitute("Partition $0 dump successfully.", index_); |
| 1075 | return Status::OK(); |
| 1076 | } |
| 1077 | |
| 1078 | Status DataCache::Partition::Load() { |
| 1079 | std::ifstream file; |