32
32
#include < unistd.h>
33
33
34
34
#include " src/collection/CollectionManager.h"
35
+ #include " src/collection/writer/CountWriter.h"
36
+ #include " src/collection/writer/LatencyWriter.h"
37
+ #include " src/collection/writer/PerformanceWriter.h"
38
+ #include " src/collection/writer/QueueWriter.h"
39
+ #include " src/collection/writer/UtilizationWriter.h"
35
40
#include " src/config/ConfigInterface.h"
36
41
#include " src/data_structure/NodeManager.h"
37
42
#include " src/lib/Casting.h"
51
56
52
57
#define airlog (node_name, filter_item, node_index, data ) \
53
58
AIR<cfg::GetIntValue(config::ParagraphType::DEFAULT, " AirBuild" ), \
54
- cfg::GetIntValue (config::ParagraphType::NODE, " Build" , \
55
- node_name)>::LogData<cfg::GetSentenceIndex(config::ParagraphType::NODE, node_name), \
56
- cfg::GetIntValue(config::ParagraphType::FILTER, " Item" , \
57
- cfg::GetStrValue (config::ParagraphType::NODE, " Filter" , node_name), filter_item)>(node_index, data)
59
+ cfg::GetIntValue (config::ParagraphType::NODE, " Build" , node_name)> \
60
+ ::LogData<cfg::GetSentenceIndex(config::ParagraphType::NODE, node_name), \
61
+ cfg::GetIntValue(config::ParagraphType::FILTER, " Item" , \
62
+ cfg::GetStrValue (config::ParagraphType::NODE, " Filter" , node_name), filter_item), \
63
+ cfg::GetNodeType(node_name)>(node_index, data)
58
64
59
65
// Primary template
60
66
template<bool AirBuild, bool NodeBuild>
@@ -66,14 +72,10 @@ class AIR
66
72
static void Deactivate (void );
67
73
static void Finalize (void );
68
74
69
- template <int32_t node_id, int32_t filter_index>
75
+ template <int32_t node_id, int32_t filter_index, air::ProcessorType node_type,
76
+ air::ProcessorType enable = air::ProcessorType::PROCESSORTYPE_NULL>
70
77
static void LogData (uint64_t node_index, uint64_t value);
71
78
static void LogData (uint32_t node_id, uint32_t filter_index, uint64_t node_index, uint64_t value);
72
-
73
- static air::InstanceManager* instance_manager;
74
- static node::NodeManager* node_manager;
75
- static collection::CollectionManager* collection_manager;
76
- static thread_local node::NodeDataArray* node_data_array;
77
79
};
78
80
79
81
// AIR build : true && Node build : true
@@ -116,29 +118,59 @@ class AIR<true, true>
116
118
collection_manager = instance_manager->GetCollectionManager ();
117
119
}
118
120
119
- template <int32_t node_id, int32_t filter_index>
121
+ template <int32_t node_id, int32_t filter_index, air::ProcessorType node_type,
122
+ typename std::enable_if<air::ProcessorType::PERFORMANCE == node_type, air::ProcessorType>::type = node_type>
120
123
static void
121
124
LogData (uint64_t node_index, uint64_t value)
122
125
{
123
126
static_assert (-1 != node_id, " Invalid Node" );
124
127
static_assert (-1 != filter_index, " Invalid Filter Item" );
125
128
126
- if ((nullptr == collection_manager) ||
127
- (false == collection_manager->IsLog (node_id)))
128
- {
129
- return ;
130
- }
129
+ perf_writer.LogData (_GetData (node_id, filter_index, node_index), value);
130
+ }
131
131
132
- if (nullptr != node_data_array)
133
- {
134
- collection_manager->LogData (node_id, filter_index, node_data_array, node_index, value);
135
- }
136
- else if (nullptr != node_manager)
137
- {
138
- uint32_t tid = syscall (SYS_gettid);
139
- node_data_array = node_manager->GetNodeDataArray (tid);
140
- node_manager->SetNodeDataArrayName (tid);
141
- }
132
+ template <int32_t node_id, int32_t filter_index, air::ProcessorType node_type,
133
+ typename std::enable_if<air::ProcessorType::LATENCY == node_type, air::ProcessorType>::type = node_type>
134
+ static void
135
+ LogData (uint64_t node_index, uint64_t value)
136
+ {
137
+ static_assert (-1 != node_id, " Invalid Node" );
138
+ static_assert (-1 != filter_index, " Invalid Filter Item" );
139
+
140
+ lat_writer.LogData (_GetData (node_id, filter_index, node_index), value);
141
+ }
142
+
143
+ template <int32_t node_id, int32_t filter_index, air::ProcessorType node_type,
144
+ typename std::enable_if<air::ProcessorType::QUEUE == node_type, air::ProcessorType>::type = node_type>
145
+ static void
146
+ LogData (uint64_t node_index, uint64_t value)
147
+ {
148
+ static_assert (-1 != node_id, " Invalid Node" );
149
+ static_assert (-1 != filter_index, " Invalid Filter Item" );
150
+
151
+ queue_writer.LogData (_GetData (node_id, filter_index, node_index), value);
152
+ }
153
+
154
+ template <int32_t node_id, int32_t filter_index, air::ProcessorType node_type,
155
+ typename std::enable_if<air::ProcessorType::UTILIZATION == node_type, air::ProcessorType>::type = node_type>
156
+ static void
157
+ LogData (uint64_t node_index, uint64_t value)
158
+ {
159
+ static_assert (-1 != node_id, " Invalid Node" );
160
+ static_assert (-1 != filter_index, " Invalid Filter Item" );
161
+
162
+ util_writer.LogData (_GetData (node_id, filter_index, node_index), value);
163
+ }
164
+
165
+ template <int32_t node_id, int32_t filter_index, air::ProcessorType node_type,
166
+ typename std::enable_if<air::ProcessorType::COUNT == node_type, air::ProcessorType>::type = node_type>
167
+ static void
168
+ LogData (uint64_t node_index, uint64_t value)
169
+ {
170
+ static_assert (-1 != node_id, " Invalid Node" );
171
+ static_assert (-1 != filter_index, " Invalid Filter Item" );
172
+
173
+ count_writer.LogData (_GetData (node_id, filter_index, node_index), value);
142
174
}
143
175
144
176
static void
@@ -162,53 +194,49 @@ class AIR<true, true>
162
194
}
163
195
}
164
196
197
+ protected:
198
+ static lib::Data*
199
+ _GetData (int32_t node_id, int32_t filter_index, uint64_t node_index)
200
+ {
201
+ if ((nullptr == collection_manager) ||
202
+ (false == collection_manager->IsLog (node_id)))
203
+ {
204
+ return nullptr ;
205
+ }
206
+ if (nullptr != node_data_array)
207
+ {
208
+ node::NodeData* node_data = node_data_array->node [node_id];
209
+ if (nullptr == node_data)
210
+ {
211
+ return nullptr ;
212
+ }
213
+ return node_data->GetUserDataByNodeIndex (node_index, filter_index);
214
+ }
215
+ else if (nullptr != node_manager)
216
+ {
217
+ uint32_t tid = syscall (SYS_gettid);
218
+ node_data_array = node_manager->GetNodeDataArray (tid);
219
+ node_manager->SetNodeDataArrayName (tid);
220
+ }
221
+ return nullptr ;
222
+ }
165
223
static air::InstanceManager* instance_manager;
166
224
static node::NodeManager* node_manager;
167
225
static collection::CollectionManager* collection_manager;
168
226
static thread_local node::NodeDataArray* node_data_array;
227
+ static collection::PerformanceWriter perf_writer;
228
+ static collection::LatencyWriter lat_writer;
229
+ static collection::QueueWriter queue_writer;
230
+ static collection::UtilizationWriter util_writer;
231
+ static collection::CountWriter count_writer;
169
232
};
170
233
171
- // AIR build : false && Node build : true
234
+ // AIR build : true && Node build : false
172
235
template <>
173
236
class AIR <true , false >
174
237
{
175
238
public:
176
- static void
177
- Initialize (uint32_t cpu_num = 0 )
178
- {
179
- instance_manager = new air::InstanceManager ();
180
- instance_manager->Initialize (cpu_num);
181
- node_manager = instance_manager->GetNodeManager ();
182
- collection_manager = instance_manager->GetCollectionManager ();
183
- }
184
- static void
185
- Activate (void )
186
- {
187
- if (nullptr != instance_manager)
188
- {
189
- instance_manager->Activate ();
190
- }
191
- }
192
- static void
193
- Deactivate (void )
194
- {
195
- if (nullptr != instance_manager)
196
- {
197
- instance_manager->Deactivate ();
198
- }
199
- }
200
- static void
201
- Finalize (void )
202
- {
203
- if (nullptr != instance_manager)
204
- {
205
- instance_manager->Finalize ();
206
- delete instance_manager;
207
- instance_manager = nullptr ;
208
- }
209
- }
210
-
211
- template <int32_t node_id, int32_t filter_index>
239
+ template <int32_t node_id, int32_t filter_index, air::ProcessorType type>
212
240
static void
213
241
LogData (uint64_t node_index, uint64_t value)
214
242
{
@@ -217,11 +245,6 @@ class AIR<true, false>
217
245
LogData (uint32_t node_id, uint32_t filter_index, uint64_t node_index, uint64_t value)
218
246
{
219
247
}
220
-
221
- static air::InstanceManager* instance_manager;
222
- static node::NodeManager* node_manager;
223
- static collection::CollectionManager* collection_manager;
224
- static thread_local node::NodeDataArray* node_data_array;
225
248
};
226
249
227
250
// AIR build : false
@@ -245,7 +268,7 @@ class AIR<false, NodeBuild>
245
268
Finalize (void )
246
269
{
247
270
}
248
- template <int32_t node_id, int32_t filter_index>
271
+ template <int32_t node_id, int32_t filter_index, air::ProcessorType type >
249
272
static void
250
273
LogData (uint64_t node_index, uint64_t value)
251
274
{
0 commit comments