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>
void Client::report()
{
+ with_stats.update_stats();
gate.dispatch_in_background(__func__, *this, [this] {
assert(conn);
auto pg_stats = with_stats.get_stats();
// 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() {}
};
// 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
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,