mirror of
https://github.com/ceph/ceph
synced 2025-02-24 19:47:44 +00:00
crimson/{mgr,osd}: add WithStats::update_stats()
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>
This commit is contained in:
parent
99067b8dc6
commit
d5e1d104ff
@ -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();
|
||||
|
@ -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() {}
|
||||
};
|
||||
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user