1 /* 2 * Copyright (c) 2023 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 #ifndef I_CLOUD_SYNCER_H 16 #define I_CLOUD_SYNCER_H 17 #include <cstdint> 18 #include <string> 19 #include "cloud/cloud_store_types.h" 20 #include "icloud_sync_storage_interface.h" 21 #include "query_sync_object.h" 22 #include "ref_object.h" 23 namespace DistributedDB { 24 using DownloadList = std::vector<std::tuple<std::string, Type, OpType, std::map<std::string, Assets>, Key, 25 std::vector<Type>, Timestamp>>; 26 class ICloudSyncer : public virtual RefObject { 27 public: 28 using TaskId = uint64_t; 29 struct CloudTaskInfo { 30 bool priorityTask = false; 31 bool compensatedTask = false; 32 bool pause = false; 33 bool resume = false; 34 SyncMode mode = SyncMode::SYNC_MODE_PUSH_ONLY; 35 ProcessStatus status = ProcessStatus::PREPARED; 36 int errCode = 0; 37 TaskId taskId = 0u; 38 int64_t timeout = 0; 39 SyncProcessCallback callback; 40 std::vector<std::string> table; 41 std::vector<std::string> devices; 42 std::vector<QuerySyncObject> queryList; 43 std::vector<std::string> users; 44 LockAction lockAction = LockAction::INSERT; 45 bool merge = false; 46 std::string storeId; 47 std::string prepareTraceId; 48 }; 49 50 struct InnerProcessInfo { 51 std::string tableName; 52 ProcessStatus tableStatus = ProcessStatus::PREPARED; 53 Info downLoadInfo; 54 Info upLoadInfo; 55 }; 56 57 struct WithoutRowIdData { 58 std::vector<size_t> insertData = {}; 59 std::vector<std::tuple<size_t, size_t>> updateData = {}; 60 std::vector<std::tuple<size_t, size_t>> assetInsertData = {}; 61 }; 62 63 struct SyncParam { 64 DownloadData downloadData; 65 ChangedData changedData; 66 InnerProcessInfo info; 67 DownloadList assetsDownloadList; 68 std::string cloudWaterMark; 69 std::vector<std::string> pkColNames; 70 std::set<Key> deletePrimaryKeySet; 71 std::set<Key> dupHashKeySet; 72 std::string tableName; 73 bool isSinglePrimaryKey = false; 74 bool isLastBatch = false; 75 WithoutRowIdData withoutRowIdData; 76 std::vector<std::vector<Type>> insertPk; 77 }; 78 79 struct DataInfo { 80 DataInfoWithLog localInfo; 81 LogInfo cloudLogInfo; 82 }; 83 84 virtual std::string GetIdentify() const = 0; 85 86 virtual bool IsClosed() const = 0; 87 }; 88 } 89 #endif // I_CLOUD_SYNCER_H 90