Skip to content

Commit 6b85bc3

Browse files
authored
optimize tenantinfo handler (#7699)
1 parent 8053e6d commit 6b85bc3

File tree

4 files changed

+369
-291
lines changed

4 files changed

+369
-291
lines changed

ydb/core/viewer/json_pipe_req.cpp

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,26 @@ void TViewerPipeClient::SendDelayedRequests() {
8787
}
8888
}
8989

90+
TPathId TViewerPipeClient::GetPathId(TEvTxProxySchemeCache::TEvNavigateKeySetResult::TPtr& ev) {
91+
if (ev->Get()->Request->ResultSet.size() == 1) {
92+
if (ev->Get()->Request->ResultSet.begin()->Self) {
93+
const auto& info = ev->Get()->Request->ResultSet.begin()->Self->Info;
94+
return TPathId(info.GetSchemeshardId(), info.GetPathId());
95+
}
96+
if (ev->Get()->Request->ResultSet.begin()->TableId) {
97+
return ev->Get()->Request->ResultSet.begin()->TableId.PathId;
98+
}
99+
}
100+
return {};
101+
}
102+
103+
TString TViewerPipeClient::GetPath(TEvTxProxySchemeCache::TEvNavigateKeySetResult::TPtr& ev) {
104+
if (ev->Get()->Request->ResultSet.size() == 1) {
105+
return CanonizePath(ev->Get()->Request->ResultSet.begin()->Path);
106+
}
107+
return {};
108+
}
109+
90110
void TViewerPipeClient::RequestHiveDomainStats(NNodeWhiteboard::TTabletId hiveId) {
91111
TActorId pipeClient = ConnectTabletPipe(hiveId);
92112
THolder<TEvHive::TEvRequestHiveDomainStats> request = MakeHolder<TEvHive::TEvRequestHiveDomainStats>();
@@ -113,6 +133,19 @@ void TViewerPipeClient::RequestHiveStorageStats(NNodeWhiteboard::TTabletId hiveI
113133
SendRequestToPipe(pipeClient, request.Release(), hiveId);
114134
}
115135

136+
TViewerPipeClient::TRequestResponse<TEvHive::TEvResponseHiveDomainStats> TViewerPipeClient::MakeRequestHiveDomainStats(NNodeWhiteboard::TTabletId hiveId) {
137+
TActorId pipeClient = ConnectTabletPipe(hiveId);
138+
THolder<TEvHive::TEvRequestHiveDomainStats> request = MakeHolder<TEvHive::TEvRequestHiveDomainStats>();
139+
request->Record.SetReturnFollowers(Followers);
140+
request->Record.SetReturnMetrics(Metrics);
141+
auto response = MakeRequestToPipe<TEvHive::TEvResponseHiveDomainStats>(pipeClient, request.Release(), hiveId);
142+
if (response.Span) {
143+
auto hive_id = "#" + ::ToString(hiveId);
144+
response.Span.Attribute("hive_id", hive_id);
145+
}
146+
return response;
147+
}
148+
116149
TViewerPipeClient::TRequestResponse<TEvHive::TEvResponseHiveStorageStats> TViewerPipeClient::MakeRequestHiveStorageStats(NNodeWhiteboard::TTabletId hiveId) {
117150
TActorId pipeClient = ConnectTabletPipe(hiveId);
118151
THolder<TEvHive::TEvRequestHiveStorageStats> request = MakeHolder<TEvHive::TEvRequestHiveStorageStats>();
@@ -124,6 +157,36 @@ TViewerPipeClient::TRequestResponse<TEvHive::TEvResponseHiveStorageStats> TViewe
124157
return response;
125158
}
126159

160+
TViewerPipeClient::TRequestResponse<TEvViewer::TEvViewerResponse> TViewerPipeClient::MakeRequestViewer(TNodeId nodeId, TEvViewer::TEvViewerRequest* request, ui32 flags) {
161+
auto requestType = request->Record.GetRequestCase();
162+
auto response = MakeRequest<TEvViewer::TEvViewerResponse>(MakeViewerID(nodeId), request, flags, nodeId);
163+
if (response.Span) {
164+
TString requestTypeString;
165+
switch (requestType) {
166+
case NKikimrViewer::TEvViewerRequest::kTabletRequest:
167+
requestTypeString = "TabletRequest";
168+
break;
169+
case NKikimrViewer::TEvViewerRequest::kSystemRequest:
170+
requestTypeString = "SystemRequest";
171+
break;
172+
case NKikimrViewer::TEvViewerRequest::kQueryRequest:
173+
requestTypeString = "QueryRequest";
174+
break;
175+
case NKikimrViewer::TEvViewerRequest::kRenderRequest:
176+
requestTypeString = "RenderRequest";
177+
break;
178+
case NKikimrViewer::TEvViewerRequest::kAutocompleteRequest:
179+
requestTypeString = "AutocompleteRequest";
180+
break;
181+
default:
182+
requestTypeString = ::ToString(static_cast<int>(requestType));
183+
break;
184+
}
185+
response.Span.Attribute("request_type", requestTypeString);
186+
}
187+
return response;
188+
}
189+
127190
void TViewerPipeClient::RequestConsoleListTenants() {
128191
TActorId pipeClient = ConnectTabletPipe(GetConsoleId());
129192
THolder<NConsole::TEvConsole::TEvListTenantsRequest> request = MakeHolder<NConsole::TEvConsole::TEvListTenantsRequest>();
@@ -143,6 +206,17 @@ void TViewerPipeClient::RequestConsoleGetTenantStatus(const TString& path) {
143206
SendRequestToPipe(pipeClient, request.Release());
144207
}
145208

209+
TViewerPipeClient::TRequestResponse<NConsole::TEvConsole::TEvGetTenantStatusResponse> TViewerPipeClient::MakeRequestConsoleGetTenantStatus(const TString& path) {
210+
TActorId pipeClient = ConnectTabletPipe(GetConsoleId());
211+
THolder<NConsole::TEvConsole::TEvGetTenantStatusRequest> request = MakeHolder<NConsole::TEvConsole::TEvGetTenantStatusRequest>();
212+
request->Record.MutableRequest()->set_path(path);
213+
auto response = MakeRequestToPipe<NConsole::TEvConsole::TEvGetTenantStatusResponse>(pipeClient, request.Release());
214+
if (response.Span) {
215+
response.Span.Attribute("path", path);
216+
}
217+
return response;
218+
}
219+
146220
void TViewerPipeClient::RequestBSControllerConfig() {
147221
TActorId pipeClient = ConnectTabletPipe(GetBSControllerId());
148222
THolder<TEvBlobStorage::TEvControllerConfigRequest> request = MakeHolder<TEvBlobStorage::TEvControllerConfigRequest>();
@@ -300,7 +374,7 @@ TViewerPipeClient::TRequestResponse<TEvTxProxySchemeCache::TEvNavigateKeySetResu
300374
request->ResultSet.emplace_back(entry);
301375
auto response = MakeRequest<TEvTxProxySchemeCache::TEvNavigateKeySetResult>(MakeSchemeCacheID(), new TEvTxProxySchemeCache::TEvNavigateKeySet(request.Release()), 0 /*flags*/, cookie);
302376
if (response.Span) {
303-
response.Span.Attribute("cookie", "#" + ::ToString(cookie));
377+
response.Span.Attribute("path", path);
304378
}
305379
return response;
306380
}
@@ -315,7 +389,7 @@ TViewerPipeClient::TRequestResponse<TEvTxProxySchemeCache::TEvNavigateKeySetResu
315389
request->ResultSet.emplace_back(entry);
316390
auto response = MakeRequest<TEvTxProxySchemeCache::TEvNavigateKeySetResult>(MakeSchemeCacheID(), new TEvTxProxySchemeCache::TEvNavigateKeySet(request.Release()), 0 /*flags*/, cookie);
317391
if (response.Span) {
318-
response.Span.Attribute("response", "#" + ::ToString(cookie));
392+
response.Span.Attribute("path_id", pathId.ToString());
319393
}
320394
return response;
321395
}
@@ -359,6 +433,7 @@ void TViewerPipeClient::InitConfig(const TCgiParameters& params) {
359433
Followers = FromStringWithDefault(params.Get("followers"), Followers);
360434
Metrics = FromStringWithDefault(params.Get("metrics"), Metrics);
361435
WithRetry = FromStringWithDefault(params.Get("with_retry"), WithRetry);
436+
MaxRequestsInFlight = FromStringWithDefault(params.Get("max_requests_in_flight"), MaxRequestsInFlight);
362437
}
363438

364439
void TViewerPipeClient::InitConfig(const TRequestSettings& settings) {

ydb/core/viewer/json_pipe_req.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class TViewerPipeClient : public TActorBootstrapped<TViewerPipeClient> {
3838
bool Metrics = true;
3939
bool WithRetry = true;
4040
ui32 Requests = 0;
41-
static constexpr ui32 MaxRequestsInFlight = 50;
41+
ui32 MaxRequestsInFlight = 50;
4242
NWilson::TSpan Span;
4343
IViewer* Viewer = nullptr;
4444
NMon::TEvHttpInfo::TPtr Event;
@@ -184,10 +184,14 @@ class TViewerPipeClient : public TActorBootstrapped<TViewerPipeClient> {
184184
return MakeBSControllerID();
185185
}
186186

187+
static TPathId GetPathId(TEvTxProxySchemeCache::TEvNavigateKeySetResult::TPtr& ev);
188+
static TString GetPath(TEvTxProxySchemeCache::TEvNavigateKeySetResult::TPtr& ev);
189+
TRequestResponse<TEvHive::TEvResponseHiveDomainStats> MakeRequestHiveDomainStats(TTabletId hiveId);
187190
TRequestResponse<TEvHive::TEvResponseHiveStorageStats> MakeRequestHiveStorageStats(TTabletId hiveId);
188191
void RequestConsoleListTenants();
189192
TRequestResponse<NConsole::TEvConsole::TEvListTenantsResponse> MakeRequestConsoleListTenants();
190193
void RequestConsoleGetTenantStatus(const TString& path);
194+
TRequestResponse<NConsole::TEvConsole::TEvGetTenantStatusResponse> MakeRequestConsoleGetTenantStatus(const TString& path);
191195
void RequestBSControllerConfig();
192196
void RequestBSControllerConfigWithStoragePools();
193197
TRequestResponse<TEvBlobStorage::TEvControllerConfigResponse> MakeRequestBSControllerConfigWithStoragePools();
@@ -207,6 +211,7 @@ class TViewerPipeClient : public TActorBootstrapped<TViewerPipeClient> {
207211
void RequestSchemeCacheNavigate(const TPathId& pathId);
208212
TRequestResponse<TEvTxProxySchemeCache::TEvNavigateKeySetResult> MakeRequestSchemeCacheNavigate(const TString& path, ui64 cookie = 0);
209213
TRequestResponse<TEvTxProxySchemeCache::TEvNavigateKeySetResult> MakeRequestSchemeCacheNavigate(TPathId pathId, ui64 cookie = 0);
214+
TRequestResponse<TEvViewer::TEvViewerResponse> MakeRequestViewer(TNodeId nodeId, TEvViewer::TEvViewerRequest* request, ui32 flags = 0);
210215
void RequestTxProxyDescribe(const TString& path);
211216
void RequestStateStorageEndpointsLookup(const TString& path);
212217
void RequestStateStorageMetadataCacheEndpointsLookup(const TString& path);

ydb/core/viewer/storage_groups.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,19 +1064,6 @@ class TStorageGroups : public TViewerPipeClient {
10641064
}
10651065
}
10661066

1067-
static TPathId GetPathId(TEvTxProxySchemeCache::TEvNavigateKeySetResult::TPtr& ev) {
1068-
if (ev->Get()->Request->ResultSet.size() == 1) {
1069-
if (ev->Get()->Request->ResultSet.begin()->Self) {
1070-
const auto& info = ev->Get()->Request->ResultSet.begin()->Self->Info;
1071-
return TPathId(info.GetSchemeshardId(), info.GetPathId());
1072-
}
1073-
if (ev->Get()->Request->ResultSet.begin()->TableId) {
1074-
return ev->Get()->Request->ResultSet.begin()->TableId.PathId;
1075-
}
1076-
}
1077-
return {};
1078-
}
1079-
10801067
void Handle(TEvTxProxySchemeCache::TEvNavigateKeySetResult::TPtr& ev) {
10811068
bool firstNavigate = (ev->Cookie == 0);
10821069
TPathId pathId = GetPathId(ev);

0 commit comments

Comments
 (0)