@@ -22,6 +22,8 @@ class TJsonTenantInfo : public TViewerPipeClient {
2222 std::optional<TRequestResponse<NConsole::TEvConsole::TEvListTenantsResponse>> ListTenantsResponse;
2323 std::unordered_map<TString, TRequestResponse<NConsole::TEvConsole::TEvGetTenantStatusResponse>> TenantStatusResponses;
2424 std::unordered_map<TString, TRequestResponse<TEvTxProxySchemeCache::TEvNavigateKeySetResult>> NavigateKeySetResult;
25+ std::unordered_map<TString, TRequestResponse<NSchemeShard::TEvSchemeShard::TEvDescribeSchemeResult>> DescribeSchemeResult;
26+ std::unordered_map<TTabletId, std::vector<TString>> DescribesBySchemeShard;
2527 std::unordered_map<TTabletId, TRequestResponse<TEvHive::TEvResponseHiveDomainStats>> HiveDomainStats;
2628 std::unordered_map<TTabletId, TRequestResponse<TEvHive::TEvResponseHiveStorageStats>> HiveStorageStats;
2729 std::unordered_map<TNodeId, TRequestResponse<TEvWhiteboard::TEvSystemStateResponse>> SystemStateResponse;
@@ -52,6 +54,7 @@ class TJsonTenantInfo : public TViewerPipeClient {
5254 bool MetadataCache = true ;
5355 THashMap<TString, std::vector<TNodeId>> TenantNodes;
5456 TTabletId RootHiveId = 0 ;
57+ TTabletId RootSchemeShardId = 0 ;
5558 TString RootId; // id of root domain (tenant)
5659 NKikimrViewer::TTenantInfo Result;
5760
@@ -97,6 +100,15 @@ class TJsonTenantInfo : public TViewerPipeClient {
97100 }
98101 }
99102
103+ TRequestResponse<NSchemeShard::TEvSchemeShard::TEvDescribeSchemeResult> MakeRequestSchemeShardDescribe (TTabletId schemeShardId, const TString& path) {
104+ NKikimrSchemeOp::TDescribeOptions options;
105+ options.SetReturnPartitioningInfo (false );
106+ options.SetReturnPartitionConfig (false );
107+ options.SetReturnChildren (false );
108+ options.SetReturnRangeKey (false );
109+ return TBase::MakeRequestSchemeShardDescribe (schemeShardId, path, options);
110+ }
111+
100112 void Bootstrap () override {
101113 if (NeedToRedirect ()) {
102114 return ;
@@ -120,6 +132,7 @@ class TJsonTenantInfo : public TViewerPipeClient {
120132 TIntrusivePtr<TDomainsInfo> domains = AppData ()->DomainsInfo ;
121133 auto * domain = domains->GetDomain ();
122134 DomainPath = " /" + domain->Name ;
135+ RootSchemeShardId = domain->SchemeRoot ;
123136 TPathId rootPathId (domain->SchemeRoot , 1 );
124137 RootId = GetDomainId (rootPathId);
125138 RootHiveId = domains->GetHive ();
@@ -146,6 +159,8 @@ class TJsonTenantInfo : public TViewerPipeClient {
146159 HiveDomainStats[RootHiveId] = MakeRequestHiveDomainStats (RootHiveId);
147160 if (Storage) {
148161 HiveStorageStats[RootHiveId] = MakeRequestHiveStorageStats (RootHiveId);
162+ DescribeSchemeResult[DomainPath] = MakeRequestSchemeShardDescribe (RootSchemeShardId, DomainPath);
163+ DescribesBySchemeShard[RootSchemeShardId].emplace_back (DomainPath);
149164 }
150165
151166 Become (&TThis::StateCollectingInfo, TDuration::MilliSeconds (Timeout), new TEvents::TEvWakeup ());
@@ -175,6 +190,7 @@ class TJsonTenantInfo : public TViewerPipeClient {
175190 hFunc (TEvTabletPipe::TEvClientConnected, Handle);
176191 hFunc (TEvStateStorage::TEvBoardInfo, Handle);
177192 hFunc (NHealthCheck::TEvSelfCheckResultProto, Handle);
193+ hFunc (TEvSchemeShard::TEvDescribeSchemeResult, Handle);
178194 cFunc (TEvents::TSystem::Wakeup, HandleTimeout);
179195 }
180196 }
@@ -202,6 +218,12 @@ class TJsonTenantInfo : public TViewerPipeClient {
202218 it->second .Error (error);
203219 }
204220 }
221+ auto itDescribes = DescribesBySchemeShard.find (ev->Get ()->TabletId );
222+ if (itDescribes != DescribesBySchemeShard.end ()) {
223+ for (const TString& path : itDescribes->second ) {
224+ DescribeSchemeResult[path].Error (error);
225+ }
226+ }
205227 }
206228 TBase::Handle (ev); // all RequestDone() are handled by base handler
207229 }
@@ -397,14 +419,19 @@ class TJsonTenantInfo : public TViewerPipeClient {
397419 if (result.IsOk ()) {
398420 auto domainInfo = result.Get ()->Request ->ResultSet .begin ()->DomainInfo ;
399421 TTabletId hiveId = domainInfo->Params .GetHive ();
422+ TTabletId schemeShardId = domainInfo->Params .GetSchemeShard ();
400423 if (hiveId) {
401424 if (HiveDomainStats.count (hiveId) == 0 ) {
402425 HiveDomainStats[hiveId] = MakeRequestHiveDomainStats (hiveId);
403426 }
404- if (Storage) {
405- if (HiveStorageStats.count (hiveId) == 0 ) {
406- HiveStorageStats[hiveId] = MakeRequestHiveStorageStats (hiveId);
407- }
427+ }
428+ if (Storage) {
429+ if (hiveId && HiveStorageStats.count (hiveId) == 0 ) {
430+ HiveStorageStats[hiveId] = MakeRequestHiveStorageStats (hiveId);
431+ }
432+ if (schemeShardId && DescribeSchemeResult.count (path) == 0 ) {
433+ DescribeSchemeResult[path] = MakeRequestSchemeShardDescribe (schemeShardId, path);
434+ DescribesBySchemeShard[schemeShardId].emplace_back (path);
408435 }
409436 }
410437 NKikimrViewer::TTenant& tenant = TenantBySubDomainKey[domainInfo->DomainKey ];
@@ -424,6 +451,13 @@ class TJsonTenantInfo : public TViewerPipeClient {
424451 }
425452 }
426453
454+ void Handle (NSchemeShard::TEvSchemeShard::TEvDescribeSchemeResult::TPtr& ev) {
455+ TString path = ev->Get ()->GetRecord ().GetPath ();
456+ if (DescribeSchemeResult[path].Set (std::move (ev))) {
457+ RequestDone ();
458+ }
459+ }
460+
427461 void Handle (NNodeWhiteboard::TEvWhiteboard::TEvSystemStateResponse::TPtr& ev) {
428462 ui32 nodeId = ev.Get ()->Cookie ;
429463 if (SystemStateResponse[nodeId].Set (std::move (ev))) {
@@ -745,7 +779,6 @@ class TJsonTenantInfo : public TViewerPipeClient {
745779 }
746780 }
747781
748- THashMap<NKikimrViewer::TStorageUsage::EType, ui64> tablesStorageByType;
749782 THashMap<NKikimrViewer::TStorageUsage::EType, TStorageQuota> storageQuotasByType;
750783
751784 for (const auto & quota : tenant.GetDatabaseQuotas ().storage_quotas ()) {
@@ -755,42 +788,47 @@ class TJsonTenantInfo : public TViewerPipeClient {
755788 usage.HardQuota += quota.data_size_hard_quota ();
756789 }
757790
758- if (entry.DomainDescription ) {
759- for (const auto & poolUsage : entry.DomainDescription ->Description .GetDiskSpaceUsage ().GetStoragePoolsUsage ()) {
791+ auto itDescribeScheme = DescribeSchemeResult.find (name);
792+ if (itDescribeScheme != DescribeSchemeResult.end () && itDescribeScheme->second .IsOk ()) {
793+ const auto & record = itDescribeScheme->second .Get ()->GetRecord ();
794+ const auto & domainDescription (record.GetPathDescription ().GetDomainDescription ());
795+ THashMap<NKikimrViewer::TStorageUsage::EType, ui64> tablesStorageByType;
796+
797+ for (const auto & poolUsage : domainDescription.GetDiskSpaceUsage ().GetStoragePoolsUsage ()) {
760798 auto type = GetStorageType (poolUsage.GetPoolKind ());
761799 tablesStorageByType[type] += poolUsage.GetTotalSize ();
762800 }
763801
764- if (tablesStorageByType.empty () && entry. DomainDescription -> Description .HasDiskSpaceUsage ()) {
765- tablesStorageByType[GuessStorageType (entry. DomainDescription -> Description )] =
766- entry. DomainDescription -> Description .GetDiskSpaceUsage ().GetTables ().GetTotalSize ()
767- + entry. DomainDescription -> Description .GetDiskSpaceUsage ().GetTopics ().GetDataSize ();
802+ if (tablesStorageByType.empty () && domainDescription .HasDiskSpaceUsage ()) {
803+ tablesStorageByType[GuessStorageType (domainDescription )] =
804+ domainDescription .GetDiskSpaceUsage ().GetTables ().GetTotalSize ()
805+ + domainDescription .GetDiskSpaceUsage ().GetTopics ().GetDataSize ();
768806 }
769807
770808 if (storageQuotasByType.empty ()) {
771- auto & quotas = storageQuotasByType[GuessStorageType (entry. DomainDescription -> Description )];
772- quotas.HardQuota = entry. DomainDescription -> Description .GetDatabaseQuotas ().data_size_hard_quota ();
773- quotas.SoftQuota = entry. DomainDescription -> Description .GetDatabaseQuotas ().data_size_soft_quota ();
809+ auto & quotas = storageQuotasByType[GuessStorageType (domainDescription )];
810+ quotas.HardQuota = domainDescription .GetDatabaseQuotas ().data_size_hard_quota ();
811+ quotas.SoftQuota = domainDescription .GetDatabaseQuotas ().data_size_soft_quota ();
774812 }
775- }
776813
777- for (const auto & [type, size] : tablesStorageByType) {
778- auto it = storageQuotasByType.find (type);
779- auto & tablesStorage = *tenant.AddTablesStorage ();
780- tablesStorage.SetType (type);
781- tablesStorage.SetSize (size);
782- if (it != storageQuotasByType.end ()) {
783- tablesStorage.SetLimit (it->second .SoftQuota );
784- tablesStorage.SetSoftQuota (it->second .SoftQuota );
785- tablesStorage.SetHardQuota (it->second .HardQuota );
814+ for (const auto & [type, size] : tablesStorageByType) {
815+ auto it = storageQuotasByType.find (type);
816+ auto & tablesStorage = *tenant.AddTablesStorage ();
817+ tablesStorage.SetType (type);
818+ tablesStorage.SetSize (size);
819+ if (it != storageQuotasByType.end ()) {
820+ tablesStorage.SetLimit (it->second .SoftQuota );
821+ tablesStorage.SetSoftQuota (it->second .SoftQuota );
822+ tablesStorage.SetHardQuota (it->second .HardQuota );
823+ }
786824 }
787- }
788825
789- for (const auto & [type, pr] : databaseStorageByType) {
790- auto & databaseStorage = *tenant.AddDatabaseStorage ();
791- databaseStorage.SetType (type);
792- databaseStorage.SetSize (pr.first );
793- databaseStorage.SetLimit (pr.first + pr.second );
826+ for (const auto & [type, pr] : databaseStorageByType) {
827+ auto & databaseStorage = *tenant.AddDatabaseStorage ();
828+ databaseStorage.SetType (type);
829+ databaseStorage.SetSize (pr.first );
830+ databaseStorage.SetLimit (pr.first + pr.second );
831+ }
794832 }
795833 }
796834
0 commit comments