]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: clean up "joined" flag
authorSage Weil <sage@inktank.com>
Thu, 17 May 2012 18:00:46 +0000 (11:00 -0700)
committerSage Weil <sage@inktank.com>
Fri, 18 May 2012 23:23:55 +0000 (16:23 -0700)
- check flag on init, keep in memory
- set flag only when we are active and have a committed monmap.  i.e., when
  we are active participants in a bootstrapped/created mon cluster.

Signed-off-by: Sage Weil <sage@inktank.com>
src/mon/Monitor.cc
src/mon/Monitor.h
src/mon/MonmapMonitor.cc
src/mon/MonmapMonitor.h

index f0cf460011d9039172ffa000b3d874101e80f42a..b723d2ea56ec1b77ad9fa4fe612b68fe4c177acb 100644 (file)
@@ -93,6 +93,7 @@ Monitor::Monitor(CephContext* cct_, string nm, MonitorStore *s, Messenger *m, Mo
   messenger(m),
   lock("Monitor::lock"),
   timer(cct_, lock),
+  has_ever_joined(false),
   logger(NULL), cluster_logger(NULL), cluster_logger_registered(false),
   monmap(map),
   clog(cct_, messenger, monmap, NULL, LogClient::FLAG_MON),
@@ -278,6 +279,9 @@ int Monitor::init()
     dout(10) << "features " << features << dendl;
   }
 
+  // have we ever joined a quorum?
+  has_ever_joined = store->exists_bl_ss("joined");
+
   // init paxos
   for (int i = 0; i < PAXOS_NUM; ++i) {
     paxos[i]->init();
@@ -420,7 +424,7 @@ void Monitor::bootstrap()
   int newrank = monmap->get_rank(messenger->get_myaddr());
   if (newrank < 0 && rank >= 0) {
     // was i ever part of the quorum?
-    if (store->exists_bl_ss("joined")) {
+    if (has_ever_joined) {
       dout(0) << " removed from monmap, suicide." << dendl;
       exit(0);
     }
@@ -882,9 +886,6 @@ void Monitor::finish_election()
   resend_routed_requests();
   update_logger();
   register_cluster_logger();
-
-  // make note of the fact that i was, once, part of the quorum.
-  store->put_int(1, "joined");
 } 
 
 
index 2cf308f6aab91486b0dc5d5c956bb3ac900cd1fd..f21edb95ad2b0e3b4db2d4d9c9a411f8fa60e235 100644 (file)
@@ -102,6 +102,11 @@ public:
   Mutex lock;
   SafeTimer timer;
   
+  /// true if we have ever joined a quorum.  if false, we are either a
+  /// new cluster, a newly joining monitor, or a just-upgraded
+  /// monitor.
+  bool has_ever_joined;
+
   PerfCounters *logger, *cluster_logger;
   bool cluster_logger_registered;
 
index 2525538b2cfb10d5ed4362298808dcb8a73ac84d..81646b49617e495b47b7610bcc3d1e6296a4f52d 100644 (file)
@@ -105,6 +105,19 @@ void MonmapMonitor::encode_pending(bufferlist& bl)
   pending_map.encode(bl, CEPH_FEATURES_ALL);
 }
 
+void MonmapMonitor::on_active()
+{
+  if (paxos->get_version() >= 1 && !mon->has_ever_joined) {
+    // make note of the fact that i was, once, part of the quorum.
+    dout(10) << "noting that i was, once, part of an active quorum." << dendl;
+    mon->store->put_int(1, "joined");
+    mon->has_ever_joined = true;
+  }
+
+  if (mon->is_leader())
+    mon->clog.info() << "monmap " << *mon->monmap << "\n";
+}
+
 bool MonmapMonitor::preprocess_query(PaxosServiceMessage *m)
 {
   switch (m->get_type()) {
@@ -263,12 +276,6 @@ bool MonmapMonitor::prepare_update(PaxosServiceMessage *m)
   return false;
 }
 
-void MonmapMonitor::on_active() 
-{
-  if (mon->is_leader())
-    mon->clog.info() << "monmap " << *mon->monmap << "\n";
-}
-
 bool MonmapMonitor::prepare_command(MMonCommand *m)
 {
   stringstream ss;
index 7833cbfbac347901d70316d0e9ce154c53149114..e1f02c9510a4ab0d337a7143479dc2dd7e5724ce 100644 (file)
@@ -53,7 +53,6 @@ class MonmapMonitor : public PaxosService {
 
   void on_active();
 
-
   bool preprocess_query(PaxosServiceMessage *m);
   bool prepare_update(PaxosServiceMessage *m);