X-Git-Url: http://xvm.mit.edu/gitweb/invirt/third/libt4.git/blobdiff_plain/4b9798f44ae94deabf87dd534337b55259272950..f0dcb6b97d6d40f67698d1f71ac26970f1776f82:/config.h?ds=sidebyside diff --git a/config.h b/config.h index f3fe216..895de1b 100644 --- a/config.h +++ b/config.h @@ -1,55 +1,48 @@ #ifndef config_h #define config_h -#include -#include +#include "types.h" #include "paxos.h" -#include "lock.h" 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 { private: - acceptor *paxos_acceptor; - proposer *paxos_proposer; unsigned my_view_id; - std::string first; - std::string me; + string first; + string me; config_view_change *vc; - std::vector mems; + proposer_acceptor paxos; + vector mems; mutex cfg_mutex; - std::condition_variable config_cond; - paxos_protocol::status heartbeat(int &r, std::string m, unsigned instance); - std::string value(const std::vector &mems) const; - void members(const std::string &v, std::vector &m) const; - void get_view_wo(unsigned instance, std::vector &m); - bool remove(const std::string &); - void reconstruct(); + cond config_cond; + paxos_protocol::status heartbeat(int & r, string m, unsigned instance); + 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); 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 std::string &m); + heartbeat_t doheartbeat(const string & m, lock & cfg_mutex_lock); public: - config(const std::string &_first, - const std::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 std::string &myaddr() const { return me; }; - std::string dump() { return paxos_acceptor->dump(); }; - void get_view(unsigned instance, std::vector &m); - void restore(const std::string &s); - bool add(const std::string &, unsigned view_id); - bool ismember(const std::string &m, unsigned view_id); - void heartbeater(void); - void paxos_commit(unsigned instance, const std::string &v); - rpcs *get_rpcs() { return paxos_acceptor->get_rpcs(); } - void breakpoint(int b) { paxos_proposer->breakpoint(b); } + const string & myaddr() const { return me; } + string dump() { return paxos.dump(); } + void get_view(unsigned instance, vector & m); + void restore(const string & s); + bool add(const string &, unsigned view_id); + 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