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 #ifndef SYNC_TYPES_H 17 #define SYNC_TYPES_H 18 19 #include <cstdint> 20 #include "query_sync_object.h" 21 #include "sync_config.h" 22 23 namespace DistributedDB { 24 enum MessageId { 25 TIME_SYNC_MESSAGE = 1, 26 DATA_SYNC_MESSAGE, 27 COMMIT_HISTORY_SYNC_MESSAGE, 28 MULTI_VER_DATA_SYNC_MESSAGE, 29 VALUE_SLICE_SYNC_MESSAGE, 30 LOCAL_DATA_CHANGED, 31 ABILITY_SYNC_MESSAGE, 32 QUERY_SYNC_MESSAGE, 33 CONTROL_SYNC_MESSAGE, 34 REMOTE_EXECUTE_MESSAGE, 35 UNKNOW_MESSAGE, 36 }; 37 38 enum SyncModeType { 39 PUSH, 40 PULL, 41 PUSH_AND_PULL, 42 AUTO_PUSH, 43 AUTO_PULL, 44 RESPONSE_PULL, 45 QUERY_PUSH, 46 QUERY_PULL, 47 QUERY_PUSH_PULL, 48 SUBSCRIBE_QUERY, 49 UNSUBSCRIBE_QUERY, 50 AUTO_SUBSCRIBE_QUERY, 51 INVALID_MODE 52 }; 53 54 enum class SyncType { 55 MANUAL_FULL_SYNC_TYPE = 1, 56 AUTO_SYNC_TYPE, 57 QUERY_SYNC_TYPE, 58 INVALID_SYNC_TYPE, 59 }; 60 61 enum ControlCmdType { 62 SUBSCRIBE_QUERY_CMD, 63 UNSUBSCRIBE_QUERY_CMD, 64 INVALID_CONTROL_CMD, 65 }; 66 67 struct UpdateWaterMark { 68 bool normalUpdateMark = false; 69 bool deleteUpdateMark = false; 70 }; 71 72 struct InternalSyncParma { 73 std::vector<std::string> devices; 74 int mode = 0; 75 bool isQuerySync = false; 76 QuerySyncObject syncQuery; 77 }; 78 79 constexpr int32_t UNKNOWN_SECURITY_LABEL = -1; 80 constexpr int NOT_SUPPORT_SEC_CLASSIFICATION = 0xff; 81 constexpr int FAILED_GET_SEC_CLASSIFICATION = 0x55; 82 constexpr uint8_t QUERY_SYNC_MODE_BASE = SyncModeType::QUERY_PUSH; 83 constexpr int AUTO_RETRY_TIMES = 3; 84 constexpr int MANUAL_RETRY_TIMES = 1; 85 constexpr int TIME_SYNC_WAIT_TIME = 5000; // 5s 86 constexpr uint64_t MAX_PACKETID = 10000000000; // max packetId 87 constexpr int NOTIFY_MIN_MTU_SIZE = 30 * 1024; // 30k 88 89 constexpr int MAX_SUBSCRIBE_NUM_PER_DEV = 4; 90 constexpr int MAX_SUBSCRIBE_NUM_PER_DB = 8; 91 constexpr size_t MAX_DEVICES_NUM = 32; 92 93 // index 0 for packetId in data request 94 // if ack reserve size is 1, reserve is {localWaterMark} 95 // if ack reserve size is above 2, reserve is {localWaterMark, packetId, deletedWaterMark...} 96 constexpr uint32_t REQUEST_PACKET_RESERVED_INDEX_PACKETID = 0; 97 constexpr uint32_t ACK_PACKET_RESERVED_INDEX_PACKETID = 1; // index 1 for packetId 98 constexpr uint32_t ACK_PACKET_RESERVED_INDEX_LOCAL_WATER_MARK = 0; // index 0 for localWaterMark 99 constexpr uint32_t ACK_PACKET_RESERVED_INDEX_DELETE_WATER_MARK = 2; // index 2 for deleteDataWaterMark 100 constexpr uint64_t MAX_TIMESTAMP = INT64_MAX; 101 constexpr uint8_t REMOVE_DEVICE_DATA_MARK = 1; 102 constexpr uint8_t SUPPORT_MARK = 1; // used for set is support one ability 103 } 104 #endif