WithStats& with_stats)
: msgr{msgr},
with_stats{with_stats},
- report_timer{[this] {report();}}
+ tick_timer{[this] {tick();}}
{}
seastar::future<> Client::start()
seastar::future<> Client::ms_handle_reset(crimson::net::ConnectionRef c)
{
if (conn == c) {
- return reconnect();
- } else {
- return seastar::now();
+ conn = nullptr;
}
+ return seastar::now();
}
seastar::future<> Client::reconnect()
Ref<MMgrConfigure> m)
{
logger().info("{} {}", __func__, *m);
- report_period = std::chrono::seconds{m->stats_period};
- if (report_period.count() && !report_timer.armed() ) {
- report();
+ tick_period = std::chrono::seconds{m->stats_period};
+ if (tick_period.count() && !tick_timer.armed() ) {
+ tick();
}
return seastar::now();
}
-void Client::report()
+void Client::tick()
{
- (void) seastar::with_gate(gate, [this] {
- auto pg_stats = with_stats.get_stats();
- return conn->send(std::move(pg_stats)).finally([this] {
- if (report_period.count()) {
- report_timer.arm(report_period);
- }
- });
+ (void) seastar::with_gate(gate, [=] {
+ if (conn) {
+ auto pg_stats = with_stats.get_stats();
+ return conn->send(std::move(pg_stats)).finally([this] {
+ if (tick_period.count()) {
+ tick_timer.arm(tick_period);
+ }
+ });
+ } else {
+ return reconnect().finally([this] {
+ if (tick_period.count()) {
+ tick_timer.arm(tick_period);
+ }
+ });;
+ }
});
}
seastar::future<> handle_mgr_conf(crimson::net::Connection* conn,
Ref<MMgrConfigure> m);
seastar::future<> reconnect();
- void report();
+ void tick();
private:
MgrMap mgrmap;
crimson::net::Messenger& msgr;
WithStats& with_stats;
crimson::net::ConnectionRef conn;
- std::chrono::seconds report_period{0};
- seastar::timer<seastar::lowres_clock> report_timer;
+ std::chrono::seconds tick_period{0};
+ seastar::timer<seastar::lowres_clock> tick_timer;
seastar::gate gate;
};