More cleaning
[invirt/third/libt4.git] / config.cc
index 7bac4a9..d1cd70a 100644 (file)
--- a/config.cc
+++ b/config.cc
@@ -1,10 +1,5 @@
-#include <thread>
-#include <sstream>
 #include "config.h"
-#include "paxos.h"
 #include "handle.h"
-#include "threaded_log.h"
-#include "lang/verify.h"
 
 // The config module maintains views. As a node joins or leaves a
 // view, the next view will be the same as previous view, except with
@@ -40,8 +35,7 @@
 
 config::config(const string &_first, const string &_me, config_view_change *_vc)
     : my_view_id(0), first(_first), me(_me), vc(_vc),
-      paxos_acceptor(this, me == _first, me, me),
-      paxos_proposer(this, &paxos_acceptor, me)
+      paxos(this, me == _first, me, me)
 {
     get_rpcs()->reg(paxos_protocol::heartbeat, &config::heartbeat, this);
     lock cfg_mutex_lock(cfg_mutex);
@@ -51,7 +45,7 @@ config::config(const string &_first, const string &_me, config_view_change *_vc)
 
 void config::restore(const string &s) {
     lock cfg_mutex_lock(cfg_mutex);
-    paxos_acceptor.restore(s);
+    paxos.restore(s);
     reconstruct(cfg_mutex_lock);
 }
 
@@ -61,7 +55,7 @@ void config::get_view(unsigned instance, vector<string> &m) {
 }
 
 void config::get_view(unsigned instance, vector<string> &m, lock &) {
-    string value = paxos_acceptor.value(instance);
+    string value = paxos.value(instance);
     LOG("get_view(" << instance << "): returns " << value);
     m = members(value);
 }
@@ -80,8 +74,8 @@ string config::value(const vector<string> &m) const {
 
 void config::reconstruct(lock &cfg_mutex_lock) {
     VERIFY(cfg_mutex_lock);
-    if (paxos_acceptor.instance() > 0) {
-        my_view_id = paxos_acceptor.instance();
+    my_view_id = paxos.instance();
+    if (my_view_id > 0) {
         get_view(my_view_id, mems, cfg_mutex_lock);
         LOG("config::reconstruct: " << my_view_id << " " << print_members(mems));
     }
@@ -128,7 +122,7 @@ bool config::add(const string &new_m, unsigned vid) {
     vector<string> cmems = mems;
     unsigned nextvid = my_view_id + 1;
     cfg_mutex_lock.unlock();
-    bool r = paxos_proposer.run(nextvid, cmems, value(m));
+    bool r = paxos.run(nextvid, cmems, value(m));
     cfg_mutex_lock.lock();
     LOG("config::add: proposer returned " << (r ? "success" : "failure"));
     return r;
@@ -145,7 +139,7 @@ bool config::remove(const string &m, lock &cfg_mutex_lock) {
     vector<string> cmems = mems;
     unsigned nextvid = my_view_id + 1;
     cfg_mutex_lock.unlock();
-    bool r = paxos_proposer.run(nextvid, cmems, value(n));
+    bool r = paxos.run(nextvid, cmems, value(n));
     cfg_mutex_lock.lock();
     LOG("config::remove: proposer returned " << (r ? "success" : "failure"));
     return r;
@@ -195,7 +189,7 @@ paxos_protocol::status config::heartbeat(int &r, string m, unsigned vid) {
     LOG("heartbeat from " << m << "(" << vid << ") my_view_id " << my_view_id);
     if (vid == my_view_id)
         return paxos_protocol::OK;
-    else if (paxos_proposer.isrunning()) {
+    else if (paxos.isrunning()) {
         VERIFY (vid == my_view_id + 1 || vid + 1 == my_view_id);
         return paxos_protocol::OK;
     }