X-Git-Url: http://xvm.mit.edu/gitweb/invirt/third/libt4.git/blobdiff_plain/4b9798f44ae94deabf87dd534337b55259272950..5bb7eb131773abd9e642f83629528b4c4e706b2e:/config.h diff --git a/config.h b/config.h index f3fe216..73940a0 100644 --- a/config.h +++ b/config.h @@ -1,55 +1,50 @@ #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); + 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); 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); + 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(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); } + void paxos_commit(unsigned instance, const string &v); + rpcs *get_rpcs() { return paxos.get_rpcs(); } + void breakpoint(int b) { paxos.breakpoint(b); } }; #endif