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 VERSION_H
17 #define VERSION_H
18 
19 #include <string>
20 #include <cstdint>
21 
22 namespace DistributedDB {
23 // Version Regulation:
24 // Module version is always equal to the max version of its submodule.
25 // If a module or submodule upgrade to higher version, DO NOT simply increase current version by 1.
26 //      First: you have to preserve current version by renaming it as a historical version.
27 //      Second: Update the current version to the version to be release.
28 //      Finally: Update its parent module's version if exist.
29 // Why we update the current version to the version to be release? For example, if module A has submodule B and C,
30 // if now version of B is 105, and C is 101, thus version of A is 105; if now release version is 106 and we upgrade
31 // submodule C, if we simply change version of C to 102 then version of A is still 105, but if we change version of C
32 // to 106 then version of A is now 106, so we can know that something had changed for module A.
33 constexpr const char *SOFTWARE_VERSION_STRING = "1.1.5"; // DistributedDB current version string.
34 constexpr uint32_t SOFTWARE_VERSION_BASE = 100; // Software version base value, do not change it
35 constexpr uint32_t SOFTWARE_VERSION_RELEASE_1_0 = SOFTWARE_VERSION_BASE + 1; // 1 for first released version
36 constexpr uint32_t SOFTWARE_VERSION_RELEASE_2_0 = SOFTWARE_VERSION_BASE + 2; // 2 for second released version
37 constexpr uint32_t SOFTWARE_VERSION_RELEASE_3_0 = SOFTWARE_VERSION_BASE + 3; // 3 for third released version
38 constexpr uint32_t SOFTWARE_VERSION_RELEASE_4_0 = SOFTWARE_VERSION_BASE + 4; // 4 for fourth released version
39 constexpr uint32_t SOFTWARE_VERSION_RELEASE_5_0 = SOFTWARE_VERSION_BASE + 5; // 5 for fifth released version
40 constexpr uint32_t SOFTWARE_VERSION_RELEASE_6_0 = SOFTWARE_VERSION_BASE + 6; // 6 for sixth released version
41 // check both device has security label at 107
42 constexpr uint32_t SOFTWARE_VERSION_RELEASE_7_0 = SOFTWARE_VERSION_BASE + 7; // 7 for seventh released version
43 // kv ability sync with 2 packet at 108
44 constexpr uint32_t SOFTWARE_VERSION_RELEASE_8_0 = SOFTWARE_VERSION_BASE + 8; // 8 for eighth released version
45 // 109 version add field in request packet
46 // add schema version in ability request
47 // add schema version, system time offset, sender local time offset in data request
48 constexpr uint32_t SOFTWARE_VERSION_RELEASE_9_0 = SOFTWARE_VERSION_BASE + 9; // 9 for ninth released version
49 constexpr uint32_t SOFTWARE_VERSION_EARLIEST = SOFTWARE_VERSION_RELEASE_1_0;
50 constexpr uint32_t SOFTWARE_VERSION_CURRENT = SOFTWARE_VERSION_RELEASE_9_0;
51 constexpr int VERSION_INVALID = INT32_MAX;
52 
53 // Storage Related Version
54 // LocalNaturalStore Related Version
55 constexpr int LOCAL_STORE_VERSION_CURRENT = SOFTWARE_VERSION_RELEASE_1_0;
56 // SingleVerNaturalStore Related Version
57 constexpr int SINGLE_VER_STORE_VERSION_V1 = SOFTWARE_VERSION_RELEASE_1_0;
58 constexpr int SINGLE_VER_STORE_VERSION_V2 = SOFTWARE_VERSION_RELEASE_2_0;
59 constexpr int SINGLE_VER_STORE_VERSION_V3 = SOFTWARE_VERSION_RELEASE_3_0;
60 // 104 add modify time and create time into sync_data
61 constexpr int SINGLE_VER_STORE_VERSION_V4 = SOFTWARE_VERSION_RELEASE_4_0;
62 constexpr int SINGLE_VER_STORE_VERSION_CURRENT = SINGLE_VER_STORE_VERSION_V4;
63 // MultiVerNaturalStore Related Version
64 constexpr uint32_t VERSION_FILE_VERSION_CURRENT = 1;
65 constexpr uint32_t MULTI_VER_STORE_VERSION_CURRENT = SOFTWARE_VERSION_RELEASE_1_0;
66 constexpr int MULTI_VER_COMMIT_STORAGE_VERSION_CURRENT = SOFTWARE_VERSION_RELEASE_1_0;
67 constexpr int MULTI_VER_DATA_STORAGE_VERSION_CURRENT = SOFTWARE_VERSION_RELEASE_1_0;
68 constexpr int MULTI_VER_METADATA_STORAGE_VERSION_CURRENT = SOFTWARE_VERSION_RELEASE_1_0;
69 constexpr int MULTI_VER_VALUESLICE_STORAGE_VERSION_CURRENT = SOFTWARE_VERSION_RELEASE_1_0;
70 
71 // Syncer Related Version
72 constexpr int TIME_SYNC_VERSION_V1 = SOFTWARE_VERSION_RELEASE_1_0; // time sync proctol added in version 101.
73 constexpr int ABILITY_SYNC_VERSION_V1 = SOFTWARE_VERSION_RELEASE_2_0; // Ability sync proctol added in version 102.
74 constexpr uint32_t SINGLE_VER_SYNC_PROCTOL_V1 = SOFTWARE_VERSION_RELEASE_1_0; // The 1st version num
75 constexpr uint32_t SINGLE_VER_SYNC_PROCTOL_V2 = SOFTWARE_VERSION_RELEASE_2_0; // The 2nd version num
76 constexpr uint32_t SINGLE_VER_SYNC_PROCTOL_V3 = SOFTWARE_VERSION_RELEASE_3_0; // The third version num
77 
78 // Local Meta Data Version
79 constexpr uint32_t LOCAL_META_DATA_VERSION_V1 = SOFTWARE_VERSION_RELEASE_8_0;
80 constexpr uint32_t LOCAL_META_DATA_VERSION_V2 = SOFTWARE_VERSION_RELEASE_9_0;
81 } // namespace DistributedDB
82 
83 #endif // VERSION_H