@@ -55,6 +55,12 @@ 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 SoftQuota = 0 ;
61
+ uint64 HardQuota = 0 ;
62
+ };
63
+
58
64
public:
59
65
static constexpr NKikimrServices::TActivity::EType ActorActivityType () {
60
66
return NKikimrServices::TActivity::VIEWER_HANDLER;
@@ -476,6 +482,17 @@ class TJsonTenantInfo : public TViewerPipeClient<TJsonTenantInfo> {
476
482
}
477
483
}
478
484
485
+ NKikimrViewer::TStorageUsage::EType GetStorageType (const TString& poolKind) {
486
+ auto kind = to_lower (poolKind);
487
+ if (kind.StartsWith (" ssd" ) || kind.StartsWith (" nvme" )) {
488
+ return NKikimrViewer::TStorageUsage::SSD;
489
+ }
490
+ if (kind.StartsWith (" hdd" ) || kind.StartsWith (" rot" )) {
491
+ return NKikimrViewer::TStorageUsage::HDD;
492
+ }
493
+ return NKikimrViewer::TStorageUsage::None;
494
+ }
495
+
479
496
void ReplyAndPassAway () {
480
497
BLOG_TRACE (" ReplyAndPassAway() started" );
481
498
TIntrusivePtr<TDomainsInfo> domains = AppData ()->DomainsInfo ;
@@ -628,23 +645,29 @@ class TJsonTenantInfo : public TViewerPipeClient<TJsonTenantInfo> {
628
645
tenant.SetStorageAllocatedLimit (storageAllocatedLimit);
629
646
tenant.SetStorageMinAvailableSize (storageMinAvailableSize);
630
647
tenant.SetStorageGroups (storageGroups);
648
+ }
631
649
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
- }
650
+ THashMap<NKikimrViewer::TStorageUsage::EType, TStorageUsage> storageUsageByType;
651
+ for (const auto & poolUsage : entry.DomainDescription ->Description .GetDiskSpaceUsage ().GetStoragePoolsUsage ()) {
652
+ auto type = GetStorageType (poolUsage.GetPoolKind ());
653
+ auto & usage = storageUsageByType[type];
654
+ usage.Size += poolUsage.GetTotalSize ();
655
+ }
656
+
657
+ for (const auto & quota: tenant.databasequotas ().storage_quotas ()) {
658
+ auto type = GetStorageType (quota.unit_kind ());
659
+ auto & usage = storageUsageByType[type];
660
+ usage.SoftQuota += quota.data_size_soft_quota ();
661
+ usage.HardQuota += quota.data_size_hard_quota ();
662
+ }
663
+
664
+ for (const auto & [type, usage] : storageUsageByType) {
665
+ auto & storageUsage = *tenant.AddStorageUsage ();
666
+ storageUsage.SetType (type);
667
+ storageUsage.SetSize (usage.Size );
668
+ storageUsage.SetLimit (usage.HardQuota );
669
+ storageUsage.SetSoftQuota (usage.SoftQuota );
670
+ storageUsage.SetHardQuota (usage.HardQuota );
648
671
}
649
672
}
650
673
0 commit comments