From: Kefu Chai Date: Mon, 23 Oct 2017 03:46:31 +0000 (+0800) Subject: mgr/MgrClient: extract MMgrReport sending code into a separated method X-Git-Tag: v12.2.9~112^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0524ddd25990ce8312b05e722024bf3f34db2e11;p=ceph.git 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 --- diff --git a/src/mgr/MgrClient.cc b/src/mgr/MgrClient.cc index 0faf3ec0e2b..c06d94039bf 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 d1d6061871b..a3afe701ebe 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 -