1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
|
#include "read_balancer__balancing.h"
#include <library/cpp/monlib/service/pages/templates.h>
#define DEBUG(message)
namespace NKikimr::NPQ::NBalancing {
void TBalancer::RenderApp(TStringStream& str) const {
auto& __stream = str;
for (auto& [consumerName, consumer] : Consumers) {
auto consumerAnchor = "c_" + EncodeAnchor(consumerName);
auto familyAnchor = [&](const size_t familyId) {
return TStringBuilder() << consumerAnchor << "_F" << familyId;
};
auto partitionAnchor = [&](const ui32 partitionId) {
return TStringBuilder() << consumerAnchor << "_P" << partitionId;
};
DIV_CLASS_ID("tab-pane fade", consumerAnchor) {
TABLE_CLASS("table") {
CAPTION() { str << "Families"; }
TABLEHEAD() {
TABLER() {
TABLEH() { str << "Id"; }
TABLEH() { str << "Status"; }
TABLEH() { str << "Partitions"; }
TABLEH() { str << "Session"; }
TABLEH() { str << "Statistics"; }
}
}
TABLEBODY() {
for (auto& [familyId, family] : consumer->Families) {
TABLER() {
TABLED() { DIV_CLASS_ID("text-info", familyAnchor(familyId)) { str << familyId; } }
TABLED() { str << family->Status; }
TABLED() {
for (auto partitionId : family->Partitions) {
HREF("#" + partitionAnchor(partitionId)) { str << partitionId; }
str << ", ";
}
}
TABLED() { str << (family->Session ? family->Session->SessionName : ""); }
TABLED() { str << "Active " << family->ActivePartitionCount << " / Inactive " << family->InactivePartitionCount << " / Locked " << family->LockedPartitions.size(); }
}
}
}
}
size_t free = 0;
size_t finished = 0;
size_t read = 0;
size_t ready = 0;
TABLE_CLASS("table") {
CAPTION() { str << "Partitions"; }
TABLEHEAD() {
TABLER() {
TABLEH() { str << "Id"; }
TABLEH() { str << "Family"; }
TABLEH() { str << "Status"; };
TABLEH() { str << "Parents"; }
TABLEH() { str << "Description"; }
TABLEH() { str << "P Generation"; }
TABLEH() { str << "P Cookie"; }
}
}
TABLEBODY() {
for (auto& [partitionId, partition] : consumer->Partitions) {
const auto* family = consumer->FindFamily(partitionId);
const auto* node = consumer->GetPartitionGraph().GetPartition(partitionId);
TString style = node && node->Children.empty() ? "text-success" : "text-muted";
auto* partitionInfo = GetPartitionInfo(partitionId);
TABLER() {
TABLED() { DIV_CLASS_ID(style, partitionAnchor(partitionId)) {
str << partitionId << " ";
if (partitionInfo) {
HREF(TStringBuilder() << "?TabletID=" << partitionInfo->TabletId) { str << "#"; }
}
} }
TABLED() {
if (family) {
HREF("#" + familyAnchor(family->Id)) { str << family->Id; }
}
}
TABLED() {
if (family) {
if (partition.IsInactive()) {
str << "Finished";
++finished;
} else {
str << "Read";
++read;
}
} else if (consumer->IsReadable(partitionId)) {
str << "Ready";
++ready;
} else {
str << "Free";
++free;
}
}
TABLED() {
if (node) {
for (auto* parent : node->Parents) {
HREF("#" + partitionAnchor(parent->Id)) { str << parent->Id; }
str << ", ";
}
} else {
str << "error: not found";
}
}
TABLED() {
if (partition.Commited) {
str << "commited";
} else if (partition.ReadingFinished) {
if (partition.ScaleAwareSDK) {
str << "reading child";
} else if (partition.StartedReadingFromEndOffset) {
str << "finished";
} else {
str << "scheduled. iteration: " << partition.Iteration;
}
} else if (partition.Iteration) {
str << "iteration: " << partition.Iteration;
}
}
TABLED() { str << partition.PartitionGeneration; }
TABLED() { str << partition.PartitionCookie; }
}
}
}
}
TABLE_CLASS("table") {
CAPTION() { str << "Statistics"; }
TABLEBODY() {
TABLER() {
TABLED() { str << "Free"; }
TABLED() { str << free; }
}
TABLER() {
TABLED() { str << "Ready"; }
TABLED() { str << ready; }
}
TABLER() {
TABLED() { str << "Read"; }
TABLED() { str << read; }
}
TABLER() {
TABLED() { str << "Finished"; }
TABLED() { str << finished; }
}
TABLER() {
TABLED() { STRONG() { str << "Total"; }}
TABLED() { str << (finished + read + ready + free); }
}
}
}
TABLE_CLASS("table") {
CAPTION() { str << "Sessions"; }
TABLEHEAD() {
TABLER() {
TABLEH() { }
TABLEH() { str << "Id"; }
TABLEH() { str << "Partitions"; }
TABLEH() { str << "<span title=\"All families / Active / Releasing\">Families</span>"; }
TABLEH() { str << "<span title=\"All partitions / Active / Inactive / Releasing\">Statistics</span>"; };
TABLEH() { str << "Client node"; }
TABLEH() { str << "Proxy node"; }
}
}
TABLEBODY() {
size_t familyAllCount = 0;
size_t activeFamilyCount = 0;
size_t releasingFamilyCount = 0;
size_t activePartitionCount = 0;
size_t inactivePartitionCount = 0;
size_t releasingPartitionCount = 0;
size_t i = 0;
for (auto& [pipe, session] : Sessions) {
if (session->ClientId != consumerName) {
continue;
}
familyAllCount += session->Families.size();
activeFamilyCount += session->ActiveFamilyCount;
releasingFamilyCount += session->ReleasingFamilyCount;
activePartitionCount += session->ActivePartitionCount;
inactivePartitionCount += session->InactivePartitionCount;
releasingPartitionCount += session->ReleasingPartitionCount;
TABLER() {
TABLED() { str << ++i; }
TABLED() { str << session->SessionName; }
TABLED() { str << (session->Partitions.empty() ? "" : JoinRange(", ", session->Partitions.begin(), session->Partitions.end())); }
TABLED() { str << session->Families.size() << " / " << session->ActiveFamilyCount << " / " << session->ReleasingFamilyCount; }
TABLED() { str << (session->ActivePartitionCount + session->InactivePartitionCount + session->ReleasingPartitionCount)
<< " / " << session->ActivePartitionCount << " / " << session->InactivePartitionCount << " / " << session->ReleasingPartitionCount; }
TABLED() { str << session->ClientNode; }
TABLED() { str << session->ProxyNodeId; }
}
}
TABLER() {
TABLED() { }
TABLED() { str << "<strong>Total:</strong>"; }
TABLED() { }
TABLED() { str << familyAllCount << " / " << activeFamilyCount << " / " << releasingFamilyCount; }
TABLED() { str << (activePartitionCount + inactivePartitionCount + releasingPartitionCount) << " / " << activePartitionCount << " / "
<< inactivePartitionCount << " / " << releasingPartitionCount; }
TABLED() { }
TABLED() { }
}
}
}
}
}
}
}
|