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 DISTRIBUTEDDATAMGR_DFX_TYPES_H 17 #define DISTRIBUTEDDATAMGR_DFX_TYPES_H 18 19 #include <map> 20 #include <memory> 21 #include <string> 22 23 #include "db_meta_callback_delegate.h" 24 25 namespace OHOS { 26 namespace DistributedDataDfx { 27 struct ModuleName { 28 static const inline std::string DEVICE = "DEVICE"; 29 static const inline std::string USER = "USER"; 30 static const inline std::string RDB_STORE = "RDB_STORE"; 31 static const inline std::string KV_STORE = "KV_STORE"; 32 static const inline std::string CLOUD_SERVER = "CLOUD_SERVER"; 33 static const inline std::string CLOUD_SYNC_CALLBACK = "CLOUD_SYNC_CALLBACK"; 34 }; 35 36 enum class Fault { 37 // Service Fault 38 SF_SERVICE_PUBLISH = 0, 39 SF_GET_SERVICE = 1, 40 SF_CREATE_DIR = 2, 41 SF_DATABASE_CONFIG = 3, 42 SF_PROCESS_LABEL = 4, 43 SF_INIT_DELEGATE = 5, 44 45 // Runtime Fault 46 RF_OPEN_DB = 20, 47 RF_CLOSE_DB = 21, 48 RF_DELETE_DB = 22, 49 RF_DATA_SUBSCRIBE = 23, 50 RF_DATA_UNSUBSCRIBE = 24, 51 RF_CREATE_SNAPSHOT = 25, 52 RF_RELEASE_SNAPSHOT = 26, 53 RF_KEY_STORE_DAMAGE = 27, 54 RF_KEY_STORE_LOST = 28, 55 RF_DB_ROM = 29, 56 RF_GET_DB = 30, 57 RF_SUBCRIBE = 31, 58 RF_UNSUBCRIBE = 32, 59 RF_REPORT_THERAD_ERROR = 33, 60 61 // Communication Fault 62 CF_CREATE_SESSION = 40, 63 CF_CREATE_PIPE = 41, 64 CF_SEND_PIPE_BROKEN = 42, 65 CF_REV_PIPE_BROKEN = 43, 66 CF_SERVICE_DIED = 44, 67 CF_CREATE_ZDN = 45, 68 CF_QUERY_ZDN = 46, 69 70 // Database Fault 71 DF_DB_DAMAGE = 60, 72 DF_DB_REKEY_FAILED = 61, 73 DF_DB_CORRUPTED = 62, 74 75 // Cloud Sync Fault 76 CSF_CLOUD_INFO = 70, 77 CSF_SUBSCRIBE = 71, 78 CSF_UNSUBSCRIBE = 72, 79 CSF_APP_SCHEMA = 73, 80 CSF_CONNECT_CLOUD_ASSET_LOADER = 74, 81 CSF_CONNECT_CLOUD_DB = 75, 82 CSF_BATCH_INSERT = 76, 83 CSF_BATCH_UPDATE = 77, 84 CSF_BATCH_DELETE = 78, 85 CSF_BATCH_QUERY = 79, 86 CSF_LOCK = 80, 87 CSF_SHARE = 81, 88 CSF_DOWNLOAD_ASSETS = 82, 89 CSF_GS_CREATE_DISTRIBUTED_TABLE = 83, 90 CSF_GS_CLOUD_SYNC = 84, 91 CSF_GS_CLOUD_CLEAN = 85, 92 }; 93 94 enum class FaultType { 95 SERVICE_FAULT = 0, 96 RUNTIME_FAULT = 1, 97 DATABASE_FAULT = 2, 98 COMM_FAULT = 3, 99 }; 100 101 enum class BehaviourType { 102 DATABASE_BACKUP = 0, 103 DATABASE_RECOVERY = 1, 104 }; 105 106 enum class SecurityInfo { 107 PERMISSIONS_APPID_FAILE = 0, 108 PERMISSIONS_DEVICEID_FAILE = 1, 109 PERMISSIONS_TOKENID_FAILE = 2, 110 SENSITIVE_LEVEL_FAILE = 3, 111 }; 112 113 struct FaultMsg { 114 FaultType faultType; 115 std::string moduleName; 116 std::string interfaceName; 117 Fault errorType; 118 }; 119 120 struct DBFaultMsg { 121 std::string appId; 122 std::string storeId; 123 std::string moduleName; 124 Fault errorType; 125 }; 126 127 struct CommFaultMsg { 128 std::string userId; 129 std::string appId; 130 std::string storeId; 131 std::vector<std::string> deviceId; 132 std::vector<int32_t> errorCode; 133 }; 134 135 struct ArkDataFaultMsg { 136 std::string faultType; 137 std::string bundleName; 138 std::string moduleName; 139 std::string storeName; 140 std::string businessType; 141 int32_t errorType; 142 std::string appendixMsg; 143 }; 144 145 struct SecurityPermissionsMsg { 146 std::string userId; 147 std::string appId; 148 std::string storeId; 149 std::string deviceId; 150 SecurityInfo securityInfo; 151 }; 152 153 struct SecuritySensitiveLevelMsg { 154 std::string deviceId; 155 int deviceSensitiveLevel; 156 int optionSensitiveLevel; 157 SecurityInfo securityInfo; 158 }; 159 160 struct BehaviourMsg { 161 std::string userId; 162 std::string appId; 163 std::string storeId; 164 BehaviourType behaviourType; 165 std::string extensionInfo; 166 }; 167 168 struct UdmfBehaviourMsg { 169 std::string appId; 170 std::string channel; 171 int64_t dataSize; 172 std::string dataType; 173 std::string operation; 174 std::string result; 175 }; 176 177 struct VisitStat { 178 std::string appId; 179 std::string interfaceName; GetKeyVisitStat180 API_EXPORT std::string GetKey() const 181 { 182 return appId + interfaceName; 183 } 184 }; 185 186 struct TrafficStat { 187 std::string appId; 188 std::string deviceId; 189 int sendSize; 190 int receivedSize; GetKeyTrafficStat191 API_EXPORT std::string GetKey() const 192 { 193 return appId + deviceId; 194 } 195 }; 196 197 struct DbStat { 198 std::string userId; 199 std::string appId; 200 std::string storeId; 201 int dbSize; 202 std::shared_ptr<DistributedKv::DbMetaCallbackDelegate> delegate; 203 GetKeyDbStat204 API_EXPORT std::string GetKey() const 205 { 206 return userId + appId + storeId; 207 } 208 }; 209 210 struct DbPerformanceStat { 211 std::string appId; 212 std::string storeId; 213 uint64_t currentTime; 214 uint64_t completeTime; 215 int size; 216 std::string srcDevId; 217 std::string dstDevId; 218 }; 219 220 struct ApiPerformanceStat { 221 std::string interfaceName; 222 uint64_t costTime; 223 uint64_t averageTime; 224 uint64_t worstTime; GetKeyApiPerformanceStat225 API_EXPORT std::string GetKey() const 226 { 227 return interfaceName; 228 } 229 }; 230 231 enum class ReportStatus { 232 SUCCESS = 0, 233 ERROR = 1, 234 }; 235 } // namespace DistributedDataDfx 236 } // namespace OHOS 237 #endif // DISTRIBUTEDDATAMGR_DFX_TYPES_H 238