pgmon()->check_sub(s->sub_map["osd_pg_creates"]);
}
} else if (p->first == "monmap") {
- check_sub(s->sub_map["monmap"]);
+ monmon()->check_sub(s->sub_map[p->first]);
} else if (logmon()->sub_name_to_id(p->first) >= 0) {
logmon()->check_sub(s->sub_map[p->first]);
} else if (p->first == "mgrmap" || p->first == "mgrdigest") {
return false;
}
-void Monitor::check_subs()
-{
- string type = "monmap";
- if (session_map.subs.count(type) == 0)
- return;
- xlist<Subscription*>::iterator p = session_map.subs[type]->begin();
- while (!p.end()) {
- Subscription *sub = *p;
- ++p;
- check_sub(sub);
- }
-}
-
-void Monitor::check_sub(Subscription *sub)
-{
- dout(10) << "check_sub monmap next " << sub->next << " have " << monmap->get_epoch() << dendl;
- if (sub->next <= monmap->get_epoch()) {
- send_latest_monmap(sub->session->con.get());
- if (sub->onetime)
- session_map.remove_sub(sub);
- else
- sub->next = monmap->get_epoch() + 1;
- }
-}
-
-
// -----
void Monitor::send_latest_monmap(Connection *con)
MonSessionMap session_map;
AdminSocketHook *admin_hook;
- void check_subs();
- void check_sub(Subscription *sub);
-
void send_latest_monmap(Connection *con);
// messages
t->erase("mkfs", "monmap");
mon->store->apply_transaction(t);
}
+
+ check_subs();
}
void MonmapMonitor::create_pending()
}
return 0;
}
+
+void MonmapMonitor::check_subs()
+{
+ const string type = "monmap";
+ auto subs = mon->session_map.subs.find(type);
+ if (subs == mon->session_map.subs.end())
+ return;
+ for (auto sub : *subs->second) {
+ check_sub(sub);
+ }
+}
+
+void MonmapMonitor::check_sub(Subscription *sub)
+{
+ const auto epoch = mon->monmap->get_epoch();
+ dout(10) << __func__
+ << " monmap next " << sub->next
+ << " have " << epoch << dendl;
+ if (sub->next <= epoch) {
+ mon->send_latest_monmap(sub->session->con.get());
+ if (sub->onetime)
+ mon->session_map.remove_sub(sub);
+ else
+ sub->next = epoch + 1;
+ }
+}