-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathconfiguration.h
86 lines (71 loc) · 2.4 KB
/
configuration.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
* ===============================================================
* Description: Weaver cluster configuration.
*
* Created: 2014-02-10 14:04:37
*
* Author: Robert Escriva, [email protected]
* Ayush Dubey, [email protected]
*
* Copyright (C) 2013, Cornell University, see the LICENSE file
* for licensing agreement
* ===============================================================
*/
// Most of the following code has been 'borrowed' from
// Robert Escriva's HyperDex coordinator.
// see https://github.com/rescrv/HyperDex for the original code.
#ifndef weaver_common_configuration_h_
#define weaver_common_configuration_h_
// STL
#include <vector>
// po6
#include <po6/net/location.h>
// e
#include <e/array_ptr.h>
#include <e/slice.h>
// Weaver
#include "common/ids.h"
#include "common/server.h"
class configuration
{
public:
configuration();
configuration(const configuration& other);
~configuration() throw ();
// configuration metadata
public:
uint64_t cluster() const;
uint64_t version() const;
// membership metadata
public:
void get_all_addresses(std::vector<std::pair<server_id, po6::net::location> >* addrs) const;
bool exists(const server_id& id) const;
po6::net::location get_address(const server_id& id) const;
server::state_t get_state(const server_id& id) const;
uint64_t get_weaver_id(const server_id &id) const;
uint64_t get_virtual_id(const server_id &id) const;
server::type_t get_type(const server_id &id) const;
std::vector<server> get_servers() const;
public:
std::string dump() const;
public:
configuration& operator = (const configuration& rhs);
std::vector<server> delta(const configuration &other);
private:
void refill_cache();
friend size_t pack_size(const configuration&);
friend e::packer operator << (e::packer, const configuration& s);
friend e::unpacker operator >> (e::unpacker, configuration& s);
private:
uint64_t m_cluster;
uint64_t m_version;
uint64_t m_flags;
std::vector<server> m_servers;
};
e::packer
operator << (e::packer, const configuration& c);
e::unpacker
operator >> (e::unpacker, configuration& c);
size_t
pack_size(const configuration&);
#endif // weaver_common_configuration_h_