]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/MgrClient: extract MMgrReport sending code into a separated method
authorKefu Chai <kchai@redhat.com>
Mon, 23 Oct 2017 03:46:31 +0000 (11:46 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 29 Aug 2018 02:32:05 +0000 (10:32 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit 5faf1787573bb4896a67889471b3c033dbeacf04)

Conflicts:
src/mgr/MgrClient.h: trivial resolution

src/mgr/MgrClient.cc
src/mgr/MgrClient.h

index 0faf3ec0e2bd8c40f91d05f48ea0f029730b62ca..c06d94039bf39cf43c327a2aebf4ef4980d9ede2 100644 (file)
@@ -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();
index d1d6061871bb12f617d8915ccb681fc4468bb7d9..a3afe701ebe2c25797096515ad7d9e927c6aff1c 100644 (file)
@@ -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<MPGStats*()> cb_)
   {
     Mutex::Locker l(lock);
@@ -121,7 +119,10 @@ public:
   int service_daemon_update_status(
     const std::map<std::string,std::string>& status);
   void update_osd_health(std::vector<OSDHealthMetric>&& metrics);
+
+private:
+  void send_stats();
+  void send_report();
 };
 
 #endif
-