]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
elector: hoist participating into ElectionLogic
authorGreg Farnum <gfarnum@redhat.com>
Thu, 6 Jun 2019 17:46:39 +0000 (10:46 -0700)
committerGreg Farnum <gfarnum@redhat.com>
Mon, 19 Aug 2019 20:04:59 +0000 (13:04 -0700)
Signed-off-by: Greg Farnum <gfarnum@redhat.com>
src/mon/Elector.cc
src/mon/Elector.h

index 4997d2fedeeabb5d0526460923c592b7502cd14f..6c57fdf11f80c1389a893bae2a844e28e5d0b520 100644 (file)
@@ -114,7 +114,7 @@ void Elector::_bump_epoch()
 
 void Elector::start()
 {
-  if (!participating) {
+  if (!logic.participating) {
     dout(0) << "not starting new election -- not participating" << dendl;
     return;
   }
@@ -536,7 +536,7 @@ void Elector::dispatch(MonOpRequestRef op)
     
   case MSG_MON_ELECTION:
     {
-      if (!participating) {
+      if (!logic.participating) {
         return;
       }
       if (op->get_req()->get_source().num() >= mon->monmap->size()) {
@@ -617,7 +617,5 @@ void Elector::dispatch(MonOpRequestRef op)
 
 void Elector::start_participating()
 {
-  if (!participating) {
-    participating = true;
-  }
+  logic.participating = true;
 }
index 9820576a4f19f0c9a80e9aff01114fdb58dabf46..85dadbfaa843e64dc0b4365ff4956380c6d409a0 100644 (file)
@@ -31,11 +31,12 @@ class ElectionLogic {
 public:
   Elector *elector;
   epoch_t epoch;
+  bool participating;
   bool electing_me;
   set<int> acked_me;
   int leader_acked;
 
-  ElectionLogic(Elector *e) : elector(e), epoch(0),
+  ElectionLogic(Elector *e) : elector(e), epoch(0), participating(true),
                              electing_me(false), leader_acked(-1) {}
   void init();
   void bump_epoch(epoch_t e);
@@ -139,7 +140,7 @@ private:
    *         have to call Elector::start_participating for us to resume
    *         participating in the quorum.
    */
-  bool participating;
+  //  bool participating;
 
   // electing me
   /**
@@ -363,8 +364,7 @@ private:
    */
   explicit Elector(Monitor *m) : logic(this),
                                 elector(this),
-                                mon(m),
-                                participating(true) {}
+                                mon(m) {}
 
   /**
    * Initiate the Elector class.
@@ -426,7 +426,7 @@ private:
    *
    * @post @p participating is false
    */
-  void stop_participating() { participating = false; }
+  void stop_participating() { logic.participating = false; }
   /**
    * Start participating in Elections.
    *