]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: PaxosService: add request_proposal() to perform cross-proposals
authorJoao Eduardo Luis <joao.luis@inktank.com>
Tue, 16 Apr 2013 15:41:57 +0000 (16:41 +0100)
committerJoao Eduardo Luis <joao.luis@inktank.com>
Mon, 22 Apr 2013 22:20:26 +0000 (23:20 +0100)
Instead of allowing services to directly use 'propose_pending()' on
other services, we instead add two new functions:

  - request_proposal() to request 'this' service to propose its
    pending value; and
  - request_proposal(PaxosService *other) so that 'this' service
    can request a proposal to 'other'

These functions should allow us to enforce a greater set of
constraints at time of a cross-proposal, either by making sure a
service will (e.g.) hold-off his own proposals until said proposal
is performed, or even that the other service will enforce a tighter
set of constraints that wouldn't otherwise be enforced by using
'propose_pending()' directly.

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
src/mon/PaxosService.h

index cd112e10fed1f66786d29210d00708cb4de3be78..dc13ad37a5e810bae814335d27149b5b29c35b71 100644 (file)
@@ -274,6 +274,35 @@ public:
    *      the class that is implementing PaxosService
    */
   void propose_pending();
+
+  /**
+   * Let others request us to propose.
+   *
+   * At the moment, this is just a wrapper to propose_pending() with an
+   * extra check for is_writeable(), but it's a good practice to dissociate
+   * requests for proposals from direct usage of propose_pending() for
+   * future use -- we might want to perform additional checks or put a
+   * request on hold, for instance.
+   */
+  void request_proposal() {
+    assert(is_writeable());
+
+    propose_pending();
+  }
+  /**
+   * Request service @p other to perform a proposal.
+   *
+   * We could simply use the function above, requesting @p other directly,
+   * but we might eventually want to do something to the request -- say,
+   * set a flag stating we're waiting on a cross-proposal to be finished.
+   */
+  void request_proposal(PaxosService *other) {
+    assert(other != NULL);
+    assert(other->is_writeable());
+
+    other->request_proposal();
+  }
+
   /**
    * Dispatch a message by passing it to several different functions that are
    * either implemented directly by this service, or that should be implemented