]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
elector: fix privacy and restore dout in Elector
authorGreg Farnum <gfarnum@redhat.com>
Thu, 20 Jun 2019 17:34:59 +0000 (10:34 -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 07702c20cc5e0763d03eaf71b97449e3a88f5005..a8ca4cd1efb82931d5a33eb732b09c3943e82463 100644 (file)
 
 #define dout_subsys ceph_subsys_mon
 #undef dout_prefix
-#define dout_prefix _prefix(_dout, elector)
-static ostream& _prefix(std::ostream *_dout, Elector* elector) {
-  return *_dout << "mon." << elector->mon->name << "@" << elector->mon->rank
-               << "(" << elector->mon->get_state_name()
-               << ").elector(" << elector->get_epoch() << ") ";
+#define dout_prefix _prefix(_dout, mon, get_epoch())
+static ostream& _prefix(std::ostream *_dout, Monitor *mon, epoch_t epoch) {
+  return *_dout << "mon." << mon->name << "@" << mon->rank
+               << "(" << mon->get_state_name()
+               << ").elector(" << epoch << ") ";
 }
 
 Elector::Elector(Monitor *m) : logic(this, m->cct),
index 359ce94e9b6ba1f221b834063ef60eb915cd561f..e25208a4fa038bedd56b71a2014f7e4319949a5e 100644 (file)
@@ -36,7 +36,6 @@ class Elector : public ElectionOwner {
    * @defgroup Elector_h_class Elector
    * @{
    */
-  friend class ElectionLogic;
   ElectionLogic logic;
 
    /**
@@ -63,20 +62,7 @@ class Elector : public ElectionOwner {
   /**
    * The Monitor instance associated with this class.
    */
-  // FIXME!
-public:
   Monitor *mon;
-  void persist_epoch(epoch_t e);
-  epoch_t read_persisted_epoch();
-  void validate_store();
-  void trigger_new_election();
-  int get_my_rank();
-  void propose_to_peers(epoch_t e);
-  void reset_election();
-  bool ever_participated();
-  unsigned paxos_size();
-
-private:
 
   /**
    * Event callback responsible for dealing with an expired election once a
@@ -159,86 +145,6 @@ private:
    * @}
    */
  
-  /**
-   * Update our epoch.
-   *
-   * If we come across a higher epoch, we simply update ours, also making
-   * sure we are no longer being elected (even though we could have been,
-   * we no longer are since we no longer are on that old epoch).
-   *
-   * @pre Our epoch is lower than @p e
-   * @post Our epoch equals @p e
-   *
-   * @param e Epoch to which we will update our epoch
-   */
-  void notify_bump_epoch();
-
-  /**
-   * Start new elections by proposing ourselves as the new Leader.
-   *
-   * Basically, send propose messages to all the monitors in the MonMap and
-   * then reset the expire_event timer so we can limit the amount of time we 
-   * will be going at it.
-   *
-   * @pre   participating is true
-   * @post  epoch is an odd value
-   * @post  electing_me is true
-   * @post  we sent propose messages to all the monitors in the MonMap
-   * @post  we reset the expire_event timer
-   */
-  void _start();
-  /**
-   * Defer the current election to some other monitor.
-   *
-   * This means that we will ack some other monitor and drop out from the run
-   * to become the Leader. We will only defer an election if the monitor we
-   * are deferring to outranks us.
-   *
-   * @pre   @p who outranks us (i.e., who < our rank)
-   * @pre   @p who outranks any other monitor we have deferred to in the past
-   * @post  electing_me is false
-   * @post  leader_acked equals @p who
-   * @post  we sent an ack message to @p who
-   * @post  we reset the expire_event timer
-   *
-   * @param who Some other monitor's numeric identifier. 
-   */
-  void _defer_to(int who);
-  /**
-   * The election has taken too long and has expired.
-   *
-   * This will happen when no one declared victory or started a new election
-   * during the time span allowed by the expire_event timer.
-   *
-   * When the election expires, we will check if we were the ones who won, and
-   * if so we will declare victory. If that is not the case, then we assume
-   * that the one we deferred to didn't declare victory quickly enough (in fact,
-   * as far as we know, we may even be dead); so, just propose ourselves as the
-   * Leader.
-   */
-  //  void expire();
-  /**
-   * Declare Victory.
-   * 
-   * We won. Or at least we believe we won, but for all intentions and purposes
-   * that does not matter. What matters is that we Won.
-   *
-   * That said, we must now bump our epoch to reflect that the election is over
-   * and then we must let everybody in the quorum know we are their brand new
-   * Leader. And we will also cancel our expire_event timer.
-   *
-   * Actually, the quorum will be now defined as the group of monitors that
-   * acked us during the election process.
-   *
-   * @pre   Election is on-going
-   * @pre   electing_me is true
-   * @post  electing_me is false
-   * @post  epoch is bumped up into an even value
-   * @post  Election is not on-going
-   * @post  We have a quorum, composed of the monitors that acked us
-   * @post  We sent a message of type OP_VICTORY to each quorum member.
-   */
-  void message_victory(const set<int>& quorum);
   /**
    * Handle a message from some other node proposing itself to become it
    * the Leader.
@@ -337,6 +243,97 @@ private:
   void handle_nak(MonOpRequestRef op);
   
  public:
+  /**
+   * Update our epoch.
+   *
+   * If we come across a higher epoch, we simply update ours, also making
+   * sure we are no longer being elected (even though we could have been,
+   * we no longer are since we no longer are on that old epoch).
+   *
+   * @pre Our epoch is lower than @p e
+   * @post Our epoch equals @p e
+   *
+   * @param e Epoch to which we will update our epoch
+   */
+  void notify_bump_epoch();
+
+  /**
+   * Start new elections by proposing ourselves as the new Leader.
+   *
+   * Basically, send propose messages to all the monitors in the MonMap and
+   * then reset the expire_event timer so we can limit the amount of time we 
+   * will be going at it.
+   *
+   * @pre   participating is true
+   * @post  epoch is an odd value
+   * @post  electing_me is true
+   * @post  we sent propose messages to all the monitors in the MonMap
+   * @post  we reset the expire_event timer
+   */
+  void _start();
+  /**
+   * Defer the current election to some other monitor.
+   *
+   * This means that we will ack some other monitor and drop out from the run
+   * to become the Leader. We will only defer an election if the monitor we
+   * are deferring to outranks us.
+   *
+   * @pre   @p who outranks us (i.e., who < our rank)
+   * @pre   @p who outranks any other monitor we have deferred to in the past
+   * @post  electing_me is false
+   * @post  leader_acked equals @p who
+   * @post  we sent an ack message to @p who
+   * @post  we reset the expire_event timer
+   *
+   * @param who Some other monitor's numeric identifier. 
+   */
+  void _defer_to(int who);
+  /**
+   * The election has taken too long and has expired.
+   *
+   * This will happen when no one declared victory or started a new election
+   * during the time span allowed by the expire_event timer.
+   *
+   * When the election expires, we will check if we were the ones who won, and
+   * if so we will declare victory. If that is not the case, then we assume
+   * that the one we deferred to didn't declare victory quickly enough (in fact,
+   * as far as we know, we may even be dead); so, just propose ourselves as the
+   * Leader.
+   */
+  //  void expire();
+  /**
+   * Declare Victory.
+   * 
+   * We won. Or at least we believe we won, but for all intentions and purposes
+   * that does not matter. What matters is that we Won.
+   *
+   * That said, we must now bump our epoch to reflect that the election is over
+   * and then we must let everybody in the quorum know we are their brand new
+   * Leader. And we will also cancel our expire_event timer.
+   *
+   * Actually, the quorum will be now defined as the group of monitors that
+   * acked us during the election process.
+   *
+   * @pre   Election is on-going
+   * @pre   electing_me is true
+   * @post  electing_me is false
+   * @post  epoch is bumped up into an even value
+   * @post  Election is not on-going
+   * @post  We have a quorum, composed of the monitors that acked us
+   * @post  We sent a message of type OP_VICTORY to each quorum member.
+   */
+  void message_victory(const set<int>& quorum);
+
+  void persist_epoch(epoch_t e);
+  epoch_t read_persisted_epoch();
+  void validate_store();
+  void trigger_new_election();
+  int get_my_rank();
+  void propose_to_peers(epoch_t e);
+  void reset_election();
+  bool ever_participated();
+  unsigned paxos_size();
+
   Elector *elector;
   bool is_current_member(int rank);