@@ -54,13 +54,13 @@ class TJsonStorage : public TJsonStorageBase {
54
54
uint64 Read;
55
55
uint64 Write;
56
56
57
- TGroupRow ()
57
+ TGroupRow ()
58
58
: Degraded(0 )
59
59
, Usage(0 )
60
60
, Used(0 )
61
61
, Limit(0 )
62
62
, Read(0 )
63
- , Write(0 )
63
+ , Write(0 )
64
64
{}
65
65
};
66
66
THashMap<TString, TGroupRow> GroupRowsByGroupId;
@@ -245,6 +245,36 @@ class TJsonStorage : public TJsonStorageBase {
245
245
}
246
246
}
247
247
248
+ bool CheckGroupFilters (const TString& groupId, const TString& poolName, const TGroupRow& groupRow) {
249
+ if (!EffectiveFilterGroupIds.empty () && !EffectiveFilterGroupIds.contains (groupId)) {
250
+ return false ;
251
+ }
252
+ switch (With) {
253
+ case EWith::MissingDisks:
254
+ if (BSGroupWithMissingDisks.count (groupId) == 0 ) {
255
+ return false ;
256
+ }
257
+ break ;
258
+ case EWith::SpaceProblems:
259
+ if (BSGroupWithSpaceProblems.count (groupId) == 0 && groupRow.Usage < 0.8 ) {
260
+ return false ;
261
+ }
262
+ break ;
263
+ case EWith::Everything:
264
+ break ;
265
+ }
266
+ if (Filter) {
267
+ if (poolName.Contains (Filter)) {
268
+ return true ;
269
+ }
270
+ if (groupId.Contains (Filter)) {
271
+ return true ;
272
+ }
273
+ return false ;
274
+ }
275
+ return true ;
276
+ }
277
+
248
278
void ReplyAndPassAway () override {
249
279
if (CheckAdditionalNodesInfoNeeded ()) {
250
280
return ;
@@ -270,19 +300,62 @@ class TJsonStorage : public TJsonStorageBase {
270
300
}
271
301
ui64 foundGroups = 0 ;
272
302
ui64 totalGroups = 0 ;
303
+ TVector<TGroupRow> GroupRows;
273
304
for (const auto & [poolName, poolInfo] : StoragePoolInfo) {
274
305
if ((!FilterTenant.empty () || !FilterStoragePools.empty ()) && FilterStoragePools.count (poolName) == 0 ) {
275
306
continue ;
276
307
}
277
308
NKikimrViewer::TStoragePoolInfo* pool = StorageInfo.AddStoragePools ();
278
309
for (TString groupId : poolInfo.Groups ) {
310
+ TGroupRow row;
311
+ row.PoolName = poolName;
312
+ row.GroupId = groupId;
313
+ row.Kind = poolInfo.Kind ;
314
+ auto ib = BSGroupIndex.find (groupId);
315
+ if (ib != BSGroupIndex.end ()) {
316
+ row.Erasure = ib->second .GetErasureSpecies ();
317
+ const auto & vDiskIds = ib->second .GetVDiskIds ();
318
+ for (auto iv = vDiskIds.begin (); iv != vDiskIds.end (); ++iv) {
319
+ const NKikimrBlobStorage::TVDiskID& vDiskId = *iv;
320
+ auto ie = VDisksIndex.find (vDiskId);
321
+ bool degraded = false ;
322
+ if (ie != VDisksIndex.end ()) {
323
+ ui32 nodeId = ie->second .GetNodeId ();
324
+ ui32 pDiskId = ie->second .GetPDiskId ();
325
+ degraded |= !ie->second .GetReplicated () || ie->second .GetVDiskState () != NKikimrWhiteboard::EVDiskState::OK;
326
+ row.Used += ie->second .GetAllocatedSize ();
327
+ row.Limit += ie->second .GetAllocatedSize () + ie->second .GetAvailableSize ();
328
+ row.Read += ie->second .GetReadThroughput ();
329
+ row.Write += ie->second .GetWriteThroughput ();
330
+
331
+ auto ip = PDisksIndex.find (std::make_pair (nodeId, pDiskId));
332
+ if (ip != PDisksIndex.end ()) {
333
+ degraded |= ip->second .GetState () != NKikimrBlobStorage::TPDiskState::Normal;
334
+ if (!ie->second .HasAvailableSize ()) {
335
+ row.Limit += ip->second .GetAvailableSize ();
336
+ }
337
+ }
338
+ }
339
+ if (degraded) {
340
+ row.Degraded ++;
341
+ }
342
+ }
343
+ }
344
+ row.Usage = row.Limit == 0 ? 100 : (float )row.Used / row.Limit ;
345
+
279
346
++totalGroups;
280
- if (!CheckGroupFilters (groupId, poolName)) {
347
+ if (!CheckGroupFilters (groupId, poolName, row )) {
281
348
continue ;
282
349
}
283
350
++foundGroups;
284
351
if (Version == EVersion::v1) {
285
352
pool->AddGroups ()->SetGroupId (groupId);
353
+ } else if (Version == EVersion::v2) {
354
+ if (!UsageBuckets.empty () && !BinarySearch (UsageBuckets.begin (), UsageBuckets.end (), (ui32)(row.Usage * 100 ) / UsagePace)) {
355
+ continue ;
356
+ }
357
+ GroupRows.emplace_back (row);
358
+ GroupRowsByGroupId[groupId] = row;
286
359
}
287
360
auto itHiveGroup = BSGroupHiveIndex.find (groupId);
288
361
if (itHiveGroup != BSGroupHiveIndex.end ()) {
@@ -309,61 +382,6 @@ class TJsonStorage : public TJsonStorageBase {
309
382
}
310
383
311
384
if (Version == EVersion::v2) {
312
- TVector<TGroupRow> GroupRows;
313
- for (const auto & [poolName, poolInfo] : StoragePoolInfo) {
314
- if ((!FilterTenant.empty () || !FilterStoragePools.empty ()) && FilterStoragePools.count (poolName) == 0 ) {
315
- continue ;
316
- }
317
- for (TString groupId : poolInfo.Groups ) {
318
- if (!CheckGroupFilters (groupId, poolName)) {
319
- continue ;
320
- }
321
-
322
- TGroupRow row;
323
- row.PoolName = poolName;
324
- row.GroupId = groupId;
325
- row.Kind = poolInfo.Kind ;
326
-
327
- auto ib = BSGroupIndex.find (groupId);
328
- if (ib != BSGroupIndex.end ()) {
329
- row.Erasure = ib->second .GetErasureSpecies ();
330
- const auto & vDiskIds = ib->second .GetVDiskIds ();
331
- for (auto iv = vDiskIds.begin (); iv != vDiskIds.end (); ++iv) {
332
- const NKikimrBlobStorage::TVDiskID& vDiskId = *iv;
333
- auto ie = VDisksIndex.find (vDiskId);
334
- bool degraded = false ;
335
- if (ie != VDisksIndex.end ()) {
336
- ui32 nodeId = ie->second .GetNodeId ();
337
- ui32 pDiskId = ie->second .GetPDiskId ();
338
- degraded |= !ie->second .GetReplicated () || ie->second .GetVDiskState () != NKikimrWhiteboard::EVDiskState::OK;
339
- row.Used += ie->second .GetAllocatedSize ();
340
- row.Limit += ie->second .GetAllocatedSize () + ie->second .GetAvailableSize ();
341
- row.Read += ie->second .GetReadThroughput ();
342
- row.Write += ie->second .GetWriteThroughput ();
343
-
344
- auto ip = PDisksIndex.find (std::make_pair (nodeId, pDiskId));
345
- if (ip != PDisksIndex.end ()) {
346
- degraded |= ip->second .GetState () != NKikimrBlobStorage::TPDiskState::Normal;
347
- if (!ie->second .HasAvailableSize ()) {
348
- row.Limit += ip->second .GetAvailableSize ();
349
- }
350
- }
351
- }
352
- if (degraded) {
353
- row.Degraded ++;
354
- }
355
- }
356
- }
357
-
358
- row.Usage = row.Limit == 0 ? 100 : (float )row.Used / row.Limit ;
359
- if (!UsageBuckets.empty () && !BinarySearch (UsageBuckets.begin (), UsageBuckets.end (), (ui32)(row.Usage * 100 ) / UsagePace)) {
360
- continue ;
361
- }
362
- GroupRows.emplace_back (row);
363
- GroupRowsByGroupId[groupId] = row;
364
- }
365
- }
366
-
367
385
switch (GroupSort) {
368
386
case EGroupSort::PoolName:
369
387
SortCollection (GroupRows, [](const TGroupRow& node) { return node.PoolName ;}, ReverseSort);
0 commit comments