// i am one state machine.
/**
- * This libary is based on the Paxos algorithm, but varies in a few key ways:
+ * This library is based on the Paxos algorithm, but varies in a few key ways:
* 1- Only a single new value is generated at a time, simplifying the recovery logic.
* 2- Nodes track "committed" values, and share them generously (and trustingly)
* 3- A 'leasing' mechanism is built-in, allowing nodes to determine when it is
* not on the active state, or if the lease has expired.
*/
list<Context*> waiting_for_writeable;
- /**
- * List of callbacks waiting for a commit to finish.
- *
- * @remarks This may be used to a) wait for an on-going commit to finish
- * before we proceed with, say, a new proposal; or b) wait for the
- * next commit to be finished so we are sure that our value was
- * fully committed.
- */
- list<Context*> waiting_for_commit;
/**
* Pending proposal transaction
static void decode_append_transaction(MonitorDBStore::TransactionRef t,
bufferlist& bl) {
auto vt(std::make_shared<MonitorDBStore::Transaction>());
- bufferlist::iterator it = bl.begin();
+ auto it = bl.cbegin();
vt->decode(it);
t->append(vt);
}
*/
bool should_trim() {
int available_versions = get_version() - get_first_committed();
- int maximum_versions = g_conf->paxos_min + g_conf->paxos_trim_min;
+ int maximum_versions = g_conf()->paxos_min + g_conf()->paxos_trim_min;
if (trimming || (available_versions <= maximum_versions))
return false;
return plugged;
}
void plug() {
- assert(plugged == false);
+ ceph_assert(plugged == false);
plugged = true;
}
void unplug() {
- assert(plugged == true);
+ ceph_assert(plugged == true);
plugged = false;
}
* @param onreadable A callback
*/
void wait_for_readable(MonOpRequestRef op, Context *onreadable) {
- assert(!is_readable());
+ ceph_assert(!is_readable());
if (op)
op->mark_event("paxos:wait_for_readable");
waiting_for_readable.push_back(onreadable);
* @param c A callback
*/
void wait_for_writeable(MonOpRequestRef op, Context *c) {
- assert(!is_writeable());
+ ceph_assert(!is_writeable());
if (op)
op->mark_event("paxos:wait_for_writeable");
waiting_for_writeable.push_back(c);
* something) that will be deferred (e.g., until the current round finishes).
*/
bool trigger_propose();
-
- /**
- * Add oncommit to the back of the list of callbacks waiting for us to
- * finish committing.
- *
- * @param oncommit A callback
- */
- void wait_for_commit(Context *oncommit) {
- waiting_for_commit.push_back(oncommit);
- }
- /**
- * Add oncommit to the front of the list of callbacks waiting for us to
- * finish committing.
- *
- * @param oncommit A callback
- */
- void wait_for_commit_front(Context *oncommit) {
- waiting_for_commit.push_front(oncommit);
- }
/**
* @}
*/
<< " queued " << (ceph_clock_now() - p.proposal_time)
<< " tx dump:\n";
auto t(std::make_shared<MonitorDBStore::Transaction>());
- bufferlist::iterator p_it = p.bl.begin();
+ auto p_it = p.bl.cbegin();
t->decode(p_it);
JSONFormatter f(true);
t->dump(&f);