So many changes. Broken.
[invirt/third/libt4.git] / include / paxos.h
similarity index 69%
rename from paxos.h
rename to include/paxos.h
index 20e249c..9b54c05 100644 (file)
--- a/paxos.h
@@ -1,10 +1,10 @@
 #ifndef paxos_h
 #define paxos_h
 
 #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;
 
 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<unsigned,value_t> values;   // vals of each instance
 
         unsigned instance_h = 0;    // number of the highest instance we have decided
         std::map<unsigned,value_t> 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);
 
 
         void commit(unsigned instance, const value_t & v, lock & acceptor_mutex_lock);
 
@@ -59,12 +58,39 @@ class proposer_acceptor {
         void breakpoint1();
         void breakpoint2();
 
         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]; }
     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);
         rpcs *get_rpcs() { return &pxs; }
 
         bool run(unsigned instance, const nodes_t & cnodes, const value_t & v);