forked from Netflix/dynomite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdyn_gossip.h
76 lines (63 loc) · 2.24 KB
/
dyn_gossip.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
#ifndef DYN_GOSSIP_H_
#define DYN_GOSSIP_H_
#include "dyn_array.h"
#include "dyn_dict.h"
#include "dyn_string.h"
#include "hashkit/dyn_token.h"
#define GOS_NOOPS 1
#define GOS_OK 0
#define GOS_ERROR -1
#define SIMPLE_PROVIDER "simple_provider"
#define FLORIDA_PROVIDER "florida_provider"
#define DNS_PROVIDER "dns_provider"
#define SEED_BUF_SIZE (1024 * 1024) // in bytes
typedef uint8_t (*seeds_provider_t)(struct context *, struct mbuf *);
extern struct gossip_node_pool gn_pool;
// In comparison to conf_server in dyn_conf.h, this structure,
// has sockinfo & valid flag missing
// It has is_local, state, and timestamp extra
// Also in conf_server, pname is name:port:weight,
// whereas here it is just name:port
struct gossip_node {
struct string pname; /* name:port */
struct string name; /* name */
int port; /* port */
// info is missing
struct dyn_token token; /* token for this node */
struct string rack;
struct string dc;
bool is_secure; /* is a secured conn */
bool is_local; /* is this peer the current running node? */
uint8_t state; /* state of a node that this host knows */
uint64_t ts; /* timestamp */
};
struct gossip_rack {
struct string name;
struct string dc;
uint32_t nnodes; /* # total nodes */
uint32_t nlive_nodes; /* # live nodes */
struct array nodes; /* nodes */
dict *dict_token_nodes;
dict *dict_name_nodes;
};
struct gossip_dc {
struct string name; /* datacenter name */
struct array racks; /* list of gossip_rack in a datacenter */
dict *dict_rack;
};
struct gossip_node_pool {
struct string *name; /* pool name (ref in conf_pool) */
uint32_t idx; /* pool index */
struct context *ctx; /* owner context */
seeds_provider_t seeds_provider; /* seeds provider */
struct array datacenters; /* gossip datacenters */
int64_t last_run; /* last time run in usec */
msec_t g_interval; /* gossip interval */
dict *dict_dc;
};
rstatus_t gossip_pool_init(struct context *ctx);
void gossip_pool_deinit(struct context *ctx);
rstatus_t gossip_start(struct server_pool *sp);
rstatus_t gossip_destroy(struct server_pool *sp);
rstatus_t gossip_msg_peer_update(void *msg);
#endif /* DYN_GOSSIP_H_ */