]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/PaxosService: add force_immediate_propose mechanism
authorSage Weil <sage@redhat.com>
Fri, 5 May 2017 16:26:04 +0000 (12:26 -0400)
committerJoao Eduardo Luis <joao@suse.de>
Mon, 5 Jun 2017 14:20:19 +0000 (15:20 +0100)
Add an easy mechanism for a prepare method to force an immediate proposal.
(Otherwise they have to ensure that a future call to should_propose
returns true with delay==0.0, which is a bit more work for them.)

Signed-off-by: Sage Weil <sage@redhat.com>
src/mon/PaxosService.cc
src/mon/PaxosService.h

index c17e9a84d81e4c1f7d92c21a717241db66f30960..621f942149252d7866f91e9f23bfc5fb5d460915 100644 (file)
@@ -93,6 +93,13 @@ bool PaxosService::dispatch(MonOpRequestRef op)
     return true;
   }
 
+  if (need_immediate_propose) {
+    dout(10) << __func__ << " forced immediate propose" << dendl;
+    need_immediate_propose = false;
+    propose_pending();
+    return true;
+  }
+
   double delay = 0.0;
   if (!should_propose(delay)) {
     dout(10) << " not proposing" << dendl;
index 050270586f0d6cb2cabb47e98a241f488d258e47..ca75915841e591702b41a3d80444f52c78a99fa7 100644 (file)
@@ -53,7 +53,9 @@ class PaxosService {
    */
   bool proposing;
 
- protected:
+  bool need_immediate_propose = false;
+
+protected:
   /**
    * Services implementing us used to depend on the Paxos version, back when
    * each service would have a Paxos instance for itself. However, now we only
@@ -356,6 +358,15 @@ public:
    */
   virtual bool should_propose(double &delay);
 
+  /**
+   * force an immediate propose.
+   *
+   * This is meant to be called from prepare_update(op).
+   */
+  void force_immediate_propose() {
+    need_immediate_propose = true;
+  }
+
   /**
    * @defgroup PaxosService_h_courtesy Courtesy functions
    *