Cosmetic improvements.
[invirt/third/libt4.git] / config.h
1 #ifndef config_h
2 #define config_h
3
4 #include "types.h"
5 #include "paxos.h"
6
7 class config_view_change {
8     public:
9         virtual void commit_change(unsigned view_id) = 0;
10         virtual ~config_view_change() {}
11 };
12
13 class config : public paxos_change {
14     private:
15         unsigned my_view_id;
16         string first;
17         string me;
18         config_view_change *vc;
19         proposer_acceptor paxos;
20         vector<string> mems;
21         mutex cfg_mutex;
22         cond config_cond;
23         paxos_protocol::status heartbeat(int & r, string m, unsigned instance);
24         void get_view(unsigned instance, vector<string> & m, lock & cfg_mutex_lock);
25         bool remove(const string &, lock & cfg_mutex_lock);
26         void reconstruct(lock & cfg_mutex_lock);
27         typedef enum {
28             OK, // response and same view #
29             VIEWERR, // response but different view #
30             FAILURE, // no response
31         } heartbeat_t;
32         heartbeat_t doheartbeat(const string & m, lock & cfg_mutex_lock);
33     public:
34         config(const string & _first, const string & _me, config_view_change *_vc);
35         unsigned view_id() { return my_view_id; }
36         const string & myaddr() const { return me; }
37         string dump() { return paxos.dump(); }
38         void get_view(unsigned instance, vector<string> & m);
39         void restore(const string & s);
40         bool add(const string &, unsigned view_id);
41         bool ismember(const string & m, unsigned view_id);
42         void heartbeater NORETURN ();
43         void paxos_commit(unsigned instance, const string & v);
44         rpcs *get_rpcs() { return paxos.get_rpcs(); }
45         void breakpoint(int b) { paxos.breakpoint(b); }
46 };
47
48 #endif