diff options
author | yuryalekseev <yuryalekseev@yandex-team.com> | 2022-07-12 11:55:07 +0300 |
---|---|---|
committer | yuryalekseev <yuryalekseev@yandex-team.com> | 2022-07-12 11:55:07 +0300 |
commit | 4213b519b93b5e3d657bc362837adfea82579dcc (patch) | |
tree | 420c725fd5ef86809d17c31a70b08740b6b85432 | |
parent | c294cbb440925d60778a83e07309347f8b7f04dd (diff) | |
download | ydb-4213b519b93b5e3d657bc362837adfea82579dcc.tar.gz |
Tidy up storage stats stuff.
-rw-r--r-- | ydb/core/mind/bscontroller/sys_view.cpp | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/ydb/core/mind/bscontroller/sys_view.cpp b/ydb/core/mind/bscontroller/sys_view.cpp index e3522770b3..159a38ec70 100644 --- a/ydb/core/mind/bscontroller/sys_view.cpp +++ b/ydb/core/mind/bscontroller/sys_view.cpp @@ -74,7 +74,6 @@ void CalculateGroupUsageStats(NKikimrSysView::TGroupInfo *info, const std::vecto class TSystemViewsCollector : public TActorBootstrapped<TSystemViewsCollector> { TControllerSystemViewsState State; - std::optional<std::vector<NKikimrSysView::TStorageStatsEntry>> StorageStats; std::vector<std::pair<TPDiskId, const NKikimrSysView::TPDiskInfo*>> PDiskIndex; std::vector<std::pair<TVSlotId, const NKikimrSysView::TVSlotInfo*>> VSlotIndex; std::vector<std::pair<TGroupId, const NKikimrSysView::TGroupInfo*>> GroupIndex; @@ -85,7 +84,10 @@ class TSystemViewsCollector : public TActorBootstrapped<TSystemViewsCollector> { ::NMonitoring::TDynamicCounterPtr Counters; std::unordered_set<std::tuple<TString>> PDiskFilterCounters; std::unordered_set<std::tuple<TString, TString>> ErasureCounters; + + std::vector<NKikimrSysView::TStorageStatsEntry> StorageStats; TActorId StorageStatsCalculatorId; + static constexpr TDuration StorageStatsUpdatePeriod = TDuration::Minutes(10); public: static constexpr NKikimrServices::TActivity::EType ActorActivityType() { @@ -102,7 +104,7 @@ public: void Bootstrap(const TActorContext&) { Become(&TThis::StateWork); - Schedule(TDuration::Seconds(0), new TEvCalculateStorageStatsRequest()); + RunStorageStatsCalculator(); } STRICT_STFUNC(StateWork, @@ -112,7 +114,7 @@ public: hFunc(TEvSysView::TEvGetGroupsRequest, Handle); hFunc(TEvSysView::TEvGetStoragePoolsRequest, Handle); hFunc(TEvSysView::TEvGetStorageStatsRequest, Handle); - hFunc(TEvCalculateStorageStatsRequest, Handle); + cFunc(NSysView::TEvSysView::EvCalculateStorageStatsRequest, RunStorageStatsCalculator); hFunc(TEvCalculateStorageStatsResponse, Handle); cFunc(TEvents::TSystem::Poison, PassAway); ) @@ -212,16 +214,14 @@ public: void Handle(TEvSysView::TEvGetStorageStatsRequest::TPtr& ev) { auto response = std::make_unique<TEvSysView::TEvGetStorageStatsResponse>(); auto& r = response->Record; - if (StorageStats) { - for (const auto& item : *StorageStats) { - auto *e = r.AddEntries(); - e->CopyFrom(item); - } + for (const auto& item : StorageStats) { + auto *e = r.AddEntries(); + e->CopyFrom(item); } Send(ev->Sender, response.release()); } - void Handle(TEvCalculateStorageStatsRequest::TPtr&) { + void RunStorageStatsCalculator() { if (StorageStatsCalculatorId) { return; } @@ -235,18 +235,13 @@ public: StorageStatsCalculatorId = RunInBatchPool(ctx, actor.release()); - Schedule(TDuration::Minutes(10), new TEvCalculateStorageStatsRequest()); + Schedule(StorageStatsUpdatePeriod, new TEvCalculateStorageStatsRequest()); } void Handle(TEvCalculateStorageStatsResponse::TPtr& ev) { auto& response = *(ev->Get()); - if (!response.StorageStats.empty()) { - StorageStats = response.StorageStats; - UpdateStorageStatsCounters(*StorageStats); - } else { - StorageStats.reset(); - } - + StorageStats = std::move(response.StorageStats); + UpdateStorageStatsCounters(StorageStats); StorageStatsCalculatorId = TActorId(); } |