Skip to content

Commit bd36f9e

Browse files
authored
cleanup api and add local pdisk restart handler (#4982)
1 parent 8ec6905 commit bd36f9e

35 files changed

+471
-148
lines changed

ydb/core/mon/async_http_mon.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,7 @@ void TAsyncHttpMon::Start(TActorSystem* actorSystem) {
732732
"text/javascript",
733733
"application/javascript",
734734
"application/json",
735+
"application/yaml",
735736
};
736737
addPort->SslCertificatePem = Config.Certificate;
737738
addPort->Secure = !Config.Certificate.empty();

ydb/core/viewer/json_acl.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ class TJsonACL : public TViewerPipeClient<TJsonACL> {
8080

8181
void ReplyAndPassAway() {
8282
TStringStream json;
83-
TString headers = Viewer->GetHTTPOKJSON(Event->Get());
8483
if (DescribeResult != nullptr) {
8584
//TProtoToJson::ProtoToJson(json, DescribeResult->GetRecord(), JsonSettings);
8685
const auto& pbRecord(DescribeResult->GetRecord());
@@ -155,16 +154,17 @@ class TJsonACL : public TViewerPipeClient<TJsonACL> {
155154

156155
switch (DescribeResult->GetRecord().GetStatus()) {
157156
case NKikimrScheme::StatusAccessDenied:
158-
headers = Viewer->GetHTTPFORBIDDEN(Event->Get());
159-
break;
157+
Send(Event->Sender, new NMon::TEvHttpInfoRes(Viewer->GetHTTPFORBIDDEN(Event->Get()), 0, NMon::IEvHttpInfoRes::EContentType::Custom));
158+
PassAway();
159+
return;
160160
default:
161161
break;
162162
}
163163
} else {
164164
json << "null";
165165
}
166166

167-
Send(Event->Sender, new NMon::TEvHttpInfoRes(headers + json.Str(), 0, NMon::IEvHttpInfoRes::EContentType::Custom));
167+
Send(Event->Sender, new NMon::TEvHttpInfoRes(Viewer->GetHTTPOKJSON(Event->Get(), json.Str()), 0, NMon::IEvHttpInfoRes::EContentType::Custom));
168168
PassAway();
169169
}
170170

ydb/core/viewer/json_autocomplete.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ class TJsonAutocomplete : public TViewerPipeClient<TJsonAutocomplete> {
390390
} else {
391391
TStringStream json;
392392
TProtoToJson::ProtoToJson(json, Result, JsonSettings);
393-
Send(Event->Sender, new NMon::TEvHttpInfoRes(Viewer->GetHTTPOKJSON(Event->Get()) + json.Str(), 0, NMon::IEvHttpInfoRes::EContentType::Custom));
393+
Send(Event->Sender, new NMon::TEvHttpInfoRes(Viewer->GetHTTPOKJSON(Event->Get(), json.Str()), 0, NMon::IEvHttpInfoRes::EContentType::Custom));
394394
}
395395
}
396396

ydb/core/viewer/json_browse.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ class TJsonBrowse : public TActorBootstrapped<TJsonBrowse> {
178178
}
179179
TProtoToJson::ProtoToJson(json, browseInfo, JsonSettings);
180180
}
181-
ctx.Send(Event->Sender, new NMon::TEvHttpInfoRes(Viewer->GetHTTPOKJSON(Event->Get()) + json.Str(), 0, NMon::IEvHttpInfoRes::EContentType::Custom));
181+
ctx.Send(Event->Sender, new NMon::TEvHttpInfoRes(Viewer->GetHTTPOKJSON(Event->Get(), json.Str()), 0, NMon::IEvHttpInfoRes::EContentType::Custom));
182182
Die(ctx);
183183
}
184184

ydb/core/viewer/json_bscontrollerinfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class TJsonBSControllerInfo : public TViewerPipeClient<TJsonBSControllerInfo> {
6161
} else {
6262
json << "null";
6363
}
64-
Send(Event->Sender, new NMon::TEvHttpInfoRes(Viewer->GetHTTPOKJSON(Event->Get()) + json.Str(), 0, NMon::IEvHttpInfoRes::EContentType::Custom));
64+
Send(Event->Sender, new NMon::TEvHttpInfoRes(Viewer->GetHTTPOKJSON(Event->Get(), json.Str()), 0, NMon::IEvHttpInfoRes::EContentType::Custom));
6565
PassAway();
6666
}
6767

