]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
elector: const-ify a bunch of functions
authorGreg Farnum <gfarnum@redhat.com>
Fri, 16 Aug 2019 01:44:24 +0000 (18:44 -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/ElectionLogic.h
src/mon/Elector.cc
src/mon/Elector.h

index f146d055dd86fb63e4bbbaae75105ad2a55825e9..86bb8d391d51dbf4cbc221dbe44ccd3b15c222a4 100644 (file)
@@ -34,7 +34,7 @@ public:
    *
    * @returns The latest epoch passed to persist_epoch()
    */
-  virtual epoch_t read_persisted_epoch() = 0;
+  virtual epoch_t read_persisted_epoch() const = 0;
   /**
    * Validate that the persistent store is working by committing
    * to it. (There is no interface for retrieving the value; this
@@ -58,7 +58,7 @@ public:
   /**
    * Retrieve this Paxos instance's rank.
    */
-  virtual int get_my_rank() = 0;
+  virtual int get_my_rank() const = 0;
   /**
    * Send a PROPOSE message to all our peers. This happens when
    * we have started a new election (which may mean attempting to
@@ -78,12 +78,12 @@ public:
    *
    * @returns true if we have participated, false otherwise
    */
-  virtual bool ever_participated() = 0;
+  virtual bool ever_participated() const = 0;
   /**
    * Ask the ElectionOwner for the size of the Paxos set. This includes
    * those monitors which may not be in the current quorum!
    */
-  virtual unsigned paxos_size() = 0;
+  virtual unsigned paxos_size() const = 0;
   /**
    * Tell the ElectionOwner we have started a new election.
    *
@@ -107,14 +107,14 @@ public:
    * @param quorum The ranks of our peers which deferred to us and
    *        must be told of our victory
    */
-  virtual void message_victory(const set<int>& quorum) = 0;
+  virtual void message_victory(const std::set<int>& quorum) = 0;
   /**
    * Query the ElectionOwner about if a given rank is in the
    * currently active quorum.
    * @param rank the Paxos rank whose status we are checking
    * @returns true if the rank is in our current quorum, false otherwise.
    */
-  virtual bool is_current_member(int rank) = 0;
+  virtual bool is_current_member(int rank) const = 0;
   virtual ~ElectionOwner() {}
 };
 
@@ -165,7 +165,7 @@ public:
    * If we are acked by ElectionOwner::paxos_size() peers, we will declare
    * victory.
    */
-  set<int> acked_me;
+  std::set<int> acked_me;
 
   ElectionLogic(ElectionOwner *e, CephContext *c) : elector(e), cct(c),
                                                    leader_acked(-1),
@@ -280,8 +280,7 @@ public:
    *
    * @returns Our current epoch number
    */
-  epoch_t get_epoch() { return epoch; }
-
+  epoch_t get_epoch() const { return epoch; }
   
 private:
   /**
index 7268197c60503ac1c477f60dda6bd8c7a3559596..754e404995527648e9b190a71501eab1d8d4536f 100644 (file)
@@ -42,7 +42,7 @@ void Elector::persist_epoch(epoch_t e)
   mon->store->apply_transaction(t);
 }
 
-epoch_t Elector::read_persisted_epoch()
+epoch_t Elector::read_persisted_epoch() const
 {
   return mon->store->get(Monitor::MONITOR_NAME, "election_epoch");
 }
@@ -55,7 +55,7 @@ void Elector::validate_store()
   ceph_assert(r >= 0);
 }
 
-bool Elector::is_current_member(int rank)
+bool Elector::is_current_member(int rank) const
 {
   return mon->quorum.count(rank);
 }
@@ -65,7 +65,7 @@ void Elector::trigger_new_election()
   mon->start_election();
 }
 
-int Elector::get_my_rank()
+int Elector::get_my_rank() const
 {
   return mon->rank;
 }
@@ -75,12 +75,12 @@ void Elector::reset_election()
   mon->bootstrap();
 }
 
-bool Elector::ever_participated()
+bool Elector::ever_participated() const
 {
   return mon->has_ever_joined;
 }
 
-unsigned Elector::paxos_size()
+unsigned Elector::paxos_size() const
 {
   return (unsigned)mon->monmap->size();
 }
@@ -165,7 +165,7 @@ void Elector::cancel_timer()
   }
 }
 
-void Elector::message_victory(const set<int>& quorum)
+void Elector::message_victory(const std::set<int>& quorum)
 {
   uint64_t cluster_features = CEPH_FEATURES_ALL;
   mon_feature_t mon_features = ceph::features::mon::get_supported();
index b2762dd3bfb10d8170fc4d64da85f76d5c821db7..74294ba2a9644b1c9686fa03027144882d45f143 100644 (file)
@@ -183,7 +183,7 @@ class Elector : public ElectionOwner {
   /* Commit the given epoch to our MonStore */
   void persist_epoch(epoch_t e);
   /* Read the epoch out of our MonStore */
-  epoch_t read_persisted_epoch();
+  epoch_t read_persisted_epoch() const;
   /* Write a nonsense key "election_writeable_test" to our MonStore */
   void validate_store();
   /* Reset my tracking. Currently, just call Monitor::join_election() */
@@ -191,15 +191,15 @@ class Elector : public ElectionOwner {
   /* Call a new election: Invoke Monitor::start_election() */
   void trigger_new_election();
   /* Retrieve rank from the Monitor */
-  int get_my_rank();
+  int get_my_rank() const;
   /* Send MMonElection OP_PROPOSE to every monitor in the map. */
   void propose_to_peers(epoch_t e);
   /* bootstrap() the Monitor */
   void reset_election();
   /* Retrieve the Monitor::has_ever_joined member */
-  bool ever_participated();
+  bool ever_participated() const;
   /* Retrieve monmap->size() */
-  unsigned paxos_size();
+  unsigned paxos_size() const;
   /**
    * Reset the expire_event timer so we can limit the amount of time we 
    * will be electing. Clean up our peer_info.
@@ -222,9 +222,9 @@ class Elector : public ElectionOwner {
    * Our ElectionLogic told us we won an election! Identify the quorum
    * features, tell our new peons we've won, and invoke Monitor::win_election().
    */
-  void message_victory(const set<int>& quorum);
+  void message_victory(const std::set<int>& quorum);
   /* Check if rank is in mon->quorum */
-  bool is_current_member(int rank);
+  bool is_current_member(int rank) const;
   /*
    * @}
    */