1 /* 2 * Copyright (c) 2022 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 SINGLE_VER_RELATIONAL_SYNC_TASK_CONTEXT_H 17 #define SINGLE_VER_RELATIONAL_SYNC_TASK_CONTEXT_H 18 19 #ifdef RELATIONAL_STORE 20 #include "single_ver_sync_task_context.h" 21 22 namespace DistributedDB { 23 class SingleVerRelationalSyncTaskContext : public SingleVerSyncTaskContext { 24 public: 25 26 explicit SingleVerRelationalSyncTaskContext(); 27 28 DISABLE_COPY_ASSIGN_MOVE(SingleVerRelationalSyncTaskContext); 29 30 void Clear() override; 31 std::string GetQuerySyncId() const override; 32 std::string GetDeleteSyncId() const override; 33 34 void SetRelationalSyncStrategy(const RelationalSyncStrategy &strategy, bool isSchemaSync); 35 std::pair<bool, bool> GetSchemaSyncStatus(QuerySyncObject &querySyncObject) const override; 36 37 void SchemaChange() override; 38 39 bool IsSchemaCompatible() const override; 40 41 bool IsRemoteSupportFieldSync() const; 42 43 int GetDistributedSchema(RelationalSchemaObject &schemaObj) const; 44 protected: 45 ~SingleVerRelationalSyncTaskContext() override; 46 void CopyTargetData(const ISyncTarget *target, const TaskParam &taskParam) override; 47 48 mutable std::mutex querySyncIdMutex_; 49 std::string querySyncId_; 50 51 mutable std::mutex deleteSyncIdMutex_; 52 std::string deleteSyncId_; 53 54 // for relational syncStrategy 55 mutable std::mutex syncStrategyMutex_; 56 RelationalSyncStrategy relationalSyncStrategy_; 57 bool isSchemaSync_ = false; 58 }; 59 } 60 #endif // RELATIONAL_STORE 61 #endif // SINGLE_VER_RELATIONAL_SYNC_TASK_CONTEXT_H