@@ -56,6 +56,13 @@ class TJsonTenantInfo : public TViewerPipeClient<TJsonTenantInfo> {
56
56
TString RootId; // id of root domain (tenant)
57
57
NKikimrViewer::TTenantInfo Result;
58
58
59
+ struct TStorageUsage {
60
+ uint64 Size = 0 ;
61
+ uint64 Limit = 0 ;
62
+ uint64 SoftQuota = 0 ;
63
+ uint64 HardQuota = 0 ;
64
+ };
65
+
59
66
public:
60
67
static constexpr NKikimrServices::TActivity::EType ActorActivityType () {
61
68
return NKikimrServices::TActivity::VIEWER_HANDLER;
@@ -478,6 +485,17 @@ class TJsonTenantInfo : public TViewerPipeClient<TJsonTenantInfo> {
478
485
}
479
486
}
480
487
488
+ NKikimrViewer::TStorageUsage::EType GetStorageType (const TString& poolKind) {
489
+ auto kind = to_lower (poolKind);
490
+ if (kind.StartsWith (" ssd" ) || kind.StartsWith (" nvme" )) {
491
+ return NKikimrViewer::TStorageUsage::SSD;
492
+ }
493
+ if (kind.StartsWith (" hdd" ) || kind.StartsWith (" rot" )) {
494
+ return NKikimrViewer::TStorageUsage::HDD;
495
+ }
496
+ return NKikimrViewer::TStorageUsage::None;
497
+ }
498
+
481
499
void ReplyAndPassAway () {
482
500
BLOG_TRACE (" ReplyAndPassAway() started" );
483
501
TIntrusivePtr<TDomainsInfo> domains = AppData ()->DomainsInfo ;
@@ -632,23 +650,32 @@ class TJsonTenantInfo : public TViewerPipeClient<TJsonTenantInfo> {
632
650
tenant.SetStorageAllocatedLimit (storageAllocatedLimit);
633
651
tenant.SetStorageMinAvailableSize (storageMinAvailableSize);
634
652
tenant.SetStorageGroups (storageGroups);
653
+ }
635
654
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);
651
- }
655
+ THashMap<NKikimrViewer::TStorageUsage::EType, TStorageUsage> StorageUsageByType;
656
+ for (const auto & poolUsage : entry.DomainDescription ->Description .GetDiskSpaceUsage ().GetStoragePoolsUsage ()) {
657
+ auto type = GetStorageType (poolUsage.GetPoolKind ());
658
+ auto & usage = StorageUsageByType[type];
659
+
660
+ usage.Size += poolUsage.GetDataSize ();
661
+ usage.Limit += poolUsage.GetTotalSize ();
662
+ }
663
+
664
+ for (auto & quota: tenant.databasequotas ().storage_quotas ()) {
665
+ auto type = GetStorageType (quota.unit_kind ());
666
+ auto & usage = StorageUsageByType[type];
667
+
668
+ usage.SoftQuota += quota.data_size_soft_quota ();
669
+ usage.HardQuota += quota.data_size_hard_quota ();
670
+ }
671
+
672
+ for (const auto & [type, usage] : StorageUsageByType) {
673
+ auto & storageUsage = *tenant.AddStorageUsage ();
674
+ storageUsage.SetType (type);
675
+ storageUsage.SetSize (usage.Size );
676
+ storageUsage.SetLimit (usage.Limit );
677
+ storageUsage.SetSoftQuota (usage.SoftQuota );
678
+ storageUsage.SetHardQuota (usage.HardQuota );
652
679
}
653
680
}
654
681
0 commit comments