mon: PaxosService: is_readable/writeable() depending on is_active()

Instead of depending on individual conditions.

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
This commit is contained in:
Joao Eduardo Luis 2013-04-19 12:56:51 +01:00
parent b29a5b151f
commit 98e23980f4

View File

@ -485,7 +485,7 @@ public:
bool is_readable(version_t ver = 0) {
if ((ver > get_last_committed())
|| ((!mon->is_peon() && !mon->is_leader()))
|| (is_proposing() || paxos->is_recovering() || paxos->is_locked())
|| !is_active()
|| (get_last_committed() <= 0)
|| ((mon->get_quorum().size() != 1) && !paxos->is_lease_valid())) {
return false;
@ -507,10 +507,9 @@ public:
* @returns true if writeable; false otherwise
*/
bool is_writeable() {
return (!is_proposing() && mon->is_leader()
&& !paxos->is_locked()
&& paxos->is_lease_valid() && !paxos->is_bootstrapping()
&& !paxos->is_recovering());
return (is_active()
&& mon->is_leader()
&& paxos->is_lease_valid());
}
/**