aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Efimov <xeno@prnwatch.com>2022-02-22 20:47:28 +0300
committerAlexey Efimov <xeno@prnwatch.com>2022-02-22 20:47:28 +0300
commit676d0708782b1bb1bbf38aff1d33235f3004185d (patch)
treea5d94c37b1997612e77aca2a0500c8b2d4729ab4
parent22d10b79b67f22b1a627980ebb0c63b7e5fcddf6 (diff)
downloadydb-676d0708782b1bb1bbf38aff1d33235f3004185d.tar.gz
add web handler to move specific tablet to specific node KIKIMR-14409
ref:cf2bc48c18f0211a65b448d9c8a6d3ca7d21e2d5
-rw-r--r--ydb/core/mind/hive/hive_impl.h2
-rw-r--r--ydb/core/mind/hive/monitoring.cpp92
-rw-r--r--ydb/core/protos/auth.proto4
-rw-r--r--ydb/core/protos/counters_hive.proto1
4 files changed, 96 insertions, 3 deletions
diff --git a/ydb/core/mind/hive/hive_impl.h b/ydb/core/mind/hive/hive_impl.h
index 70c4530fee0..c81fea97f15 100644
--- a/ydb/core/mind/hive/hive_impl.h
+++ b/ydb/core/mind/hive/hive_impl.h
@@ -174,6 +174,7 @@ protected:
friend class THiveDrain;
friend class THiveFill;
friend class TReassignTabletWaitActor;
+ friend class TMoveTabletWaitActor;
friend class TStopTabletWaitActor;
friend class TResumeTabletWaitActor;
friend class TInitMigrationWaitActor;
@@ -205,6 +206,7 @@ protected:
friend class TTxMonEvent_Rebalance;
friend class TTxMonEvent_Storage;
friend class TTxMonEvent_FindTablet;
+ friend class TTxMonEvent_MoveTablet;
friend class TTxMonEvent_StopTablet;
friend class TTxMonEvent_ResumeTablet;
friend class TTxMonEvent_InitMigration;
diff --git a/ydb/core/mind/hive/monitoring.cpp b/ydb/core/mind/hive/monitoring.cpp
index 7e9a83b354e..c42fd7fc16d 100644
--- a/ydb/core/mind/hive/monitoring.cpp
+++ b/ydb/core/mind/hive/monitoring.cpp
@@ -2390,6 +2390,94 @@ public:
}
};
+class TMoveTabletWaitActor : public TActor<TMoveTabletWaitActor>, public ISubActor {
+public:
+ TActorId Source;
+ THive* Hive;
+
+ static constexpr NKikimrServices::TActivity::EType ActorActivityType() {
+ return NKikimrServices::TActivity::HIVE_MON_REQUEST;
+ }
+
+ TMoveTabletWaitActor(const TActorId& source, THive* hive)
+ : TActor(&TMoveTabletWaitActor::StateWork)
+ , Source(source)
+ , Hive(hive)
+ {}
+
+ void PassAway() override {
+ Hive->RemoveSubActor(this);
+ return IActor::PassAway();
+ }
+
+ void Cleanup() override {
+ PassAway();
+ }
+
+ void Handle(TEvPrivate::TEvRestartComplete::TPtr& result) {
+ NJson::TJsonValue response;
+ response["status"] = result->Get()->Status;
+ Send(Source, new NMon::TEvRemoteJsonInfoRes(NJson::WriteJson(response, false)));
+ PassAway();
+ }
+
+ STATEFN(StateWork) {
+ switch (ev->GetTypeRewrite()) {
+ cFunc(TEvents::TSystem::PoisonPill, PassAway);
+ hFunc(TEvPrivate::TEvRestartComplete, Handle);
+ }
+ }
+};
+
+class TTxMonEvent_MoveTablet : public TTransactionBase<THive> {
+public:
+ TAutoPtr<NMon::TEvRemoteHttpInfo> Event;
+ const TActorId Source;
+ TTabletId TabletId = 0;
+ TNodeId NodeId = 0;
+ bool Wait = true;
+
+ TTxMonEvent_MoveTablet(const TActorId& source, NMon::TEvRemoteHttpInfo::TPtr& ev, TSelf* hive)
+ : TBase(hive)
+ , Event(ev->Release())
+ , Source(source)
+ {
+ TabletId = FromStringWithDefault<TTabletId>(Event->Cgi().Get("tablet"), TabletId);
+ NodeId = FromStringWithDefault<TNodeId>(Event->Cgi().Get("node"), NodeId);
+ Wait = FromStringWithDefault(Event->Cgi().Get("wait"), Wait);
+ }
+
+ TTxType GetTxType() const override { return NHive::TXTYPE_MON_MOVE_TABLET; }
+
+ bool Execute(TTransactionContext&, const TActorContext& ctx) override {
+ TLeaderTabletInfo* tablet = Self->FindTablet(TabletId);
+ if (tablet == nullptr) {
+ ctx.Send(Source, new NMon::TEvRemoteJsonInfoRes(TStringBuilder() << "{\"error\":\"Tablet not found\"}"));
+ return true;
+ }
+ TNodeInfo* node = Self->FindNode(NodeId);
+ if (node == nullptr) {
+ ctx.Send(Source, new NMon::TEvRemoteJsonInfoRes(TStringBuilder() << "{\"error\":\"Node not found\"}"));
+ return true;
+ }
+ if (Wait) {
+ TMoveTabletWaitActor* waitActor = new TMoveTabletWaitActor(Source, Self);
+ TActorId waitActorId = ctx.RegisterWithSameMailbox(waitActor);
+ tablet->ActorsToNotifyOnRestart.emplace_back(waitActorId);
+ Self->SubActors.emplace_back(waitActor);
+ }
+ TInstant now = TActivationContext::Now();
+ tablet->MakeBalancerDecision(now);
+ Self->Execute(Self->CreateRestartTablet(tablet->GetFullTabletId(), NodeId));
+ if (!Wait) {
+ ctx.Send(Source, new NMon::TEvRemoteJsonInfoRes("{}"));
+ }
+ return true;
+ }
+
+ void Complete(const TActorContext&) override {}
+};
+
class TStopTabletWaitActor : public TActor<TStopTabletWaitActor>, public ISubActor {
public:
TActorId Source;
@@ -2427,7 +2515,6 @@ public:
}
};
-
class TTxMonEvent_StopTablet : public TTransactionBase<THive> {
public:
TAutoPtr<NMon::TEvRemoteHttpInfo> Event;
@@ -3372,6 +3459,9 @@ void THive::CreateEvMonitoring(NMon::TEvRemoteHttpInfo::TPtr& ev, const TActorCo
if (page == "QueryMigration") {
return Execute(new TTxMonEvent_QueryMigration(ev->Sender, ev, this), ctx);
}
+ if (page == "MoveTablet") {
+ return Execute(new TTxMonEvent_MoveTablet(ev->Sender, ev, this), ctx);
+ }
if (page == "StopTablet") {
return Execute(new TTxMonEvent_StopTablet(ev->Sender, ev, this), ctx);
}
diff --git a/ydb/core/protos/auth.proto b/ydb/core/protos/auth.proto
index 1f252b8f711..7ba2bc4bd54 100644
--- a/ydb/core/protos/auth.proto
+++ b/ydb/core/protos/auth.proto
@@ -32,10 +32,10 @@ message TAuthConfig {
optional string UserAccountDomain = 43 [default = "passport"];
optional string ServiceDomain = 44 [default = "service"];
optional bool DomainLoginOnly = 45 [default = true];
- optional string RefreshPeriod = 50 [default = "1s"]; // how often do we check for ticket freshness/expiration
+ optional string RefreshPeriod = 50 [default = "1s"]; // how often we check for tickets freshness/expiration
optional string RefreshTime = 51 [default = "1h"]; // we will try to refresh valid ticket within RefreshTime/2 and RefreshTime randomly
optional string LifeTime = 52 [default = "1h"]; // for how long ticket will remain in the cache after last access
- optional string ExpireTime = 53 [default = "24h"]; // after what time ticket will expired and removed from the cache
+ optional string ExpireTime = 53 [default = "24h"]; // after what time ticket will be expired and removed from the cache
optional string TVMExpireTime = 54 [default = "2m"]; // the same for TVM tickets
optional string MinErrorRefreshTime = 55 [default = "1s"]; // min period for refresh of error ticket
optional string MaxErrorRefreshTime = 56 [default = "1m"]; // max period for refresh of error ticket
diff --git a/ydb/core/protos/counters_hive.proto b/ydb/core/protos/counters_hive.proto
index 952f4e99e3c..01375851923 100644
--- a/ydb/core/protos/counters_hive.proto
+++ b/ydb/core/protos/counters_hive.proto
@@ -104,4 +104,5 @@ enum ETxTypes {
TXTYPE_STOP_TABLET = 54 [(TxTypeOpts) = {Name: "TxStopTablet"}];
TXTYPE_RESUME_TABLET = 55 [(TxTypeOpts) = {Name: "TxResumeTablet"}];
TXTYPE_RESTART_TABLET = 56 [(TxTypeOpts) = {Name: "TxRestartTablet"}];
+ TXTYPE_MON_MOVE_TABLET = 57 [(TxTypeOpts) = {Name: "TxMonMoveTablet"}];
}