]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/{mgr,osd}: add WithStats::update_stats()
authorKefu Chai <kchai@redhat.com>
Fri, 3 Jul 2020 07:59:11 +0000 (15:59 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 3 Jul 2020 08:09:38 +0000 (16:09 +0800)
because we need to implement a tell command which forces osd to
send the latest pg stats to mgr, and the command returns the user with
the sequence id of the report, and `mgr::Client::report()` does not
return a future, so we have to update the seq id before sending
the report. the solution is to update the seq id in a separated
method, so in this change:

* add `const` to `WithStats::get_stats()
* add a dedicated method of `WithStats::update_stats()` to update
  the stats to be collected by mgr::Client.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/mgr/client.cc
src/crimson/mgr/client.h
src/crimson/osd/osd.cc
src/crimson/osd/osd.h

index 74403fc4e955d91fa27a33bcb0f8a7eae3bf6325..dd86ac88a0e64b3d5491643a54062c8463e5f4bb 100644 (file)
@@ -142,6 +142,7 @@ seastar::future<> Client::handle_mgr_conf(crimson::net::Connection* conn,
 
 void Client::report()
 {
+  with_stats.update_stats();
   gate.dispatch_in_background(__func__, *this, [this] {
     assert(conn);
     auto pg_stats = with_stats.get_stats();
index 51130b06bc53e273f17b7889440a8db6c8c3b405..919fdeb608036e126740edeb0c01ef1b45baf254 100644 (file)
@@ -24,9 +24,8 @@ namespace crimson::mgr
 // implement WithStats if you want to report stats to mgr periodically
 class WithStats {
 public:
-  // the method is not const, because the class sending stats might need to
-  // update a seq number every time it collects the stats
-  virtual MessageRef get_stats() = 0;
+  virtual void update_stats() = 0;
+  virtual MessageRef get_stats() const = 0;
   virtual ~WithStats() {}
 };
 
index 527da83c705a108b42338d3685c6fbfc6a334998..0744d98d5ea5c9b70c12bb79435ffd5b41b11a5f 100644 (file)
@@ -684,7 +684,14 @@ void OSD::handle_authentication(const EntityName& name,
   // todo
 }
 
-MessageRef OSD::get_stats()
+void OSD::update_stats()
+{
+  osd_stat_seq++;
+  osd_stat.up_from = get_up_epoch();
+  osd_stat.seq = (static_cast<uint64_t>(get_up_epoch()) << 32) | osd_stat_seq;
+}
+
+MessageRef OSD::get_stats() const
 {
   // todo: m-to-n: collect stats using map-reduce
   // MPGStats::had_map_for is not used since PGMonitor was removed
index 18197aa8cd7f3216b2d87f868d0f78f2584358fd..0e8723ab8dd5cdc0b7b3295563903cc68931d831 100644 (file)
@@ -102,7 +102,11 @@ class OSD final : public crimson::net::Dispatcher,
   void ms_handle_remote_reset(crimson::net::ConnectionRef conn) final;
 
   // mgr::WithStats methods
-  MessageRef get_stats() final;
+  // pg statistics including osd ones
+  osd_stat_t osd_stat;
+  uint32_t osd_stat_seq = 0;
+  void update_stats() final;
+  MessageRef get_stats() const final;
 
   // AuthHandler methods
   void handle_authentication(const EntityName& name,