@@ -56,6 +56,11 @@ class TJsonTenantInfo : public TViewerPipeClient<TJsonTenantInfo> {
56
56
TString RootId; // id of root domain (tenant)
57
57
NKikimrViewer::TTenantInfo Result;
58
58
59
+ struct TStorageQuota {
60
+ uint64 SoftQuota = 0 ;
61
+ uint64 HardQuota = 0 ;
62
+ };
63
+
59
64
public:
60
65
static constexpr NKikimrServices::TActivity::EType ActorActivityType () {
61
66
return NKikimrServices::TActivity::VIEWER_HANDLER;
@@ -478,6 +483,17 @@ class TJsonTenantInfo : public TViewerPipeClient<TJsonTenantInfo> {
478
483
}
479
484
}
480
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
+
481
497
void ReplyAndPassAway () {
482
498
BLOG_TRACE (" ReplyAndPassAway() started" );
483
499
TIntrusivePtr<TDomainsInfo> domains = AppData ()->DomainsInfo ;
@@ -632,22 +648,33 @@ class TJsonTenantInfo : public TViewerPipeClient<TJsonTenantInfo> {
632
648
tenant.SetStorageAllocatedLimit (storageAllocatedLimit);
633
649
tenant.SetStorageMinAvailableSize (storageMinAvailableSize);
634
650
tenant.SetStorageGroups (storageGroups);
651
+ }
652
+
653
+ THashMap<NKikimrViewer::TStorageUsage::EType, ui64> storageUsageByType;
654
+ THashMap<NKikimrViewer::TStorageUsage::EType, TStorageQuota> storageQuotasByType;
655
+ if (entry.DomainDescription ) {
656
+ for (const auto & poolUsage : entry.DomainDescription ->Description .GetDiskSpaceUsage ().GetStoragePoolsUsage ()) {
657
+ auto type = GetStorageType (poolUsage.GetPoolKind ());
658
+ storageUsageByType[type] += poolUsage.GetTotalSize ();
659
+ }
660
+ }
661
+
662
+ for (const auto & quota : tenant.GetDatabaseQuotas ().storage_quotas ()) {
663
+ auto type = GetStorageType (quota.unit_kind ());
664
+ auto & usage = storageQuotasByType[type];
665
+ usage.SoftQuota += quota.data_size_soft_quota ();
666
+ usage.HardQuota += quota.data_size_hard_quota ();
667
+ }
635
668
636
- auto & ssdUsage = *tenant.AddStorageUsage ();
637
- ssdUsage.SetType (NKikimrViewer::TStorageUsage::SSD);
638
- ssdUsage.SetSize (storageAllocatedSize);
639
- ssdUsage.SetLimit (storageAllocatedLimit);
640
- // TODO(andrew-rykov)
641
- auto & hddUsage = *tenant.AddStorageUsage ();
642
- hddUsage.SetType (NKikimrViewer::TStorageUsage::HDD);
643
-
644
- if (tenant.databasequotas ().data_size_hard_quota ()) {
645
- auto & ssdQuotaUsage = *tenant.AddQuotaUsage ();
646
- ssdQuotaUsage.SetType (NKikimrViewer::TStorageUsage::SSD);
647
- ssdQuotaUsage.SetSize (tenant.GetMetrics ().GetStorage ());
648
- ssdQuotaUsage.SetLimit (tenant.databasequotas ().data_size_hard_quota ());
649
- auto & hddQuotaUsage = *tenant.AddQuotaUsage ();
650
- hddQuotaUsage.SetType (NKikimrViewer::TStorageUsage::HDD);
669
+ for (const auto & [type, size] : storageUsageByType) {
670
+ auto & storageUsage = *tenant.AddStorageUsage ();
671
+ storageUsage.SetType (type);
672
+ storageUsage.SetSize (size);
673
+ auto it = storageQuotasByType.find (type);
674
+ if (it != storageQuotasByType.end ()) {
675
+ storageUsage.SetLimit (it->second .HardQuota );
676
+ storageUsage.SetSoftQuota (it->second .SoftQuota );
677
+ storageUsage.SetHardQuota (it->second .HardQuota );
651
678
}
652
679
}
653
680
}
0 commit comments