@@ -46,9 +46,11 @@ class TJsonTenantInfo : public TViewerPipeClient {
46
46
THashMap<TString, std::vector<TNodeId>> TenantNodes;
47
47
THashMap<TString, NKikimrViewer::TEvViewerResponse> OffloadMergedTabletStateResponse;
48
48
THashMap<TString, NKikimrViewer::TEvViewerResponse> OffloadMergedSystemStateResponse;
49
+ THashMap<TString, NKikimrViewer::TStorageUsage::EType> StoragePoolType;
49
50
TTabletId RootHiveId = 0 ;
50
51
TString RootId; // id of root domain (tenant)
51
52
NKikimrViewer::TTenantInfo Result;
53
+ std::optional<TRequestResponse<NSysView::TEvSysView::TEvGetStoragePoolsResponse>> GetStoragePoolsResponse;
52
54
53
55
struct TStorageQuota {
54
56
uint64 SoftQuota = 0 ;
@@ -124,6 +126,7 @@ class TJsonTenantInfo : public TViewerPipeClient {
124
126
if (Storage) {
125
127
RequestHiveStorageStats (RootHiveId);
126
128
}
129
+ GetStoragePoolsResponse = RequestBSControllerPools ();
127
130
128
131
if (Requests == 0 ) {
129
132
ReplyAndPassAway ();
@@ -154,9 +157,10 @@ class TJsonTenantInfo : public TViewerPipeClient {
154
157
hFunc (TEvViewer::TEvViewerResponse, Handle );
155
158
hFunc (TEvents::TEvUndelivered, Undelivered);
156
159
hFunc (TEvInterconnect::TEvNodeDisconnected, Disconnected);
157
- hFunc (TEvTabletPipe::TEvClientConnected, TBase:: Handle );
160
+ hFunc (TEvTabletPipe::TEvClientConnected, Handle );
158
161
hFunc (TEvStateStorage::TEvBoardInfo, Handle );
159
162
hFunc (NHealthCheck::TEvSelfCheckResultProto, Handle );
163
+ hFunc (NSysView::TEvSysView::TEvGetStoragePoolsResponse, Handle );
160
164
cFunc (TEvents::TSystem::Wakeup, HandleTimeout);
161
165
}
162
166
}
@@ -534,6 +538,30 @@ class TJsonTenantInfo : public TViewerPipeClient {
534
538
return type;
535
539
}
536
540
541
+ void Handle (TEvTabletPipe::TEvClientConnected::TPtr& ev) {
542
+ if (ev->Get ()->Status != NKikimrProto::OK) {
543
+ TString error = TStringBuilder () << " Failed to establish pipe: " << NKikimrProto::EReplyStatus_Name (ev->Get ()->Status );
544
+ if (ev->Get ()->TabletId == GetBSControllerId ()) {
545
+ if (GetStoragePoolsResponse.has_value ()) {
546
+ GetStoragePoolsResponse->Error (error);
547
+ }
548
+ }
549
+ }
550
+ TBase::Handle (ev); // all RequestDone() are handled by base handler
551
+ }
552
+
553
+ void Handle (NSysView::TEvSysView::TEvGetStoragePoolsResponse::TPtr& ev) {
554
+ GetStoragePoolsResponse->Set (std::move (ev));
555
+
556
+ if (GetStoragePoolsResponse && GetStoragePoolsResponse->IsOk ()) {
557
+ for (const NKikimrSysView::TStoragePoolEntry& entry : GetStoragePoolsResponse->Get ()->Record .GetEntries ()) {
558
+ StoragePoolType[entry.GetInfo ().GetName ()] = GetStorageType (entry.GetInfo ().GetKind ());
559
+ }
560
+ }
561
+
562
+ RequestDone ();
563
+ }
564
+
537
565
void ReplyAndPassAway () override {
538
566
BLOG_TRACE (" ReplyAndPassAway() started" );
539
567
TIntrusivePtr<TDomainsInfo> domains = AppData ()->DomainsInfo ;
@@ -666,6 +694,7 @@ class TJsonTenantInfo : public TViewerPipeClient {
666
694
}
667
695
668
696
if (Storage) {
697
+ THashMap<NKikimrViewer::TStorageUsage::EType, ui64> databaseStorageByType;
669
698
auto itHiveStorageStats = HiveStorageStats.find (hiveId);
670
699
if (itHiveStorageStats != HiveStorageStats.end ()) {
671
700
const NKikimrHive::TEvResponseHiveStorageStats& record = itHiveStorageStats->second .Get ()->Record ;
@@ -675,9 +704,12 @@ class TJsonTenantInfo : public TViewerPipeClient {
675
704
uint64 storageGroups = 0 ;
676
705
for (const NKikimrHive::THiveStoragePoolStats& poolStat : record.GetPools ()) {
677
706
if (poolStat.GetName ().StartsWith (tenantBySubDomainKey.GetName ())) {
707
+ NKikimrViewer::TStorageUsage::EType storageType = StoragePoolType[poolStat.GetName ()];
678
708
for (const NKikimrHive::THiveStorageGroupStats& groupStat : poolStat.GetGroups ()) {
679
709
storageAllocatedSize += groupStat.GetAllocatedSize ();
680
710
storageAvailableSize += groupStat.GetAvailableSize ();
711
+ databaseStorageByType[storageType] += groupStat.GetAllocatedSize ();
712
+ databaseStorageByType[storageType] += groupStat.GetAvailableSize ();
681
713
storageMinAvailableSize = std::min (storageMinAvailableSize, groupStat.GetAvailableSize ());
682
714
++storageGroups;
683
715
}
@@ -690,7 +722,7 @@ class TJsonTenantInfo : public TViewerPipeClient {
690
722
tenant.SetStorageGroups (storageGroups);
691
723
}
692
724
693
- THashMap<NKikimrViewer::TStorageUsage::EType, ui64> storageUsageByType ;
725
+ THashMap<NKikimrViewer::TStorageUsage::EType, ui64> tablesStorageByType ;
694
726
THashMap<NKikimrViewer::TStorageUsage::EType, TStorageQuota> storageQuotasByType;
695
727
696
728
for (const auto & quota : tenant.GetDatabaseQuotas ().storage_quotas ()) {
@@ -703,11 +735,11 @@ class TJsonTenantInfo : public TViewerPipeClient {
703
735
if (entry.DomainDescription ) {
704
736
for (const auto & poolUsage : entry.DomainDescription ->Description .GetDiskSpaceUsage ().GetStoragePoolsUsage ()) {
705
737
auto type = GetStorageType (poolUsage.GetPoolKind ());
706
- storageUsageByType [type] += poolUsage.GetTotalSize ();
738
+ tablesStorageByType [type] += poolUsage.GetTotalSize ();
707
739
}
708
740
709
- if (storageUsageByType .empty () && entry.DomainDescription ->Description .HasDiskSpaceUsage ()) {
710
- storageUsageByType [GuessStorageType (entry.DomainDescription ->Description )] =
741
+ if (tablesStorageByType .empty () && entry.DomainDescription ->Description .HasDiskSpaceUsage ()) {
742
+ tablesStorageByType [GuessStorageType (entry.DomainDescription ->Description )] =
711
743
entry.DomainDescription ->Description .GetDiskSpaceUsage ().GetTables ().GetTotalSize ();
712
744
}
713
745
@@ -718,17 +750,23 @@ class TJsonTenantInfo : public TViewerPipeClient {
718
750
}
719
751
}
720
752
721
- for (const auto & [type, size] : storageUsageByType) {
722
- auto & storageUsage = *tenant.AddStorageUsage ();
723
- storageUsage.SetType (type);
724
- storageUsage.SetSize (size);
753
+ for (const auto & [type, size] : tablesStorageByType) {
725
754
auto it = storageQuotasByType.find (type);
726
- if (it != storageQuotasByType.end ()) {
727
- storageUsage.SetLimit (it->second .HardQuota );
728
- storageUsage.SetSoftQuota (it->second .SoftQuota );
729
- storageUsage.SetHardQuota (it->second .HardQuota );
755
+ if (it != storageQuotasByType.end () && it->second .SoftQuota ) {
756
+ auto & tablesStorage = *tenant.AddTablesStorage ();
757
+ tablesStorage.SetType (type);
758
+ tablesStorage.SetSize (size);
759
+ tablesStorage.SetLimit (it->second .SoftQuota );
760
+ tablesStorage.SetSoftQuota (it->second .SoftQuota );
761
+ tablesStorage.SetHardQuota (it->second .HardQuota );
730
762
}
731
763
}
764
+
765
+ for (const auto & [type, size] : databaseStorageByType) {
766
+ auto & databaseStorage = *tenant.AddDatabaseStorage ();
767
+ databaseStorage.SetType (type);
768
+ databaseStorage.SetSize (size);
769
+ }
732
770
}
733
771
734
772
THashSet<TNodeId> tenantNodes;
0 commit comments