From 0524ddd25990ce8312b05e722024bf3f34db2e11 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Mon, 23 Oct 2017 11:46:31 +0800 Subject: [PATCH] mgr/MgrClient: extract MMgrReport sending code into a separated method Signed-off-by: Kefu Chai (cherry picked from commit 5faf1787573bb4896a67889471b3c033dbeacf04) Conflicts: src/mgr/MgrClient.h: trivial resolution --- src/mgr/MgrClient.cc | 19 +++++++++++-------- src/mgr/MgrClient.h | 7 ++++--- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/mgr/MgrClient.cc b/src/mgr/MgrClient.cc index 0faf3ec0e2bd8..c06d94039bf39 100644 --- a/src/mgr/MgrClient.cc +++ b/src/mgr/MgrClient.cc @@ -216,6 +216,16 @@ bool MgrClient::ms_handle_refused(Connection *con) return false; } +void MgrClient::send_stats() +{ + send_report(); + send_pgstats(); + if (stats_period != 0) { + report_callback = new FunctionContext([this](int){send_stats();}); + timer.add_event_after(stats_period, report_callback); + } +} + void MgrClient::send_report() { assert(lock.is_locked_by_me()); @@ -316,13 +326,6 @@ void MgrClient::send_report() report->osd_health_metrics = std::move(osd_health_metrics); session->con->send_message(report); - - if (stats_period != 0) { - report_callback = new FunctionContext([this](int r){send_report();}); - timer.add_event_after(stats_period, report_callback); - } - - send_pgstats(); } void MgrClient::send_pgstats() @@ -354,7 +357,7 @@ bool MgrClient::handle_mgr_configure(MMgrConfigure *m) bool starting = (stats_period == 0) && (m->stats_period != 0); stats_period = m->stats_period; if (starting) { - send_report(); + send_stats(); } m->put(); diff --git a/src/mgr/MgrClient.h b/src/mgr/MgrClient.h index d1d6061871bb1..a3afe701ebe2c 100644 --- a/src/mgr/MgrClient.h +++ b/src/mgr/MgrClient.h @@ -101,9 +101,7 @@ public: bool handle_mgr_configure(MMgrConfigure *m); bool handle_command_reply(MCommandReply *m); - void send_report(); void send_pgstats(); - void set_pgstats_cb(std::function cb_) { Mutex::Locker l(lock); @@ -121,7 +119,10 @@ public: int service_daemon_update_status( const std::map& status); void update_osd_health(std::vector&& metrics); + +private: + void send_stats(); + void send_report(); }; #endif - -- 2.39.5