37 statusTableInfo_{{0,{}},{1,{}},{2,{}},{3,{}},{4,{}}},
38 fragmentHistogram_{{0,{0}},{1,{0}},{2,{0}},{3,{0}},{4,{0}}}
44 statisticRegistrar.
registerTable<std::uint8_t>(
"QueueStatusTable",
45 {
"Queue",
"Enqueued",
"Dequeued",
"Overflow",
"Too Big",
"0",
"1",
"2",
"3",
"4"},
47 "Shows for each queue the number of packets enqueued, dequeued," 48 " dropped due to queue overflow (enqueue), dropped due to too big" 49 " (dequeue) and which slot classes fragments are being transmitted.");
51 for(
const auto & entry : statusTableInfo_)
53 pQueueStatusTable_->
addRow(entry.first,
55 Any{std::get<0>(entry.second)},
56 Any{std::get<1>(entry.second)},
57 Any{std::get<2>(entry.second)},
58 Any{std::get<3>(entry.second)},
59 Any{std::get<4>(entry.second)},
60 Any{std::get<5>(entry.second)},
61 Any{std::get<6>(entry.second)},
62 Any{std::get<7>(entry.second)},
63 Any{std::get<8>(entry.second)}});
70 pQueueFragmentHistogram_ =
71 statisticRegistrar.registerTable<std::uint8_t>(
"QueueFragmentHistogram",
72 {
"Queue",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
">9"},
74 "Shows a per queue histogram of the number of message components required to transmit packets.");
76 for(
const auto & entry : fragmentHistogram_)
78 pQueueFragmentHistogram_->
addRow(entry.first,
80 Any{std::get<0>(entry.second)},
81 Any{std::get<1>(entry.second)},
82 Any{std::get<2>(entry.second)},
83 Any{std::get<3>(entry.second)},
84 Any{std::get<4>(entry.second)},
85 Any{std::get<5>(entry.second)},
86 Any{std::get<6>(entry.second)},
87 Any{std::get<7>(entry.second)},
88 Any{std::get<8>(entry.second)},
89 Any{std::get<9>(entry.second)}});
93 pHighWaterMarkQueue_[0] =
94 statisticRegistrar.registerNumeric<std::uint64_t>(
"highWaterMarkQueue0",
96 "High water mark queue 0");
98 pHighWaterMarkQueue_[1] =
99 statisticRegistrar.registerNumeric<std::uint64_t>(
"highWaterMarkQueue1",
101 "High water mark queue 1");
103 pHighWaterMarkQueue_[2] =
104 statisticRegistrar.registerNumeric<std::uint64_t>(
"highWaterMarkQueue2",
106 "High water mark queue 2");
108 pHighWaterMarkQueue_[3] =
109 statisticRegistrar.registerNumeric<std::uint64_t>(
"highWaterMarkQueue3",
111 "High water mark queue 3");
113 pHighWaterMarkQueue_[4] =
114 statisticRegistrar.registerNumeric<std::uint64_t>(
"highWaterMarkQueue4",
116 "High water mark queue 4");
124 auto & overflow = std::get<2>(statusTableInfo_[u8Queue]);
125 auto & toobig = std::get<3>(statusTableInfo_[u8Queue]);
131 pQueueStatusTable_->
setCell(u8Queue,3,
Any{overflow});
136 pQueueStatusTable_->
setCell(u8Queue,4,
Any{toobig});
140 depthQueueInfo_[u8Queue] -= count;
144 std::uint8_t u8ActualQueue,
147 auto & dequeued = std::get<1>(statusTableInfo_[u8ActualQueue]);
148 auto & queue0 = std::get<4>(statusTableInfo_[u8ActualQueue]);
149 auto & queue1 = std::get<5>(statusTableInfo_[u8ActualQueue]);
150 auto & queue2 = std::get<6>(statusTableInfo_[u8ActualQueue]);
151 auto & queue3 = std::get<7>(statusTableInfo_[u8ActualQueue]);
152 auto & queue4 = std::get<8>(statusTableInfo_[u8ActualQueue]);
154 size_t packetsCompletedSend{};
156 for(
const auto & component : components)
158 if(!component.isMoreFragments())
160 ++packetsCompletedSend;
163 size_t parts{component.getFragmentIndex() + 1};
174 ++fragmentHistogram_[u8ActualQueue][index-1];
176 pQueueFragmentHistogram_->
setCell(u8ActualQueue,
178 Any{fragmentHistogram_[u8ActualQueue][index-1]});
183 dequeued += packetsCompletedSend;
185 pQueueStatusTable_->
setCell(u8ActualQueue,2,
Any{dequeued});
187 switch(u8RequestQueue)
190 queue0 += components.size();
191 pQueueStatusTable_->
setCell(u8ActualQueue,5,
Any{queue0});
194 queue1 += components.size();
195 pQueueStatusTable_->
setCell(u8ActualQueue,6,
Any{queue1});
198 queue2 += components.size();
199 pQueueStatusTable_->
setCell(u8ActualQueue,7,
Any{queue2});
202 queue3 += components.size();
203 pQueueStatusTable_->
setCell(u8ActualQueue,8,
Any{queue3});
206 queue4 += components.size();
207 pQueueStatusTable_->
setCell(u8ActualQueue,9,
Any{queue4});
211 depthQueueInfo_[u8ActualQueue] -= packetsCompletedSend;
216 auto & enqueued = std::get<0>(statusTableInfo_[u8Queue]);
217 pQueueStatusTable_->
setCell(u8Queue,1,
Any{++enqueued});
219 ++depthQueueInfo_[u8Queue];
221 if(depthQueueInfo_[u8Queue] > highWaterMarkQueueInfo_[u8Queue])
223 highWaterMarkQueueInfo_[u8Queue] = depthQueueInfo_[u8Queue];
225 *pHighWaterMarkQueue_[u8Queue] = highWaterMarkQueueInfo_[u8Queue];
void setCell(const Key &key, std::size_t columnIndex, const Any &any)
The StatisticRegistrar allows NEM layers to register statistics and statistic tables. Statistics and Statistic tables are owned by the emulator framework and a borrowed reference is returned to the registering NEM layer.
void drop(std::uint8_t u8Queue, DropReason reason, size_t count)
std::list< MessageComponent > MessageComponents
StatisticTable< Key, Compare, scolumn > * registerTable(const std::string &sName, const StatisticTableLabels &labels, const StatisticProperties &properties=StatisticProperties::NONE, const std::string &sDescription="")
void dequeue(std::uint8_t u8RequestQueue, std::uint8_t u8ActualQueue, const MessageComponents &components)
void addRow(const Key &key, const std::vector< Any > &anys={})
void enqueue(std::uint8_t u8Queue)
void registerStatistics(StatisticRegistrar ®istrar)
The Any class can contain an instance of one of any type in its support type set. ...