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 #include "reporter.h"
17 #include "fault/communication_fault_impl.h"
18 #include "fault/database_fault_impl.h"
19 #include "fault/runtime_fault_impl.h"
20 #include "fault/service_fault_impl.h"
21 
22 #include "statistic/traffic_statistic_impl.h"
23 #include "statistic/visit_statistic_impl.h"
24 #include "statistic/database_statistic_impl.h"
25 #include "statistic/api_performance_statistic_impl.h"
26 
27 #include "behaviour/behaviour_reporter_impl.h"
28 
29 namespace OHOS {
30 namespace DistributedDataDfx {
GetInstance()31 Reporter* Reporter::GetInstance()
32 {
33     static Reporter reporter;
34     return &reporter;
35 }
36 
CommunicationFault()37 FaultReporter* Reporter::CommunicationFault()
38 {
39     static CommunicationFaultImpl communicationFault;
40     communicationFault.SetThreadPool(executors_);
41     return &communicationFault;
42 }
43 
DatabaseFault()44 FaultReporter* Reporter::DatabaseFault()
45 {
46     static DatabaseFaultImpl databaseFault;
47     databaseFault.SetThreadPool(executors_);
48     return &databaseFault;
49 }
50 
RuntimeFault()51 FaultReporter* Reporter::RuntimeFault()
52 {
53     static RuntimeFaultImpl runtimeFault;
54     runtimeFault.SetThreadPool(executors_);
55     return &runtimeFault;
56 }
57 
ServiceFault()58 FaultReporter* Reporter::ServiceFault()
59 {
60     static ServiceFaultImpl serviceFault;
61     serviceFault.SetThreadPool(executors_);
62     return &serviceFault;
63 }
64 
TrafficStatistic()65 StatisticReporter<TrafficStat>* Reporter::TrafficStatistic()
66 {
67     static TrafficStatisticImpl trafficStatistic;
68     trafficStatistic.SetThreadPool(executors_);
69     return &trafficStatistic;
70 }
71 
VisitStatistic()72 StatisticReporter<struct VisitStat>* Reporter::VisitStatistic()
73 {
74     static VisitStatisticImpl visitStatistic;
75     visitStatistic.SetThreadPool(executors_);
76     return &visitStatistic;
77 }
78 
DatabaseStatistic()79 StatisticReporter<struct DbStat>* Reporter::DatabaseStatistic()
80 {
81     static DatabaseStatisticImpl databaseStatistic;
82     databaseStatistic.SetThreadPool(executors_);
83     return &databaseStatistic;
84 }
85 
ApiPerformanceStatistic()86 StatisticReporter<ApiPerformanceStat>* Reporter::ApiPerformanceStatistic()
87 {
88     static ApiPerformanceStatisticImpl apiPerformanceStat;
89     apiPerformanceStat.SetThreadPool(executors_);
90     return &apiPerformanceStat;
91 }
92 
BehaviourReporter()93 BehaviourReporter* Reporter::BehaviourReporter()
94 {
95     static BehaviourReporterImpl behaviourReporterImpl;
96     behaviourReporterImpl.SetThreadPool(executors_);
97     return &behaviourReporterImpl;
98 }
99 } // namespace DistributedDataDfx
100 } // namespace OHOS
101