*
* @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
/**
* 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
*
* @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.
*
* @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() {}
};
* 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),
*
* @returns Our current epoch number
*/
- epoch_t get_epoch() { return epoch; }
-
+ epoch_t get_epoch() const { return epoch; }
private:
/**
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");
}
ceph_assert(r >= 0);
}
-bool Elector::is_current_member(int rank)
+bool Elector::is_current_member(int rank) const
{
return mon->quorum.count(rank);
}
mon->start_election();
}
-int Elector::get_my_rank()
+int Elector::get_my_rank() const
{
return mon->rank;
}
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();
}
}
}
-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();
/* 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() */
/* 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.
* 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;
/*
* @}
*/