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