X-Git-Url: http://xvm.mit.edu/gitweb/invirt/third/libt4.git/blobdiff_plain/02967a43024ce81912cd1ec96a800397457f8066:/paxos.h..ab9eee5d7f1fbe7a3fe6229d4a78136efb14371b:/include/paxos.h diff --git a/paxos.h b/include/paxos.h similarity index 69% rename from paxos.h rename to include/paxos.h index 20e249c..9b54c05 100644 --- a/paxos.h +++ b/include/paxos.h @@ -1,10 +1,10 @@ #ifndef paxos_h #define paxos_h -#include "types.h" -#include "rpc/rpc.h" -#include "paxos_protocol.h" -#include "log.h" +#include "include/types.h" +#include "include/rpc/rpc.h" +#include "include/paxos_protocol.h" +#include "include/log.h" using prepareres = paxos_protocol::prepareres; using node_t = paxos_protocol::node_t; @@ -43,8 +43,7 @@ class proposer_acceptor { unsigned instance_h = 0; // number of the highest instance we have decided std::map values; // vals of each instance - friend class log; - class log l = {this, me}; + class log l = {me}; void commit(unsigned instance, const value_t & v, lock & acceptor_mutex_lock); @@ -59,12 +58,39 @@ class proposer_acceptor { void breakpoint1(); void breakpoint2(); + // Log a committed paxos instance + struct log_instance { + unsigned number; + string value; + MEMBERS(number, value) + LABEL("done") + }; + + // Log the highest proposal number that the local paxos acceptor has + // ever seen; called from paxos when responding to preparereq with + // accept + struct log_proposal { + prop_t promise; + MEMBERS(promise) + LABEL("propseen") + }; + + // Log the highest proposal (proposal number and value) that the local + // paxos acceptor accept has ever accepted; called from paxos when + // responding to acceptreq with true + struct log_accept { + prop_t number; + string value; + MEMBERS(number, value) + LABEL("accepted") + }; + public: proposer_acceptor(paxos_change *delegate, bool _first, const node_t & _me, const value_t & _value); unsigned instance() { return instance_h; } const value_t & value(unsigned instance) { return values[instance]; } - string dump() { return l.dump(); } - void restore(const string & s) { l.restore(s); l.logread(); } + string dump() { return l.read(); } + void restore(const string & s) { l.write(s); l.replay(); } rpcs *get_rpcs() { return &pxs; } bool run(unsigned instance, const nodes_t & cnodes, const value_t & v);