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_REPORTER_H 17 #define DISTRIBUTEDDATAMGR_REPORTER_H 18 19 #include <memory> 20 #include <mutex> 21 #include "dfx_types.h" 22 #include "statistic_reporter.h" 23 #include "fault_reporter.h" 24 #include "behaviour_reporter.h" 25 #include "executor_pool.h" 26 27 namespace OHOS { 28 namespace DistributedDataDfx { 29 class Reporter { 30 public: 31 KVSTORE_API static Reporter* GetInstance(); 32 KVSTORE_API FaultReporter* ServiceFault(); 33 KVSTORE_API FaultReporter* RuntimeFault(); 34 KVSTORE_API FaultReporter* DatabaseFault(); 35 KVSTORE_API FaultReporter* CommunicationFault(); 36 37 KVSTORE_API StatisticReporter<DbStat>* DatabaseStatistic(); 38 KVSTORE_API StatisticReporter<VisitStat>* VisitStatistic(); 39 KVSTORE_API StatisticReporter<TrafficStat>* TrafficStatistic(); 40 KVSTORE_API StatisticReporter<ApiPerformanceStat>* ApiPerformanceStatistic(); 41 42 KVSTORE_API BehaviourReporter* BehaviourReporter(); SetThreadPool(std::shared_ptr<ExecutorPool> executors)43 void SetThreadPool(std::shared_ptr<ExecutorPool> executors) 44 { 45 executors_ = executors; 46 if (executors != nullptr) { 47 ServiceFault(); 48 RuntimeFault(); 49 DatabaseFault(); 50 CommunicationFault(); 51 DatabaseStatistic(); 52 VisitStatistic(); 53 TrafficStatistic(); 54 ApiPerformanceStatistic(); 55 BehaviourReporter(); 56 } 57 }; 58 59 private: 60 std::shared_ptr<ExecutorPool> executors_; 61 }; 62 } // namespace DistributedDataDfx 63 } // namespace OHOS 64 #endif // DISTRIBUTEDDATAMGR_REPORTER_H 65