-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMembershipManager.h
50 lines (38 loc) · 1.3 KB
/
MembershipManager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#ifndef MembershipManager_MembershipManager_h_IsIncluded
#define MembershipManager_MembershipManager_h_IsIncluded
#include<map>
#include<sstream>
#include<fstream>
#include "MembershipManager/IncludeExtLibs.h"
// --------------------------------------------------------
// class MembershipManager
// - keeps updated list of the members in the system.
// --------------------------------------------------------
class MembershipManager : public MembershipManagerInterface, public Thread
{
private:
typedef map<string, HostInformation> MapHostInformation;
typedef map<string, int64> MapAliveCheck;
public:
MembershipManager(bool autorun = false);
~MembershipManager();
virtual void run();
virtual int Login(HostInformation &info);
virtual int Logout(string componentName);
virtual int AliveChecker(string componentName);
virtual MapHostInformation GetMembershipMap();
public:
inline MapHostInformation GetAllHostInformation() const { return mapHostInformation_; }
private:
inline void lock() { mutexUpdate_.lock(); }
inline void unlock() { mutexUpdate_.unlock(); }
private:
void createOrUpdateTimeStamp(string componentName);
private:
MapHostInformation mapHostInformation_;
MapAliveCheck mapAliveCheck_;
WaitCondition waitForChanges_;
Mutex mutexUpdate_;
bool runThread_;
};
#endif