ydb/core/viewer/json_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class TJsonConfig : public TActorBootstrapped<TJsonConfig> {
3535
config.MutableNameserviceConfig()->ClearAcceptUUID();
3636
config.ClearAuthConfig();
3737
TProtoToJson::ProtoToJson(json, config);
38-
ctx.Send(Event->Sender, new NMon::TEvHttpInfoRes(Viewer->GetHTTPOKJSON(Event->Get()) + json.Str(), 0, NMon::IEvHttpInfoRes::EContentType::Custom));
38+
ctx.Send(Event->Sender, new NMon::TEvHttpInfoRes(Viewer->GetHTTPOKJSON(Event->Get(), json.Str()), 0, NMon::IEvHttpInfoRes::EContentType::Custom));
3939
Die(ctx);
4040
}
4141
};

ydb/core/viewer/json_counters.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ class TJsonCounters : public TActorBootstrapped<TJsonCounters> {
425425
json << ']';
426426
json << '}';
427427

428-
ctx.Send(Event->Sender, new NMon::TEvHttpInfoRes(Viewer->GetHTTPOKJSON(Event->Get()) + json.Str(), 0, NMon::IEvHttpInfoRes::EContentType::Custom));
428+
ctx.Send(Event->Sender, new NMon::TEvHttpInfoRes(Viewer->GetHTTPOKJSON(Event->Get(), json.Str()), 0, NMon::IEvHttpInfoRes::EContentType::Custom));
429429
Die(ctx);
430430
}
431431

