]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: send updated monmap to its subscribers 11457/head
authorKefu Chai <kchai@redhat.com>
Thu, 13 Oct 2016 05:19:27 +0000 (13:19 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 17 Nov 2016 07:43:43 +0000 (15:43 +0800)
prior to this change, we sends monmap when serving the subscription
requests, but the updates are not sent to the subscribers anymore.
so we need to send latest monmap to subscribes and update the
subscription status accordingly when the monmap is updated.

http://tracker.ceph.com/issues/17558
Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit c2b348b12c47ba505f72228ae0ea9b1a1b674719)
Conflicts:
src/mon/Monitor.cc: resolve conflicts
src/mon/MonmapMonitor.cc: remove C++11-ism

src/mon/Monitor.cc
src/mon/Monitor.h
src/mon/MonmapMonitor.cc
src/mon/MonmapMonitor.h

index d499f0c298c67c9202cdda757079c9ee6ecfbbba..c5c5441db988adda25950e8afe4ede0316c375be 100644 (file)
@@ -4136,7 +4136,7 @@ void Monitor::handle_subscribe(MMonSubscribe *m)
        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]);
     }
@@ -4227,32 +4227,6 @@ bool Monitor::ms_handle_reset(Connection *con)
   return true;
 }
 
-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)
index 89af554dc52a657fa6153b62eff96920571be83b..01df5d770062ee17b3fa31932c0f4fe6df852605 100644 (file)
@@ -651,9 +651,6 @@ public:
   MonSessionMap session_map;
   AdminSocketHook *admin_hook;
 
-  void check_subs();
-  void check_sub(Subscription *sub);
-
   void send_latest_monmap(Connection *con);
 
   // messages
index c6b21cb47fc7c7d56bee38252d3b78eee5aa03fa..f9a370cea89e9cef49da609cf32af4841bb354eb 100644 (file)
@@ -76,6 +76,8 @@ void MonmapMonitor::update_from_paxos(bool *need_bootstrap)
     t->erase("mkfs", "monmap");
     mon->store->apply_transaction(t);
   }
+
+  check_subs();
 }
 
 void MonmapMonitor::create_pending()
@@ -502,3 +504,32 @@ int MonmapMonitor::get_monmap(MonMap &m)
   m.decode(monmap_bl);
   return 0;
 }
+
+void MonmapMonitor::check_subs()
+{
+  dout(10) << __func__ << dendl;
+  const string type = "monmap";
+  if (mon->session_map.subs.count(type) == 0)
+    return;
+  xlist<Subscription*>::iterator p = mon->session_map.subs[type]->begin();
+  while (!p.end()) {
+    Subscription *sub = *p;
+    ++p;
+    check_sub(sub);
+  }
+}
+
+void MonmapMonitor::check_sub(Subscription *sub)
+{
+  const epoch_t 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;
+  }
+}
index 22b51ad64558e215eb28328fcec5988803bf3407..6f1707806b026bb36b6eb1a50d4959cae000901a 100644 (file)
@@ -81,7 +81,12 @@ class MonmapMonitor : public PaxosService {
 
   void tick();
 
- private:
+  void check_sub(Subscription *sub);
+
+private:
+  void check_subs();
+
+private:
   bufferlist monmap_bl;
 };