pacemaker 2.1.8-2.1.8
Scalable High-Availability cluster resource manager
Loading...
Searching...
No Matches
cluster.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__H
11# define PCMK__CRM_CLUSTER__H
12
13# include <stdint.h> // uint32_t, uint64_t
14# include <glib.h> // gboolean, GHashTable
15# include <libxml/tree.h> // xmlNode
16# include <crm/common/xml.h>
17# include <crm/common/util.h>
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23# if SUPPORT_COROSYNC
24# include <corosync/cpg.h>
25# endif
26
27// @COMPAT Make this internal when we can break API backward compatibility
29extern gboolean crm_have_quorum;
30
31// @COMPAT Make this internal when we can break API backward compatibility
33extern GHashTable *crm_peer_cache;
34
35// @COMPAT Make this internal when we can break API backward compatibility
37extern GHashTable *crm_remote_peer_cache;
38
39// @COMPAT Make this internal when we can break API backward compatibility
41extern unsigned long long crm_peer_seq;
42
43// @COMPAT Make this internal when we can break API backward compatibility
45#define CRM_NODE_LOST "lost"
46
47// @COMPAT Make this internal when we can break API backward compatibility
49#define CRM_NODE_MEMBER "member"
50
51// @COMPAT Make this internal when we can break API backward compatibility
55 /* @COMPAT: crm_join_nack_quiet can be replaced by crm_node_t:user_data
56 * at a compatibility break.
57 */
60
67};
69
70// @COMPAT Make this internal when we can break API backward compatibility
74 /* Node is not a cluster node and should not be considered for cluster
75 * membership
76 */
77 crm_remote_node = (1U << 0),
78
79 // Node's cache entry is dirty
80 crm_node_dirty = (1U << 1),
81};
83
84// @COMPAT Make this internal when we can break API backward compatibility
87typedef struct crm_peer_node_s {
88 char *uname; // Node name as known to cluster
89
90 /* @COMPAT This is less than ideal since the value is not a valid XML ID
91 * (for Corosync, it's the string equivalent of the node's numeric node ID,
92 * but XML IDs can't start with a number) and the three elements should have
93 * different IDs.
94 *
95 * Ideally, we would use something like node-NODEID, node_state-NODEID, and
96 * transient_attributes-NODEID as the element IDs. Unfortunately changing it
97 * would be impractical due to backward compatibility; older nodes in a
98 * rolling upgrade will always write and expect the value in the old format.
99 *
100 * This is also named poorly, since the value is not a UUID, but at least
101 * that can be changed at an API compatibility break.
102 */
107 char *uuid;
108
109 char *state; // @TODO change to enum
110 uint64_t flags; // Bitmask of crm_node_flags
111 uint64_t last_seen; // Only needed by cluster nodes
112 uint32_t processes; // @TODO most not needed, merge into flags
113
114 /* @TODO When we can break public API compatibility, we can make the rest of
115 * these members separate structs and use void *cluster_data and
116 * void *user_data here instead, to abstract the cluster layer further.
117 */
118
119 // Currently only needed by corosync stack
120 uint32_t id; // Node ID
121 time_t when_lost; // When CPG membership was last lost
122
123 // Only used by controller
125 char *expected;
126
127 time_t peer_lost;
129
130 time_t when_member; // Since when node has been a cluster member
131 time_t when_online; // Since when peer has been online in CPG
134
135// Implementation of pcmk_cluster_t
136// @COMPAT Make this internal when we can break API backward compatibility
140 char *uuid;
141 char *uname;
142 uint32_t nodeid;
143
144 // NOTE: sbd (as of at least 1.5.2) uses this
146 void (*destroy) (gpointer);
147
148# if SUPPORT_COROSYNC
149 /* @TODO When we can break public API compatibility, make these members a
150 * separate struct and use void *cluster_data here instead, to abstract the
151 * cluster layer further.
152 */
153 struct cpg_name group;
154
155 // NOTE: sbd (as of at least 1.5.2) uses this
160 cpg_callbacks_t cpg;
161
162 cpg_handle_t cpg_handle;
163# endif
164
165};
167
170
173
175void pcmk_cluster_free(pcmk_cluster_t *cluster);
176
177int pcmk_cluster_set_destroy_fn(pcmk_cluster_t *cluster, void (*fn)(gpointer));
178#if SUPPORT_COROSYNC
179int pcmk_cpg_set_deliver_fn(pcmk_cluster_t *cluster, cpg_deliver_fn_t fn);
180int pcmk_cpg_set_confchg_fn(pcmk_cluster_t *cluster, cpg_confchg_fn_t fn);
181#endif // SUPPORT_COROSYNC
182
183/* @COMPAT Make this internal when we can break API backward compatibility. Also
184 * evaluate whether we can drop this entirely. Since 2.0.0, we have sent only
185 * messages with crm_class_cluster.
186 */
193
194// @COMPAT Make this internal when we can break API backward compatibility
210
211// @COMPAT Make this internal when we can break API backward compatibility
220
230
232const char *pcmk_cluster_layer_text(enum pcmk_cluster_layer layer);
233
234/*
235 * \brief Get log-friendly string equivalent of a join phase
236 *
237 * \param[in] phase Join phase
238 *
239 * \return Log-friendly string equivalent of \p phase
240 */
242static inline const char *
243crm_join_phase_str(enum crm_join_phase phase)
244{
245 switch (phase) {
246 case crm_join_nack_quiet: return "nack_quiet";
247 case crm_join_nack: return "nack";
248 case crm_join_none: return "none";
249 case crm_join_welcomed: return "welcomed";
250 case crm_join_integrated: return "integrated";
251 case crm_join_finalized: return "finalized";
252 case crm_join_confirmed: return "confirmed";
253 default: return "invalid";
254 }
255}
256
257#if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
258#include <crm/cluster/compat.h>
259#endif
260
261#ifdef __cplusplus
262}
263#endif
264
265#endif
void pcmk_cluster_free(pcmk_cluster_t *cluster)
Free a pcmk_cluster_t object and its dynamically allocated members.
Definition cluster.c:197
gboolean crm_have_quorum
Definition membership.c:68
pcmk_cluster_t * pcmk_cluster_new(void)
Allocate a new pcmk_cluster_t object.
Definition cluster.c:186
GHashTable * crm_peer_cache
Definition membership.c:40
crm_ais_msg_types
Definition cluster.h:197
@ crm_msg_stonithd
Definition cluster.h:204
@ crm_msg_none
Definition cluster.h:198
@ crm_msg_cib
Definition cluster.h:201
@ crm_msg_pe
Definition cluster.h:206
@ crm_msg_attrd
Definition cluster.h:203
@ crm_msg_ais
Definition cluster.h:199
@ crm_msg_te
Definition cluster.h:205
@ crm_msg_stonith_ng
Definition cluster.h:207
@ crm_msg_crmd
Definition cluster.h:202
@ crm_msg_lrmd
Definition cluster.h:200
int pcmk_cluster_connect(pcmk_cluster_t *cluster)
Definition cluster.c:123
crm_join_phase
Definition cluster.h:54
@ crm_join_nack_quiet
Not allowed to join, but don't send a nack message.
Definition cluster.h:59
@ crm_join_none
Definition cluster.h:62
@ crm_join_welcomed
Definition cluster.h:63
@ crm_join_nack
Definition cluster.h:61
@ crm_join_finalized
Definition cluster.h:65
@ crm_join_integrated
Definition cluster.h:64
@ crm_join_confirmed
Definition cluster.h:66
GHashTable * crm_remote_peer_cache
Definition membership.c:57
int pcmk_cluster_set_destroy_fn(pcmk_cluster_t *cluster, void(*fn)(gpointer))
Set the destroy function for a cluster object.
Definition cluster.c:216
int pcmk_cluster_disconnect(pcmk_cluster_t *cluster)
Disconnect from the cluster layer.
Definition cluster.c:154
struct crm_peer_node_s crm_node_t
const char * pcmk_cluster_layer_text(enum pcmk_cluster_layer layer)
Get a log-friendly string equivalent of a cluster layer.
Definition cluster.c:388
unsigned long long crm_peer_seq
Definition membership.c:67
enum pcmk_cluster_layer pcmk_get_cluster_layer(void)
Get and validate the local cluster layer.
Definition cluster.c:415
crm_ais_msg_class
Definition cluster.h:189
@ crm_class_cluster
Definition cluster.h:190
pcmk_cluster_layer
Types of cluster layer.
Definition cluster.h:225
@ pcmk_cluster_layer_invalid
Invalid cluster layer.
Definition cluster.h:227
@ pcmk_cluster_layer_corosync
Corosync Cluster Engine.
Definition cluster.h:228
@ pcmk_cluster_layer_unknown
Unknown cluster layer.
Definition cluster.h:226
crm_node_flags
Definition cluster.h:73
@ crm_remote_node
Definition cluster.h:77
@ crm_node_dirty
Definition cluster.h:80
crm_status_type
Definition cluster.h:214
@ crm_status_processes
Definition cluster.h:217
@ crm_status_nstate
Definition cluster.h:216
@ crm_status_uname
Definition cluster.h:215
Utility functions.
Deprecated Pacemaker cluster API.
int pcmk_cpg_set_deliver_fn(pcmk_cluster_t *cluster, cpg_deliver_fn_t fn)
Set the CPG deliver callback function for a cluster object.
Definition cpg.c:794
int pcmk_cpg_set_confchg_fn(pcmk_cluster_t *cluster, cpg_confchg_fn_t fn)
Set the CPG config change callback function for a cluster object.
Definition cpg.c:812
uint32_t nodeid
Definition cluster.h:142
char * uuid
Definition cluster.h:140
char * uname
Definition cluster.h:141
void(* destroy)(gpointer)
Definition cluster.h:146
uint32_t processes
Definition cluster.h:112
char * uname
Definition cluster.h:88
char * expected
Definition cluster.h:125
time_t when_member
Definition cluster.h:130
time_t when_online
Definition cluster.h:131
char * conn_host
Definition cluster.h:128
uint64_t last_seen
Definition cluster.h:111
time_t peer_lost
Definition cluster.h:127
uint32_t id
Definition cluster.h:120
time_t when_lost
Definition cluster.h:121
uint64_t flags
Definition cluster.h:110
enum crm_join_phase join
Definition cluster.h:124
Wrappers for and extensions to libxml2.