@@ -55,6 +55,13 @@ class TJsonTenantInfo : public TViewerPipeClient<TJsonTenantInfo> {
55
55
TString RootId; // id of root domain (tenant)
56
56
NKikimrViewer::TTenantInfo Result;
57
57
58
+ struct TStorageUsage {
59
+ uint64 Size = 0 ;
60
+ uint64 Limit = 0 ;
61
+ uint64 SoftQuota = 0 ;
62
+ uint64 HardQuota = 0 ;
63
+ };
64
+
58
65
public:
59
66
static constexpr NKikimrServices::TActivity::EType ActorActivityType () {
60
67
return NKikimrServices::TActivity::VIEWER_HANDLER;
@@ -476,6 +483,17 @@ class TJsonTenantInfo : public TViewerPipeClient<TJsonTenantInfo> {
476
483
}
477
484
}
478
485
486
+ NKikimrViewer::TStorageUsage::EType GetStorageType (const TString& poolKind) {
487
+ auto kind = to_lower (poolKind);
488
+ if (kind.StartsWith (" ssd" ) || kind.StartsWith (" nvme" )) {
489
+ return NKikimrViewer::TStorageUsage::SSD;
490
+ }
491
+ if (kind.StartsWith (" hdd" ) || kind.StartsWith (" rot" )) {
492
+ return NKikimrViewer::TStorageUsage::HDD;
493
+ }
494
+ return NKikimrViewer::TStorageUsage::None;
495
+ }
496
+
479
497
void ReplyAndPassAway () {
480
498
BLOG_TRACE (" ReplyAndPassAway() started" );
481
499
TIntrusivePtr<TDomainsInfo> domains = AppData ()->DomainsInfo ;
@@ -628,23 +646,32 @@ class TJsonTenantInfo : public TViewerPipeClient<TJsonTenantInfo> {
628
646
tenant.SetStorageAllocatedLimit (storageAllocatedLimit);
629
647
tenant.SetStorageMinAvailableSize (storageMinAvailableSize);
630
648
tenant.SetStorageGroups (storageGroups);
649
+ }
631
650
632
- auto & ssdUsage = *tenant.AddStorageUsage ();
633
- ssdUsage.SetType (NKikimrViewer::TStorageUsage::SSD);
634
- ssdUsage.SetSize (storageAllocatedSize);
635
- ssdUsage.SetLimit (storageAllocatedLimit);
636
- // TODO(andrew-rykov)
637
- auto & hddUsage = *tenant.AddStorageUsage ();
638
- hddUsage.SetType (NKikimrViewer::TStorageUsage::HDD);
639
-
640
- if (tenant.databasequotas ().data_size_hard_quota ()) {
641
- auto & ssdQuotaUsage = *tenant.AddQuotaUsage ();
642
- ssdQuotaUsage.SetType (NKikimrViewer::TStorageUsage::SSD);
643
- ssdQuotaUsage.SetSize (tenant.GetMetrics ().GetStorage ());
644
- ssdQuotaUsage.SetLimit (tenant.databasequotas ().data_size_hard_quota ());
645
- auto & hddQuotaUsage = *tenant.AddQuotaUsage ();
646
- hddQuotaUsage.SetType (NKikimrViewer::TStorageUsage::HDD);
647
- }
651
+ THashMap<NKikimrViewer::TStorageUsage::EType, TStorageUsage> StorageUsageByType;
652
+ for (const auto & poolUsage : entry.DomainDescription ->Description .GetDiskSpaceUsage ().GetStoragePoolsUsage ()) {
653
+ auto type = GetStorageType (poolUsage.GetPoolKind ());
654
+ auto & usage = StorageUsageByType[type];
655
+
656
+ usage.Size += poolUsage.GetDataSize ();
657
+ usage.Limit += poolUsage.GetTotalSize ();
658
+ }
659
+
660
+ for (auto & quota: tenant.databasequotas ().storage_quotas ()) {
661
+ auto type = GetStorageType (quota.unit_kind ());
662
+ auto & usage = StorageUsageByType[type];
663
+
664
+ usage.SoftQuota += quota.data_size_soft_quota ();
665
+ usage.HardQuota += quota.data_size_hard_quota ();
666
+ }
667
+
668
+ for (const auto & [type, usage] : StorageUsageByType) {
669
+ auto & storageUsage = *tenant.AddStorageUsage ();
670
+ storageUsage.SetType (type);
671
+ storageUsage.SetSize (usage.Size );
672
+ storageUsage.SetLimit (usage.Limit );
673
+ storageUsage.SetSoftQuota (usage.SoftQuota );
674
+ storageUsage.SetHardQuota (usage.HardQuota );
648
675
}
649
676
}
650
677
0 commit comments