X-Git-Url: http://xvm.mit.edu/gitweb/invirt/third/libt4.git/blobdiff_plain/2546a41ad36fdc9ef6471cb35a1d56930ae1b527..c06ef44e7af1571710fd31dd0ab068dd77b1eb2d:/config.h diff --git a/config.h b/config.h index 074cbe9..d2b33ba 100644 --- a/config.h +++ b/config.h @@ -1,28 +1,13 @@ #ifndef config_h #define config_h -#include -#include +#include "types.h" #include "paxos.h" -#include "lock.h" - -using std::chrono::steady_clock; -using std::chrono::seconds; -using std::string; -using std::vector; -using std::thread; -using std::ostringstream; -using std::istringstream; -using std::ostream_iterator; -using std::istream_iterator; -using std::copy; -using std::min; -using std::min_element; class config_view_change { public: virtual void commit_change(unsigned view_id) = 0; - virtual ~config_view_change() {} + virtual ~config_view_change(); }; class config : public paxos_change { @@ -31,37 +16,33 @@ class config : public paxos_change { string first; string me; config_view_change *vc; - acceptor paxos_acceptor; - proposer paxos_proposer; - vector mems; - mutex cfg_mutex; + proposer_acceptor paxos; + std::vector mems; + std::mutex cfg_mutex; cond config_cond; - paxos_protocol::status heartbeat(int &r, string m, unsigned instance); - string value(const vector &mems) const; - vector members(const string &v) const; - void get_view(unsigned instance, vector &m, lock &cfg_mutex_lock); - bool remove(const string &, lock &cfg_mutex_lock); - void reconstruct(lock &cfg_mutex_lock); + paxos_protocol::status heartbeat(int & r, string m, unsigned instance); + void get_view(unsigned instance, std::vector & m, lock & cfg_mutex_lock); + bool remove(const string &, lock & cfg_mutex_lock); + void reconstruct(lock & cfg_mutex_lock); typedef enum { - OK, // response and same view # - VIEWERR, // response but different view # - FAILURE, // no response + OK, // response and same view # + VIEWERR, // response but different view # + FAILURE, // no response } heartbeat_t; - heartbeat_t doheartbeat(const string &m, lock &cfg_mutex_lock); + heartbeat_t doheartbeat(const string & m, lock & cfg_mutex_lock); public: - config(const string &_first, const string &_me, config_view_change *_vc); + config(const string & _first, const string & _me, config_view_change *_vc); unsigned view_id() { return my_view_id; } - const string &myaddr() const { return me; } - string dump() { return paxos_acceptor.dump(); } - void get_view(unsigned instance, vector &m); - void restore(const string &s); + const string & myaddr() const { return me; } + string dump() { return paxos.dump(); } + void get_view(unsigned instance, std::vector & m); + void restore(const string & s); bool add(const string &, unsigned view_id); - bool ismember(const string &m, unsigned view_id); - void heartbeater(void); - void paxos_commit(unsigned instance, const string &v); - // XXX hack; maybe should have its own port number - rpcs *get_rpcs() { return paxos_acceptor.get_rpcs(); } - void breakpoint(int b) { paxos_proposer.breakpoint(b); } + bool ismember(const string & m, unsigned view_id); + void heartbeater NORETURN (); + void paxos_commit(unsigned instance, const string & v); + rpcs *get_rpcs() { return paxos.get_rpcs(); } + void breakpoint(int b) { paxos.breakpoint(b); } }; #endif