summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSage Weil <sage@newdream.net>2011-11-18 10:35:44 -0800
committerSage Weil <sage.weil@dreamhost.com>2011-11-19 14:30:31 -0800
commit9aabd3982cceb7e8489412b4bfbb4c2387880de2 (patch)
tree10ffe4de99a6a217efff354904bbd7dcd2ca8183
parent10fed791e9e1860423d671eadad375cfd6ccd4e8 (diff)
downloadceph-9aabd3982cceb7e8489412b4bfbb4c2387880de2.tar.gz
paxosservice: consolidate _active and _commit
Use the same callback for when paxos goes active and for when it commits something. The response in both cases is the same. Signed-off-by: Sage Weil <sage@newdream.net>
-rw-r--r--src/mon/PaxosService.cc19
-rw-r--r--src/mon/PaxosService.h13
2 files changed, 5 insertions, 27 deletions
diff --git a/src/mon/PaxosService.cc b/src/mon/PaxosService.cc
index d7133df43fa..bcba8e98afb 100644
--- a/src/mon/PaxosService.cc
+++ b/src/mon/PaxosService.cc
@@ -104,21 +104,6 @@ bool PaxosService::should_propose(double& delay)
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;
@@ -136,7 +121,7 @@ void PaxosService::propose_pending()
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);
}
@@ -193,6 +178,8 @@ void PaxosService::_active()
}
}
+ // 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();
}
diff --git a/src/mon/PaxosService.h b/src/mon/PaxosService.h
index de2b9d39e93..c8dc93bd7cf 100644
--- a/src/mon/PaxosService.h
+++ b/src/mon/PaxosService.h
@@ -45,16 +45,6 @@ protected:
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;
@@ -87,7 +77,6 @@ public:
private:
void _active();
- void _commit();
public:
// i implement and you use
@@ -156,6 +145,8 @@ public:
* 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() { }