]> git-server-git.apps.pok.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>
Tue, 24 Oct 2017 08:06:26 +0000 (16:06 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/mgr/MgrClient.cc
src/mgr/MgrClient.h

index c72470d9bca5a93644bcc2d536853bf8ae9cd4f0..25f365da361ef7022e188f6582c0a4760e5f95f4 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());
@@ -314,13 +324,6 @@ void MgrClient::send_report()
   }
 
   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()
@@ -352,7 +355,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 08ff24c23849428219570c0446a88813f927b8a2..be7a0945fbe583c357160fd0aa35986f223ab239 100644 (file)
@@ -100,9 +100,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);
@@ -119,7 +117,10 @@ public:
     const std::map<std::string,std::string>& metadata);
   int service_daemon_update_status(
     const std::map<std::string,std::string>& status);
+
+private:
+  void send_stats();
+  void send_report();
 };
 
 #endif
-