1 /* 2 * Copyright (c) 2021 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 #include "single_ver_sync_target.h" 17 18 #include <string> 19 20 #include "db_errno.h" 21 #include "sync_operation.h" 22 #include "log_print.h" 23 24 namespace DistributedDB { SingleVerSyncTarget()25SingleVerSyncTarget::SingleVerSyncTarget() 26 : endWaterMark_(0), 27 query_(QuerySyncObject()) 28 { 29 } 30 ~SingleVerSyncTarget()31SingleVerSyncTarget::~SingleVerSyncTarget() 32 { 33 } 34 SetSyncOperation(SyncOperation * operation)35void SingleVerSyncTarget::SetSyncOperation(SyncOperation *operation) 36 { 37 SyncTarget::SetSyncOperation(operation); 38 if ((operation != nullptr) && !operation->IsKilled()) { 39 operation->GetQuery(query_); 40 isQuerySync_ = operation->IsQuerySync(); 41 } 42 } 43 SetEndWaterMark(WaterMark waterMark)44void SingleVerSyncTarget::SetEndWaterMark(WaterMark waterMark) 45 { 46 endWaterMark_ = waterMark; 47 } 48 GetEndWaterMark() const49WaterMark SingleVerSyncTarget::GetEndWaterMark() const 50 { 51 return endWaterMark_; 52 } 53 SetResponseSessionId(uint32_t responseSessionId)54void SingleVerSyncTarget::SetResponseSessionId(uint32_t responseSessionId) 55 { 56 responseSessionId_ = responseSessionId; 57 } 58 GetResponseSessionId() const59uint32_t SingleVerSyncTarget::GetResponseSessionId() const 60 { 61 return responseSessionId_; 62 } 63 SetQuery(const QuerySyncObject & query)64void SingleVerSyncTarget::SetQuery(const QuerySyncObject &query) 65 { 66 query_ = query; 67 } 68 GetQuery() const69QuerySyncObject SingleVerSyncTarget::GetQuery() const 70 { 71 return query_; 72 } 73 SetQuerySync(bool isQuerySync)74void SingleVerSyncTarget::SetQuerySync(bool isQuerySync) 75 { 76 isQuerySync_ = isQuerySync; 77 } 78 IsQuerySync() const79bool SingleVerSyncTarget::IsQuerySync() const 80 { 81 return isQuerySync_; 82 } 83 } // namespace DistributedDB