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 #include "cloud_force_pull_strategy.h"
16 #include "cloud/cloud_storage_utils.h"
17
18 namespace DistributedDB {
19
TagSyncDataStatus(bool existInLocal,bool isCloudWin,const LogInfo & localInfo,const LogInfo & cloudInfo)20 OpType CloudForcePullStrategy::TagSyncDataStatus(bool existInLocal, bool isCloudWin, const LogInfo &localInfo,
21 const LogInfo &cloudInfo)
22 {
23 if (CloudStorageUtils::IsDataLocked(localInfo.status)) {
24 return OpType::LOCKED_NOT_HANDLE;
25 }
26 if (existInLocal) {
27 if (IsIgnoreUpdate(localInfo)) {
28 return OpType::NOT_HANDLE;
29 }
30 if (!IsDelete(localInfo) && IsDelete(cloudInfo)) {
31 return OpType::DELETE;
32 } else if (IsDelete(cloudInfo)) {
33 return OpType::UPDATE_TIMESTAMP;
34 }
35 if (IsDelete(localInfo)) {
36 return OpType::INSERT;
37 }
38 return TagUpdateLocal(cloudInfo, localInfo);
39 }
40 bool gidEmpty = localInfo.cloudGid.empty();
41 if (IsDelete(cloudInfo)) {
42 return gidEmpty ? OpType::NOT_HANDLE : OpType::DELETE;
43 }
44 if (gidEmpty) {
45 return OpType::INSERT;
46 }
47 return TagUpdateLocal(cloudInfo, localInfo);
48 }
49
JudgeUpdateCursor()50 bool CloudForcePullStrategy::JudgeUpdateCursor()
51 {
52 return true;
53 }
54
JudgeUpload()55 bool CloudForcePullStrategy::JudgeUpload()
56 {
57 return false;
58 }
59 }