ydb/core/viewer/json_describe.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ class TJsonDescribe : public TViewerPipeClient<TJsonDescribe> {
232232

233233
void ReplyAndPassAway() {
234234
TStringStream json;
235-
TString headers = Viewer->GetHTTPOKJSON(Event->Get());
236235
if (SchemeShardResult != nullptr && SchemeShardResult->GetRecord().GetStatus() == NKikimrScheme::EStatus::StatusSuccess) {
237236
DescribeResult = GetSchemeShardDescribeSchemeInfo();
238237
} else if (CacheResult != nullptr) {
@@ -264,15 +263,17 @@ class TJsonDescribe : public TViewerPipeClient<TJsonDescribe> {
264263
const auto *descriptor = NKikimrScheme::EStatus_descriptor();
265264
auto accessDeniedStatus = descriptor->FindValueByNumber(NKikimrScheme::StatusAccessDenied)->name();
266265
if (DescribeResult->GetStatus() == accessDeniedStatus) {
267-
headers = Viewer->GetHTTPFORBIDDEN(Event->Get());
266+
Send(Event->Sender, new NMon::TEvHttpInfoRes(Viewer->GetHTTPFORBIDDEN(Event->Get()), 0, NMon::IEvHttpInfoRes::EContentType::Custom));
267+
PassAway();
268+
return;
268269
}
269270
TProtoToJson::ProtoToJson(json, *DescribeResult, JsonSettings);
270271
DecodeExternalTableContent(json);
271272
} else {
272273
json << "null";
273274
}
274275

275-
Send(Event->Sender, new NMon::TEvHttpInfoRes(headers + json.Str(), 0, NMon::IEvHttpInfoRes::EContentType::Custom));
276+
Send(Event->Sender, new NMon::TEvHttpInfoRes(Viewer->GetHTTPOKJSON(Event->Get(), json.Str()), 0, NMon::IEvHttpInfoRes::EContentType::Custom));
276277
PassAway();
277278
}
278279

ydb/core/viewer/json_graph.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,21 +69,21 @@ class TJsonGraph : public TActorBootstrapped<TJsonGraph> {
6969
if (response.GetError()) {
7070
json["status"] = "error";
7171
json["error"] = response.GetError();
72-
Send(Event->Sender, new NMon::TEvHttpInfoRes(Viewer->GetHTTPOKJSON(Event->Get()) + NJson::WriteJson(json, false), 0, NMon::IEvHttpInfoRes::EContentType::Custom));
72+
Send(Event->Sender, new NMon::TEvHttpInfoRes(Viewer->GetHTTPOKJSON(Event->Get(), NJson::WriteJson(json, false)), 0, NMon::IEvHttpInfoRes::EContentType::Custom));
7373
return PassAway();
7474
}
7575
if (response.DataSize() != Metrics.size()) {
7676
json["status"] = "error";
7777
json["error"] = "Invalid data size received";
78-
Send(Event->Sender, new NMon::TEvHttpInfoRes(Viewer->GetHTTPOKJSON(Event->Get()) + NJson::WriteJson(json, false), 0, NMon::IEvHttpInfoRes::EContentType::Custom));
78+
Send(Event->Sender, new NMon::TEvHttpInfoRes(Viewer->GetHTTPOKJSON(Event->Get(), NJson::WriteJson(json, false)), 0, NMon::IEvHttpInfoRes::EContentType::Custom));
7979
return PassAway();
8080
}
8181
for (size_t nMetric = 0; nMetric < response.DataSize(); ++nMetric) {
8282
const auto& protoMetric(response.GetData(nMetric));
8383
if (response.TimeSize() != protoMetric.ValuesSize()) {
8484
json["status"] = "error";
8585
json["error"] = "Invalid value size received";
86-
Send(Event->Sender, new NMon::TEvHttpInfoRes(Viewer->GetHTTPOKJSON(Event->Get()) + NJson::WriteJson(json, false), 0, NMon::IEvHttpInfoRes::EContentType::Custom));
86+
Send(Event->Sender, new NMon::TEvHttpInfoRes(Viewer->GetHTTPOKJSON(Event->Get(), NJson::WriteJson(json, false)), 0, NMon::IEvHttpInfoRes::EContentType::Custom));
8787
return PassAway();
8888
}
8989
}
@@ -133,7 +133,7 @@ class TJsonGraph : public TActorBootstrapped<TJsonGraph> {
133133
}
134134
}
135135

136-
Send(Event->Sender, new NMon::TEvHttpInfoRes(Viewer->GetHTTPOKJSON(Event->Get()) + NJson::WriteJson(json, false), 0, NMon::IEvHttpInfoRes::EContentType::Custom));
136+
Send(Event->Sender, new NMon::TEvHttpInfoRes(Viewer->GetHTTPOKJSON(Event->Get(), NJson::WriteJson(json, false)), 0, NMon::IEvHttpInfoRes::EContentType::Custom));
137137
PassAway();
138138
}
139139

ydb/core/viewer/json_handlers.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class TJsonHandlerBase {
1313
virtual TString GetRequestSummary() = 0;
1414
virtual TString GetRequestDescription() = 0;
1515
virtual YAML::Node GetRequestParameters() = 0;
16+
virtual YAML::Node GetRequestSwagger() = 0;
1617
};
1718

1819
template <typename ActorRequestType>
@@ -41,23 +42,28 @@ class TJsonHandler : public TJsonHandlerBase {
4142
static YAML::Node parameters = TJsonRequestParameters<ActorRequestType>::GetParameters();
4243
return parameters;
4344
}
45+
46+
YAML::Node GetRequestSwagger() override {
47+
static YAML::Node swagger = TJsonRequestSwagger<ActorRequestType>::GetSwagger();
48+
return swagger;
49+
}
4450
};
4551

4652
struct TJsonHandlers {
4753
std::vector<TString> JsonHandlersList;
48-
THashMap<TString, TAutoPtr<TJsonHandlerBase>> JsonHandlersIndex;
54+
THashMap<TString, std::shared_ptr<TJsonHandlerBase>> JsonHandlersIndex;
4955

50-
void AddHandler(const TString& name, TAutoPtr<TJsonHandlerBase> handler) {
56+
void AddHandler(const TString& name, TJsonHandlerBase* handler) {
5157
JsonHandlersList.push_back(name);
52-
JsonHandlersIndex[name] = std::move(handler);
58+
JsonHandlersIndex[name] = std::shared_ptr<TJsonHandlerBase>(handler);
5359
}
5460

5561
TJsonHandlerBase* FindHandler(const TString& name) const {
5662
auto it = JsonHandlersIndex.find(name);
5763
if (it == JsonHandlersIndex.end()) {
5864
return nullptr;
5965
}
60-
return it->second.Get();
66+
return it->second.get();
6167
}
6268
};
6369

0 commit comments

Comments
 (0)