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#ifndef R2CLUSTER_HEARTBEAT_H
28#define R2CLUSTER_HEARTBEAT_H
29
30#define R2HB_REGION_TIMEOUT_MS 2000
31
32#define R2HB_MAX_REGION_NAME_LEN 32
33
34
35#define R2HB_LIVE_THRESHOLD 2
36
37extern unsigned int r2hb_dead_threshold;
38#define R2HB_DEFAULT_DEAD_THRESHOLD 31
39
40#define R2HB_MIN_DEAD_THRESHOLD 2
41#define R2HB_MAX_WRITE_TIMEOUT_MS \
42 (R2HB_REGION_TIMEOUT_MS * (r2hb_dead_threshold - 1))
43
44#define R2HB_CB_MAGIC 0x51d1e4ec
45
46
47enum r2hb_callback_type {
48 R2HB_NODE_DOWN_CB = 0,
49 R2HB_NODE_UP_CB,
50 R2HB_NUM_CB
51};
52
53struct r2nm_node;
54typedef void (r2hb_cb_func)(struct r2nm_node *, int, void *);
55
56struct r2hb_callback_func {
57 u32 hc_magic;
58 struct list_head hc_item;
59 r2hb_cb_func *hc_func;
60 void *hc_data;
61 int hc_priority;
62 enum r2hb_callback_type hc_type;
63};
64
65struct config_group *r2hb_alloc_hb_set(void);
66void r2hb_free_hb_set(struct config_group *group);
67
68void r2hb_setup_callback(struct r2hb_callback_func *hc,
69 enum r2hb_callback_type type,
70 r2hb_cb_func *func,
71 void *data,
72 int priority);
73int r2hb_register_callback(const char *region_uuid,
74 struct r2hb_callback_func *hc);
75void r2hb_unregister_callback(const char *region_uuid,
76 struct r2hb_callback_func *hc);
77void r2hb_fill_node_map(unsigned long *map,
78 unsigned bytes);
79void r2hb_exit(void);
80int r2hb_init(void);
81int r2hb_check_node_heartbeating_from_callback(u8 node_num);
82void r2hb_stop_all_regions(void);
83int r2hb_get_all_regions(char *region_uuids, u8 numregions);
84int r2hb_global_heartbeat_active(void);
85void r2hb_manual_set_node_heartbeating(int);
86
87#endif
88