@@ -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,8 +538,33 @@ 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" );
567
+ Result.SetVersion (2 );
539
568
TIntrusivePtr<TDomainsInfo> domains = AppData ()->DomainsInfo ;
540
569
auto *domain = domains->GetDomain ();
541
570
THashMap<TString, NKikimrViewer::EFlag> OverallByDomainId;
@@ -666,6 +695,7 @@ class TJsonTenantInfo : public TViewerPipeClient {
666
695
}
667
696
668
697
if (Storage) {
698
+ THashMap<NKikimrViewer::TStorageUsage::EType, ui64> databaseStorageByType;
669
699
auto itHiveStorageStats = HiveStorageStats.find (hiveId);
670
700
if (itHiveStorageStats != HiveStorageStats.end ()) {
671
701
const NKikimrHive::TEvResponseHiveStorageStats& record = itHiveStorageStats->second .Get ()->Record ;
@@ -675,9 +705,12 @@ class TJsonTenantInfo : public TViewerPipeClient {
675
705
uint64 storageGroups = 0 ;
676
706
for (const NKikimrHive::THiveStoragePoolStats& poolStat : record.GetPools ()) {
677
707
if (poolStat.GetName ().StartsWith (tenantBySubDomainKey.GetName ())) {
708
+ NKikimrViewer::TStorageUsage::EType storageType = StoragePoolType[poolStat.GetName ()];
678
709
for (const NKikimrHive::THiveStorageGroupStats& groupStat : poolStat.GetGroups ()) {
679
710
storageAllocatedSize += groupStat.GetAllocatedSize ();
680
711
storageAvailableSize += groupStat.GetAvailableSize ();
712
+ databaseStorageByType[storageType] += groupStat.GetAllocatedSize ();
713
+ databaseStorageByType[storageType] += groupStat.GetAvailableSize ();
681
714
storageMinAvailableSize = std::min (storageMinAvailableSize, groupStat.GetAvailableSize ());
682
715
++storageGroups;
683
716
}
@@ -690,7 +723,7 @@ class TJsonTenantInfo : public TViewerPipeClient {
690
723
tenant.SetStorageGroups (storageGroups);
691
724
}
692
725
693
- THashMap<NKikimrViewer::TStorageUsage::EType, ui64> storageUsageByType ;
726
+ THashMap<NKikimrViewer::TStorageUsage::EType, ui64> tablesStorageByType ;
694
727
THashMap<NKikimrViewer::TStorageUsage::EType, TStorageQuota> storageQuotasByType;
695
728
696
729
for (const auto & quota : tenant.GetDatabaseQuotas ().storage_quotas ()) {
@@ -703,11 +736,11 @@ class TJsonTenantInfo : public TViewerPipeClient {
703
736
if (entry.DomainDescription ) {
704
737
for (const auto & poolUsage : entry.DomainDescription ->Description .GetDiskSpaceUsage ().GetStoragePoolsUsage ()) {
705
738
auto type = GetStorageType (poolUsage.GetPoolKind ());
706
- storageUsageByType [type] += poolUsage.GetTotalSize ();
739
+ tablesStorageByType [type] += poolUsage.GetTotalSize ();
707
740
}
708
741
709
- if (storageUsageByType .empty () && entry.DomainDescription ->Description .HasDiskSpaceUsage ()) {
710
- storageUsageByType [GuessStorageType (entry.DomainDescription ->Description )] =
742
+ if (tablesStorageByType .empty () && entry.DomainDescription ->Description .HasDiskSpaceUsage ()) {
743
+ tablesStorageByType [GuessStorageType (entry.DomainDescription ->Description )] =
711
744
entry.DomainDescription ->Description .GetDiskSpaceUsage ().GetTables ().GetTotalSize ();
712
745
}
713
746
@@ -718,17 +751,23 @@ class TJsonTenantInfo : public TViewerPipeClient {
718
751
}
719
752
}
720
753
721
- for (const auto & [type, size] : storageUsageByType) {
722
- auto & storageUsage = *tenant.AddStorageUsage ();
723
- storageUsage.SetType (type);
724
- storageUsage.SetSize (size);
754
+ for (const auto & [type, size] : tablesStorageByType) {
725
755
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 );
756
+ if (it != storageQuotasByType.end () && it->second .SoftQuota ) {
757
+ auto & tablesStorage = *tenant.AddTablesStorage ();
758
+ tablesStorage.SetType (type);
759
+ tablesStorage.SetSize (size);
760
+ tablesStorage.SetLimit (it->second .SoftQuota );
761
+ tablesStorage.SetSoftQuota (it->second .SoftQuota );
762
+ tablesStorage.SetHardQuota (it->second .HardQuota );
730
763
}
731
764
}
765
+
766
+ for (const auto & [type, size] : databaseStorageByType) {
767
+ auto & databaseStorage = *tenant.AddDatabaseStorage ();
768
+ databaseStorage.SetType (type);
769
+ databaseStorage.SetSize (size);
770
+ }
732
771
}
733
772
734
773
THashSet<TNodeId> tenantNodes;
0 commit comments