pacemaker  2.1.8-3980678f03
Scalable High-Availability cluster resource manager
internal.h
Go to the documentation of this file.
1 /*
2  * Copyright 2004-2024 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 PCMK__CRM_CLUSTER_INTERNAL__H
11 # define PCMK__CRM_CLUSTER_INTERNAL__H
12 
13 # include <stdbool.h>
14 # include <stdint.h> // uint32_t, uint64_t
15 
16 # include <glib.h> // gboolean
17 
18 # include <crm/cluster.h>
19 
21  /* @COMPAT When crm_node_t:processes is made internal, we can merge this
22  * into node flags or turn it into a boolean. Until then, in theory
23  * something could depend on these particular numeric values.
24  */
25  crm_proc_none = 0x00000001,
26 
27  // Cluster layers
28  crm_proc_cpg = 0x04000000,
29 };
30 
31 // Used with node cache search functions
35 
38 
41 
45 
46  /* @COMPAT The values before this must stay the same until we can drop
47  * support for enum crm_get_peer_flags
48  */
49 
52 };
53 
60 static inline uint32_t
61 crm_get_cluster_proc(void)
62 {
63  switch (pcmk_get_cluster_layer()) {
65  return crm_proc_cpg;
66 
67  default:
68  break;
69  }
70  return crm_proc_none;
71 }
72 
81 static inline const char *
82 pcmk__cs_err_str(int error)
83 {
84 # if SUPPORT_COROSYNC
85  switch (error) {
86  case CS_OK: return "OK";
87  case CS_ERR_LIBRARY: return "Library error";
88  case CS_ERR_VERSION: return "Version error";
89  case CS_ERR_INIT: return "Initialization error";
90  case CS_ERR_TIMEOUT: return "Timeout";
91  case CS_ERR_TRY_AGAIN: return "Try again";
92  case CS_ERR_INVALID_PARAM: return "Invalid parameter";
93  case CS_ERR_NO_MEMORY: return "No memory";
94  case CS_ERR_BAD_HANDLE: return "Bad handle";
95  case CS_ERR_BUSY: return "Busy";
96  case CS_ERR_ACCESS: return "Access error";
97  case CS_ERR_NOT_EXIST: return "Doesn't exist";
98  case CS_ERR_NAME_TOO_LONG: return "Name too long";
99  case CS_ERR_EXIST: return "Exists";
100  case CS_ERR_NO_SPACE: return "No space";
101  case CS_ERR_INTERRUPT: return "Interrupt";
102  case CS_ERR_NAME_NOT_FOUND: return "Name not found";
103  case CS_ERR_NO_RESOURCES: return "No resources";
104  case CS_ERR_NOT_SUPPORTED: return "Not supported";
105  case CS_ERR_BAD_OPERATION: return "Bad operation";
106  case CS_ERR_FAILED_OPERATION: return "Failed operation";
107  case CS_ERR_MESSAGE_ERROR: return "Message error";
108  case CS_ERR_QUEUE_FULL: return "Queue full";
109  case CS_ERR_QUEUE_NOT_AVAILABLE: return "Queue not available";
110  case CS_ERR_BAD_FLAGS: return "Bad flags";
111  case CS_ERR_TOO_BIG: return "Too big";
112  case CS_ERR_NO_SECTIONS: return "No sections";
113  }
114 # endif
115  return "Corosync error";
116 }
117 
118 # if SUPPORT_COROSYNC
119 
120 #if 0
121 /* This is the new way to do it, but we still support all Corosync 2 versions,
122  * and this isn't always available. A better alternative here would be to check
123  * for support in the configure script and enable this conditionally.
124  */
125 #define pcmk__init_cmap(handle) cmap_initialize_map((handle), CMAP_MAP_ICMAP)
126 #else
127 #define pcmk__init_cmap(handle) cmap_initialize(handle)
128 #endif
129 
130 char *pcmk__corosync_cluster_name(void);
131 bool pcmk__corosync_add_nodes(xmlNode *xml_parent);
132 
133 void pcmk__cpg_confchg_cb(cpg_handle_t handle,
134  const struct cpg_name *group_name,
135  const struct cpg_address *member_list,
136  size_t member_list_entries,
137  const struct cpg_address *left_list,
138  size_t left_list_entries,
139  const struct cpg_address *joined_list,
140  size_t joined_list_entries);
141 
142 char *pcmk__cpg_message_data(cpg_handle_t handle, uint32_t sender_id,
143  uint32_t pid, void *content, uint32_t *kind,
144  const char **from);
145 
146 # endif
147 
148 const char *pcmk__cluster_node_uuid(crm_node_t *node);
149 char *pcmk__cluster_node_name(uint32_t nodeid);
150 const char *pcmk__cluster_local_node_name(void);
151 const char *pcmk__node_name_from_uuid(const char *uuid);
152 
153 crm_node_t *crm_update_peer_proc(const char *source, crm_node_t * peer,
154  uint32_t flag, const char *status);
155 crm_node_t *pcmk__update_peer_state(const char *source, crm_node_t *node,
156  const char *state, uint64_t membership);
157 
158 void pcmk__update_peer_expected(const char *source, crm_node_t *node,
159  const char *expected);
160 void pcmk__reap_unseen_nodes(uint64_t ring_id);
161 
162 void pcmk__corosync_quorum_connect(gboolean (*dispatch)(unsigned long long,
163  gboolean),
164  void (*destroy) (gpointer));
165 
166 enum crm_ais_msg_types pcmk__cluster_parse_msg_type(const char *text);
167 bool pcmk__cluster_send_message(const crm_node_t *node,
168  enum crm_ais_msg_types service,
169  const xmlNode *data);
170 
171 // Membership
172 
175 
176 void pcmk__cluster_set_autoreap(bool enable);
177 void pcmk__cluster_set_status_callback(void (*dispatch)(enum crm_status_type,
178  crm_node_t *,
179  const void *));
180 
181 bool pcmk__cluster_is_node_active(const crm_node_t *node);
182 unsigned int pcmk__cluster_num_active_nodes(void);
183 unsigned int pcmk__cluster_num_remote_nodes(void);
184 
185 crm_node_t *pcmk__cluster_lookup_remote_node(const char *node_name);
186 void pcmk__cluster_forget_cluster_node(uint32_t id, const char *node_name);
187 void pcmk__cluster_forget_remote_node(const char *node_name);
188 crm_node_t *pcmk__search_node_caches(unsigned int id, const char *uname,
189  uint32_t flags);
190 void pcmk__purge_node_from_cache(const char *node_name, uint32_t node_id);
191 
192 void pcmk__refresh_node_caches_from_cib(xmlNode *cib);
193 
194 crm_node_t *pcmk__get_node(unsigned int id, const char *uname,
195  const char *uuid, uint32_t flags);
196 
197 #endif // PCMK__CRM_CLUSTER_INTERNAL__H
crm_node_t * pcmk__get_node(unsigned int id, const char *uname, const char *uuid, uint32_t flags)
Definition: membership.c:890
char data[0]
Definition: cpg.c:58
crm_ais_msg_types
Definition: cluster.h:197
Corosync Cluster Engine.
Definition: cluster.h:228
void pcmk__reap_unseen_nodes(uint64_t ring_id)
Definition: membership.c:1291
void pcmk__cluster_forget_cluster_node(uint32_t id, const char *node_name)
Definition: membership.c:442
const char * pcmk__node_name_from_uuid(const char *uuid)
Definition: cluster.c:347
Search for cluster nodes from membership cache.
Definition: internal.h:37
bool pcmk__corosync_add_nodes(xmlNode *xml_parent)
Definition: corosync.c:556
void pcmk__cluster_forget_remote_node(const char *node_name)
Definition: membership.c:196
const char * pcmk__cluster_local_node_name(void)
Definition: cluster.c:325
void pcmk__cpg_confchg_cb(cpg_handle_t handle, const struct cpg_name *group_name, const struct cpg_address *member_list, size_t member_list_entries, const struct cpg_address *left_list, size_t left_list_entries, const struct cpg_address *joined_list, size_t joined_list_entries)
Definition: cpg.c:689
bool pcmk__cluster_send_message(const crm_node_t *node, enum crm_ais_msg_types service, const xmlNode *data)
Definition: cluster.c:236
char * pcmk__corosync_cluster_name(void)
Definition: corosync.c:668
unsigned int pcmk__cluster_num_active_nodes(void)
Definition: membership.c:507
crm_node_t * pcmk__update_peer_state(const char *source, crm_node_t *node, const char *state, uint64_t membership)
Update a node&#39;s state and membership information.
Definition: membership.c:1278
void pcmk__cluster_set_status_callback(void(*dispatch)(enum crm_status_type, crm_node_t *, const void *))
Definition: membership.c:594
Search for remote nodes.
Definition: internal.h:40
uint32_t pid
Definition: cpg.c:49
Does not affect search.
Definition: internal.h:34
crm_status_type
Definition: cluster.h:214
char * pcmk__cpg_message_data(cpg_handle_t handle, uint32_t sender_id, uint32_t pid, void *content, uint32_t *kind, const char **from)
Definition: cpg.c:432
crm_node_t * crm_update_peer_proc(const char *source, crm_node_t *peer, uint32_t flag, const char *status)
Definition: membership.c:1059
void pcmk__cluster_init_node_caches(void)
Definition: membership.c:537
unsigned int pcmk__cluster_num_remote_nodes(void)
Definition: membership.c:98
void pcmk__update_peer_expected(const char *source, crm_node_t *node, const char *expected)
Definition: membership.c:1153
Search for cluster member nodes and remote nodes.
Definition: internal.h:43
void pcmk__cluster_set_autoreap(bool enable)
Definition: membership.c:616
Search for cluster nodes from CIB (as of last cache refresh)
Definition: internal.h:51
void pcmk__cluster_destroy_node_caches(void)
Definition: membership.c:557
crm_node_t * pcmk__search_node_caches(unsigned int id, const char *uname, uint32_t flags)
Definition: membership.c:765
void pcmk__corosync_quorum_connect(gboolean(*dispatch)(unsigned long long, gboolean), void(*destroy)(gpointer))
Definition: corosync.c:343
enum crm_ais_msg_types pcmk__cluster_parse_msg_type(const char *text)
Definition: cluster.c:44
pcmk__node_search_flags
Definition: internal.h:32
char uname[MAX_NAME]
Definition: cpg.c:53
char * pcmk__cluster_node_name(uint32_t nodeid)
Definition: cluster.c:269
void pcmk__purge_node_from_cache(const char *node_name, uint32_t node_id)
Definition: membership.c:808
crm_node_t * pcmk__cluster_lookup_remote_node(const char *node_name)
Definition: membership.c:122
bool pcmk__cluster_is_node_active(const crm_node_t *node)
Definition: membership.c:347
enum pcmk_cluster_layer pcmk_get_cluster_layer(void)
Get and validate the local cluster layer.
Definition: cluster.c:415
crm_proc_flag
Definition: internal.h:20
uint64_t flags
Definition: remote.c:215
const char * pcmk__cluster_node_uuid(crm_node_t *node)
Definition: cluster.c:89
void pcmk__refresh_node_caches_from_cib(xmlNode *cib)
Definition: membership.c:1439