1
2
3
4
5
6
7
8
9
10 #ifndef PACEMAKER_ATTRD__H
11 # define PACEMAKER_ATTRD__H
12
13 #include <regex.h>
14 #include <glib.h>
15 #include <crm/crm.h>
16 #include <crm/cluster.h>
17 #include <crm/cluster/election_internal.h>
18 #include <crm/cib/internal.h>
19
20 void attrd_init_mainloop(void);
21 void attrd_run_mainloop(void);
22
23 void attrd_set_requesting_shutdown(void);
24 void attrd_clear_requesting_shutdown(void);
25 gboolean attrd_requesting_shutdown(void);
26 gboolean attrd_shutting_down(void);
27 void attrd_shutdown(int nsig);
28 void attrd_init_ipc(qb_ipcs_service_t **ipcs,
29 qb_ipcs_msg_process_fn dispatch_fn);
30 void attrd_ipc_fini(void);
31
32 void attrd_cib_disconnect(void);
33
34 gboolean attrd_value_needs_expansion(const char *value);
35 int attrd_expand_value(const char *value, const char *old_value);
36
37
38 #define ATTRD_RE_CLEAR_ALL \
39 "^(" PCMK__FAIL_COUNT_PREFIX "|" PCMK__LAST_FAILURE_PREFIX ")-"
40
41
42
43
44
45
46
47 #define ATTRD_RE_CLEAR_ONE ATTRD_RE_CLEAR_ALL "%s(#.+_[0-9]+)?$"
48
49
50
51
52
53
54
55 #define ATTRD_RE_CLEAR_OP ATTRD_RE_CLEAR_ALL "%s(#%s_%u)?$"
56
57 int attrd_failure_regex(regex_t *regex, const char *rsc, const char *op,
58 guint interval_ms);
59
60 extern cib_t *the_cib;
61
62
63
64 extern lrmd_t *the_lrmd;
65 extern crm_trigger_t *attrd_config_read;
66
67 void attrd_lrmd_disconnect(void);
68 gboolean attrd_read_options(gpointer user_data);
69 void attrd_cib_replaced_cb(const char *event, xmlNode * msg);
70 void attrd_cib_updated_cb(const char *event, xmlNode *msg);
71 int attrd_send_attribute_alert(const char *node, int nodeid,
72 const char *attr, const char *value);
73
74
75 void attrd_election_init(void);
76 void attrd_election_fini(void);
77 void attrd_start_election_if_needed(void);
78 bool attrd_election_won(void);
79 void attrd_handle_election_op(const crm_node_t *peer, xmlNode *xml);
80 bool attrd_check_for_new_writer(const crm_node_t *peer, const xmlNode *xml);
81 void attrd_declare_winner(void);
82 void attrd_remove_voter(const crm_node_t *peer);
83 void attrd_xml_add_writer(xmlNode *xml);
84
85 typedef struct attribute_s {
86 char *uuid;
87 char *id;
88 char *set;
89 GHashTable *values;
90 int update;
91 int timeout_ms;
92
93
94 bool changed;
95 bool unknown_peer_uuids;
96 gboolean is_private;
97
98 mainloop_timer_t *timer;
99
100 char *user;
101
102 gboolean force_write;
103
104 } attribute_t;
105
106 typedef struct attribute_value_s {
107 uint32_t nodeid;
108 gboolean is_remote;
109 char *nodename;
110 char *current;
111 char *requested;
112 gboolean seen;
113 } attribute_value_t;
114
115 extern crm_cluster_t *attrd_cluster;
116 extern GHashTable *attributes;
117
118 #define attrd_send_ack(client, id, flags) \
119 pcmk__ipc_send_ack((client), (id), (flags), "ack", CRM_EX_INDETERMINATE)
120
121 #define CIB_OP_TIMEOUT_S 120
122
123 void write_attributes(bool all, bool ignore_delay);
124 void attrd_broadcast_protocol(void);
125 void attrd_peer_message(crm_node_t *client, xmlNode *msg);
126 void attrd_client_peer_remove(pcmk__client_t *client, xmlNode *xml);
127 void attrd_client_clear_failure(xmlNode *xml);
128 void attrd_client_update(xmlNode *xml);
129 void attrd_client_refresh(void);
130 void attrd_client_query(pcmk__client_t *client, uint32_t id, uint32_t flags,
131 xmlNode *query);
132
133 void free_attribute(gpointer data);
134
135 gboolean attrd_election_cb(gpointer user_data);
136 void attrd_peer_change_cb(enum crm_status_type type, crm_node_t *peer, const void *data);
137
138 #endif