return true;
}
-void PaxosService::_commit()
-{
- dout(7) << "_commit" << dendl;
- update_from_paxos(); // notify service of new paxos state
-
- if (mon->is_leader() && paxos->is_active()) {
- dout(7) << "_commit creating new pending" << dendl;
- if (!have_pending) {
- create_pending();
- have_pending = true;
- }
- }
-}
-
-
void PaxosService::propose_pending()
{
dout(10) << "propose_pending" << dendl;
have_pending = false;
// apply to paxos
- paxos->wait_for_commit_front(new C_Commit(this));
+ paxos->wait_for_commit_front(new C_Active(this));
paxos->propose_new_value(bl);
}
}
}
+ // NOTE: it's possible that this will get called twice if we commit
+ // an old paxos value. Implementations should be mindful of that.
if (paxos->is_active())
on_active();
}
svc->_active();
}
};
- class C_Commit : public Context {
- PaxosService *svc;
- public:
- C_Commit(PaxosService *s) : svc(s) {}
- void finish(int r) {
- if (r >= 0)
- svc->_commit();
- }
- };
- friend class C_Update;
class C_Propose : public Context {
PaxosService *ps;
private:
void _active();
- void _commit();
public:
// i implement and you use
* This is called when the Paxos state goes to active.
* It's a courtesy method if you have things you want/need
* to do at that time.
+ *
+ * Note that is may get called twice in certain recovery cases.
*/
virtual void on_active() { }