Skip to content

Commit 8c85a42

Browse files
authored
add get_settings action to graph shard (#16568)
1 parent 5e559a7 commit 8c85a42

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

ydb/core/graph/shard/tx_monitoring.cpp

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "shard_impl.h"
22
#include "log.h"
3+
#include <library/cpp/json/json_writer.h>
34

45
namespace NKikimr {
56
namespace NGraph {
@@ -102,7 +103,7 @@ class TTxMonitoring : public TTransactionBase<TGraphShard> {
102103
if (wasLine) {
103104
html << "<br>";
104105
}
105-
html << "arithmetic " << name << " " << value.ValueA << " " << value.Op << " " << value.ValueB;
106+
html << "arithmetic " << name << " " << value.ValueA << " " << value.Op << " " << value.ValueB;
106107
wasLine = true;
107108
}
108109
html << "</td></tr>";
@@ -113,6 +114,45 @@ class TTxMonitoring : public TTransactionBase<TGraphShard> {
113114
}
114115
};
115116

117+
class TTxMonitoringGetSettings : public TTransactionBase<TGraphShard> {
118+
private:
119+
NMon::TEvRemoteHttpInfo::TPtr Event;
120+
121+
public:
122+
TTxMonitoringGetSettings(TGraphShard* shard, NMon::TEvRemoteHttpInfo::TPtr ev)
123+
: TBase(shard)
124+
, Event(std::move(ev))
125+
{}
126+
127+
TTxType GetTxType() const override { return NGraphShard::TXTYPE_MONITORING; }
128+
129+
bool Execute(TTransactionContext&, const TActorContext&) override {
130+
BLOG_D("TTxMonitoringGetSettings::Execute");
131+
return true;
132+
}
133+
134+
void Complete(const TActorContext& ctx) override {
135+
BLOG_D("TTxMonitoringGetSettings::Complete");
136+
NJson::TJsonValue json;
137+
switch (Self->BackendType) {
138+
case EBackendType::Memory:
139+
json["backend"] = "Memory";
140+
json["metrics_size"] = Self->MemoryBackend.MetricsIndex.size();
141+
json["records_size"] = Self->MemoryBackend.MetricsValues.size();
142+
break;
143+
case EBackendType::Local:
144+
json["backend"] = "Local";
145+
json["metrics_size"] = Self->LocalBackend.MetricsIndex.size();
146+
break;
147+
case EBackendType::External:
148+
json["backend"] = "External";
149+
break;
150+
}
151+
ctx.Send(Event->Sender, new NMon::TEvRemoteJsonInfoRes(NJson::WriteJson(json, false)));
152+
}
153+
};
154+
155+
116156
void TGraphShard::ExecuteTxMonitoring(NMon::TEvRemoteHttpInfo::TPtr ev) {
117157
if (ev->Get()->Cgi().Has("action")) {
118158
if (ev->Get()->Cgi().Get("action") == "change_backend") {
@@ -123,6 +163,10 @@ void TGraphShard::ExecuteTxMonitoring(NMon::TEvRemoteHttpInfo::TPtr ev) {
123163
return;
124164
}
125165
}
166+
if (ev->Get()->Cgi().Get("action") == "get_settings") {
167+
Execute(new TTxMonitoringGetSettings(this, std::move(ev)));
168+
return;
169+
}
126170
Send(ev->Sender, new NMon::TEvRemoteHttpInfoRes("<html><p>bad parameters</p></html>"));
127171
return;
128172
}

ydb/core/graph/shard/ya.make

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ SRCS(
1717
)
1818

1919
PEERDIR(
20+
library/cpp/json
2021
ydb/library/actors/core
2122
ydb/core/base
2223
ydb/core/cms/console

0 commit comments

Comments
 (0)