summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoao Eduardo Luis <joao.luis@inktank.com>2013-04-16 16:41:57 +0100
committerJoao Eduardo Luis <joao.luis@inktank.com>2013-04-22 15:14:28 +0100
commit86173825ec865a491a0ffdbacce1bc298e453529 (patch)
tree61cdab37cb5fb4232a166fd0026b63485a475dc3
parentcfe1ed2ce81d86371fa1278c1fd4f14a208d35bb (diff)
downloadceph-86173825ec865a491a0ffdbacce1bc298e453529.tar.gz
mon: PaxosService: add request_proposal() to perform cross-proposals
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>
-rw-r--r--src/mon/PaxosService.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/mon/PaxosService.h b/src/mon/PaxosService.h
index cd112e10fed..dc13ad37a5e 100644
--- a/src/mon/PaxosService.h
+++ b/src/mon/PaxosService.h
@@ -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