1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef PROCESS_RECORDER_H 17 #define PROCESS_RECORDER_H 18 19 #include <mutex> 20 #include "store_types.h" 21 22 namespace DistributedDB { 23 class ProcessRecorder { 24 public: 25 ProcessRecorder() = default; 26 ~ProcessRecorder() = default; 27 28 void ClearRecord(); 29 30 bool IsDownloadFinish(int userIndex, const std::string &table) const; 31 void MarkDownloadFinish(int userIndex, const std::string &table, bool finish); 32 33 bool IsUploadFinish(int userIndex, const std::string &table) const; 34 void MarkUploadFinish(int userIndex, const std::string &table, bool finish); 35 private: 36 bool IsRecordFinish(int userIndex, const std::string &table, 37 const std::map<int, std::map<std::string, bool>> &record) const; 38 void RecordFinish(int userIndex, const std::string &table, bool finish, 39 std::map<int, std::map<std::string, bool>> &record); 40 41 mutable std::mutex recordMutex_; 42 std::map<int, std::map<std::string, bool>> downloadRecord_; // record table download finish 43 std::map<int, std::map<std::string, bool>> uploadRecord_; // record table upload finish 44 }; 45 } 46 47 #endif // PROCESS_RECORDER_H