pacemaker  2.0.2-debe490
Scalable High-Availability cluster resource manager
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
internal.h
Go to the documentation of this file.
1 /*
2  * Copyright 2004-2018 the Pacemaker project contributors
3  *
4  * The version control history for this file may have further details.
5  *
6  * This source code is licensed under the GNU Lesser General Public License
7  * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
8  */
9 
10 #ifndef CRM_CLUSTER_INTERNAL__H
11 # define CRM_CLUSTER_INTERNAL__H
12 
13 # include <crm/cluster.h>
14 
15 typedef struct crm_ais_host_s AIS_Host;
16 typedef struct crm_ais_msg_s AIS_Message;
17 
19  uint32_t id;
20  uint32_t pid;
21  gboolean local;
23  uint32_t size;
24  char uname[MAX_NAME];
25 
26 } __attribute__ ((packed));
27 
28 struct crm_ais_msg_s {
29  cs_ipc_header_response_t header __attribute__ ((aligned(8)));
30  uint32_t id;
31  gboolean is_compressed;
32 
35 
36  uint32_t size;
37  uint32_t compressed_size;
38  /* 584 bytes */
39  char data[0];
40 
41 } __attribute__ ((packed));
42 
43 /* *INDENT-OFF* */
45  crm_proc_none = 0x00000001,
46 
47  // Cluster layers
48  crm_proc_cpg = 0x04000000,
49 
50  // Daemons
51  crm_proc_execd = 0x00000010,
52  crm_proc_based = 0x00000100,
53  crm_proc_controld = 0x00000200,
54  crm_proc_attrd = 0x00001000,
55  crm_proc_schedulerd = 0x00010000,
56  crm_proc_fenced = 0x00100000,
57 };
58 /* *INDENT-ON* */
59 
66 static inline uint32_t
67 crm_get_cluster_proc()
68 {
69  switch (get_cluster_type()) {
71  return crm_proc_cpg;
72 
73  default:
74  break;
75  }
76  return crm_proc_none;
77 }
78 
79 static inline const char *
80 peer2text(enum crm_proc_flag proc)
81 {
82  const char *text = "unknown";
83 
84  switch (proc) {
86  text = "none";
87  break;
88  case crm_proc_based:
89  text = "pacemaker-based";
90  break;
91  case crm_proc_controld:
92  text = "pacemaker-controld";
93  break;
95  text = "pacemaker-schedulerd";
96  break;
97  case crm_proc_execd:
98  text = "pacemaker-execd";
99  break;
100  case crm_proc_attrd:
101  text = "pacemaker-attrd";
102  break;
103  case crm_proc_fenced:
104  text = "pacemaker-fenced";
105  break;
106  case crm_proc_cpg:
107  text = "corosync-cpg";
108  break;
109  }
110  return text;
111 }
112 
113 static inline const char *
114 ais_dest(const AIS_Host *host)
115 {
116  if (host->local) {
117  return "local";
118  } else if (host->size > 0) {
119  return host->uname;
120  } else {
121  return "<all>";
122  }
123 }
124 
125 # define ais_data_len(msg) (msg->is_compressed?msg->compressed_size:msg->size)
126 
127 /*
128 typedef enum {
129  CS_OK = 1,
130  CS_ERR_LIBRARY = 2,
131  CS_ERR_VERSION = 3,
132  CS_ERR_INIT = 4,
133  CS_ERR_TIMEOUT = 5,
134  CS_ERR_TRY_AGAIN = 6,
135  CS_ERR_INVALID_PARAM = 7,
136  CS_ERR_NO_MEMORY = 8,
137  CS_ERR_BAD_HANDLE = 9,
138  CS_ERR_BUSY = 10,
139  CS_ERR_ACCESS = 11,
140  CS_ERR_NOT_EXIST = 12,
141  CS_ERR_NAME_TOO_LONG = 13,
142  CS_ERR_EXIST = 14,
143  CS_ERR_NO_SPACE = 15,
144  CS_ERR_INTERRUPT = 16,
145  CS_ERR_NAME_NOT_FOUND = 17,
146  CS_ERR_NO_RESOURCES = 18,
147  CS_ERR_NOT_SUPPORTED = 19,
148  CS_ERR_BAD_OPERATION = 20,
149  CS_ERR_FAILED_OPERATION = 21,
150  CS_ERR_MESSAGE_ERROR = 22,
151  CS_ERR_QUEUE_FULL = 23,
152  CS_ERR_QUEUE_NOT_AVAILABLE = 24,
153  CS_ERR_BAD_FLAGS = 25,
154  CS_ERR_TOO_BIG = 26,
155  CS_ERR_NO_SECTIONS = 27,
156  CS_ERR_CONTEXT_NOT_FOUND = 28,
157  CS_ERR_TOO_MANY_GROUPS = 30,
158  CS_ERR_SECURITY = 100
159 } cs_error_t;
160  */
161 static inline const char *
162 ais_error2text(int error)
163 {
164  const char *text = "unknown";
165 
166 # if SUPPORT_COROSYNC
167  switch (error) {
168  case CS_OK:
169  text = "OK";
170  break;
171  case CS_ERR_LIBRARY:
172  text = "Library error";
173  break;
174  case CS_ERR_VERSION:
175  text = "Version error";
176  break;
177  case CS_ERR_INIT:
178  text = "Initialization error";
179  break;
180  case CS_ERR_TIMEOUT:
181  text = "Timeout";
182  break;
183  case CS_ERR_TRY_AGAIN:
184  text = "Try again";
185  break;
186  case CS_ERR_INVALID_PARAM:
187  text = "Invalid parameter";
188  break;
189  case CS_ERR_NO_MEMORY:
190  text = "No memory";
191  break;
192  case CS_ERR_BAD_HANDLE:
193  text = "Bad handle";
194  break;
195  case CS_ERR_BUSY:
196  text = "Busy";
197  break;
198  case CS_ERR_ACCESS:
199  text = "Access error";
200  break;
201  case CS_ERR_NOT_EXIST:
202  text = "Doesn't exist";
203  break;
204  case CS_ERR_NAME_TOO_LONG:
205  text = "Name too long";
206  break;
207  case CS_ERR_EXIST:
208  text = "Exists";
209  break;
210  case CS_ERR_NO_SPACE:
211  text = "No space";
212  break;
213  case CS_ERR_INTERRUPT:
214  text = "Interrupt";
215  break;
216  case CS_ERR_NAME_NOT_FOUND:
217  text = "Name not found";
218  break;
219  case CS_ERR_NO_RESOURCES:
220  text = "No resources";
221  break;
222  case CS_ERR_NOT_SUPPORTED:
223  text = "Not supported";
224  break;
225  case CS_ERR_BAD_OPERATION:
226  text = "Bad operation";
227  break;
228  case CS_ERR_FAILED_OPERATION:
229  text = "Failed operation";
230  break;
231  case CS_ERR_MESSAGE_ERROR:
232  text = "Message error";
233  break;
234  case CS_ERR_QUEUE_FULL:
235  text = "Queue full";
236  break;
237  case CS_ERR_QUEUE_NOT_AVAILABLE:
238  text = "Queue not available";
239  break;
240  case CS_ERR_BAD_FLAGS:
241  text = "Bad flags";
242  break;
243  case CS_ERR_TOO_BIG:
244  text = "Too big";
245  break;
246  case CS_ERR_NO_SECTIONS:
247  text = "No sections";
248  break;
249  }
250 # endif
251  return text;
252 }
253 
254 static inline const char *
255 msg_type2text(enum crm_ais_msg_types type)
256 {
257  const char *text = "unknown";
258 
259  switch (type) {
260  case crm_msg_none:
261  text = "unknown";
262  break;
263  case crm_msg_ais:
264  text = "ais";
265  break;
266  case crm_msg_cib:
267  text = "cib";
268  break;
269  case crm_msg_crmd:
270  text = "crmd";
271  break;
272  case crm_msg_pe:
273  text = "pengine";
274  break;
275  case crm_msg_te:
276  text = "tengine";
277  break;
278  case crm_msg_lrmd:
279  text = "lrmd";
280  break;
281  case crm_msg_attrd:
282  text = "attrd";
283  break;
284  case crm_msg_stonithd:
285  text = "stonithd";
286  break;
287  case crm_msg_stonith_ng:
288  text = "stonith-ng";
289  break;
290  }
291  return text;
292 }
293 
294 gboolean check_message_sanity(const AIS_Message * msg, const char *data);
295 
296 # if SUPPORT_COROSYNC
297 
298 gboolean send_cpg_iov(struct iovec * iov);
299 
300 char *get_corosync_uuid(crm_node_t *peer);
301 char *corosync_node_name(uint64_t /*cmap_handle_t */ cmap_handle, uint32_t nodeid);
302 char *corosync_cluster_name(void);
303 int corosync_cmap_has_config(const char *prefix);
304 
305 gboolean corosync_initialize_nodelist(void *cluster, gboolean force_member, xmlNode * xml_parent);
306 
307 gboolean send_cluster_message_cs(xmlNode * msg, gboolean local,
308  crm_node_t * node, enum crm_ais_msg_types dest);
309 
311 
312 void terminate_cs_connection(crm_cluster_t * cluster);
313 gboolean init_cs_connection(crm_cluster_t * cluster);
314 gboolean init_cs_connection_once(crm_cluster_t * cluster);
315 # endif
316 
317 crm_node_t *crm_update_peer_proc(const char *source, crm_node_t * peer,
318  uint32_t flag, const char *status);
319 crm_node_t *crm_update_peer_state(const char *source, crm_node_t * node,
320  const char *state, int membership);
321 
322 void crm_update_peer_uname(crm_node_t *node, const char *uname);
323 void crm_update_peer_expected(const char *source, crm_node_t * node, const char *expected);
324 void crm_reap_unseen_nodes(uint64_t ring_id);
325 
326 gboolean cluster_connect_quorum(gboolean(*dispatch) (unsigned long long, gboolean),
327  void (*destroy) (gpointer));
328 
329 gboolean node_name_is_valid(const char *key, const char *name);
330 
331 crm_node_t * crm_find_peer_full(unsigned int id, const char *uname, int flags);
332 crm_node_t * crm_find_peer(unsigned int id, const char *uname);
333 
334 void crm_peer_caches_refresh(xmlNode *cib);
335 crm_node_t *crm_find_known_peer_full(unsigned int id, const char *uname, int flags);
336 
337 #endif
enum crm_ais_msg_types type
Definition: internal.h:22
char uname[MAX_NAME]
Definition: internal.h:87
char data[0]
Definition: internal.h:39
gboolean send_cpg_iov(struct iovec *iov)
Definition: cpg.c:219
gboolean is_compressed
Definition: internal.h:31
uint32_t size
Definition: internal.h:36
crm_ais_msg_types
Definition: cluster.h:96
void crm_reap_unseen_nodes(uint64_t ring_id)
Definition: membership.c:977
char * corosync_node_name(uint64_tcmap_handle, uint32_t nodeid)
Definition: corosync.c:61
void terminate_cs_connection(crm_cluster_t *cluster)
Definition: corosync.c:174
uint32_t id
Definition: internal.h:19
cs_ipc_header_response_t header __attribute__((aligned(8)))
AIS_Host host
Definition: internal.h:86
gboolean cluster_connect_quorum(gboolean(*dispatch)(unsigned long long, gboolean), void(*destroy)(gpointer))
Definition: corosync.c:271
gboolean init_cs_connection(crm_cluster_t *cluster)
Definition: corosync.c:356
char * corosync_cluster_name(void)
Definition: corosync.c:639
cluster_type_e
Definition: cluster.h:174
gboolean local
Definition: internal.h:21
crm_node_t * crm_update_peer_proc(const char *source, crm_node_t *peer, uint32_t flag, const char *status)
Definition: membership.c:785
AIS_Host sender
Definition: internal.h:34
uint32_t id
Definition: internal.h:30
gboolean check_message_sanity(const AIS_Message *msg, const char *data)
Definition: corosync.c:421
int corosync_cmap_has_config(const char *prefix)
Definition: corosync.c:692
uint32_t size
Definition: internal.h:23
struct qb_ipc_response_header cs_ipc_header_response_t
Definition: crm_internal.h:221
enum cluster_type_e find_corosync_variant(void)
Definition: corosync.c:484
uint32_t compressed_size
Definition: internal.h:37
#define MAX_NAME
Definition: crm.h:38
void crm_update_peer_expected(const char *source, crm_node_t *node, const char *expected)
Definition: membership.c:852
gboolean init_cs_connection_once(crm_cluster_t *cluster)
Definition: corosync.c:383
crm_node_t * crm_find_known_peer_full(unsigned int id, const char *uname, int flags)
Definition: membership.c:1156
crm_node_t * crm_update_peer_state(const char *source, crm_node_t *node, const char *state, int membership)
Update a node&#39;s state and membership information.
Definition: membership.c:965
gboolean node_name_is_valid(const char *key, const char *name)
Definition: cluster.c:334
char uname[MAX_NAME]
Definition: internal.h:24
crm_node_t * crm_find_peer_full(unsigned int id, const char *uname, int flags)
Definition: membership.c:484
gboolean send_cluster_message_cs(xmlNode *msg, gboolean local, crm_node_t *node, enum crm_ais_msg_types dest)
Definition: cpg.c:633
char data[0]
Definition: internal.h:92
char * get_corosync_uuid(crm_node_t *node)
Definition: corosync.c:44
uint32_t pid
Definition: internal.h:20
void crm_update_peer_uname(crm_node_t *node, const char *uname)
Definition: membership.c:732
AIS_Host host
Definition: internal.h:33
void crm_peer_caches_refresh(xmlNode *cib)
Definition: membership.c:1149
crm_node_t * crm_find_peer(unsigned int id, const char *uname)
Definition: membership.c:522
crm_proc_flag
Definition: internal.h:44
gboolean corosync_initialize_nodelist(void *cluster, gboolean force_member, xmlNode *xml_parent)
Definition: corosync.c:530
uint64_t flags
Definition: remote.c:148
enum crm_proc_flag __attribute__
enum crm_ais_msg_types type
Definition: internal.h:85
enum cluster_type_e get_cluster_type(void)
Definition: cluster.c:273
gboolean local
Definition: internal.h:84