pacemaker  1.1.12-561c4cf
Scalable High-Availability cluster resource manager
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
cluster.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2004 Andrew Beekhof <andrew@beekhof.net>
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This software is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 #ifndef CRM_COMMON_CLUSTER__H
19 # define CRM_COMMON_CLUSTER__H
20 
21 # include <crm/common/xml.h>
22 # include <crm/common/util.h>
23 
24 # if SUPPORT_HEARTBEAT
25 # include <heartbeat/hb_api.h>
26 # include <ocf/oc_event.h>
27 # endif
28 
29 # if SUPPORT_COROSYNC
30 # include <corosync/cpg.h>
31 # endif
32 
33 extern gboolean crm_have_quorum;
34 extern GHashTable *crm_peer_cache;
35 extern GHashTable *crm_remote_peer_cache;
36 extern unsigned long long crm_peer_seq;
37 
38 # ifndef CRM_SERVICE
39 # define CRM_SERVICE PCMK_SERVICE_ID
40 # endif
41 
42 /* *INDENT-OFF* */
43 #define CRM_NODE_LOST "lost"
44 #define CRM_NODE_MEMBER "member"
45 #define CRM_NODE_ACTIVE CRM_NODE_MEMBER
46 #define CRM_NODE_EVICTED "evicted"
47 
49 {
56 };
57 
59 {
60  /* node is not a cluster node and should not be considered for cluster membership */
61  crm_remote_node = 0x0001,
62  /* This node is a remote node living within a container resource */
64  /* This node is a bare metal remote-node */
66 };
67 /* *INDENT-ON* */
68 
69 typedef struct crm_peer_node_s {
70  uint32_t id; /* Only used by corosync derivatives */
71  uint64_t born; /* Only used by heartbeat and the legacy plugin */
72  uint64_t last_seen;
73  uint64_t flags; /* Specified by crm_node_flags enum */
74 
75  int32_t votes; /* Only used by the legacy plugin */
76  uint32_t processes;
78 
79  char *uname;
80  char *uuid;
81  char *state;
82  char *expected;
83 
84  char *addr; /* Only used by the legacy plugin */
85  char *version; /* Unused */
86 } crm_node_t;
87 
88 void crm_peer_init(void);
89 void crm_peer_destroy(void);
90 
91 typedef struct crm_cluster_s {
92  char *uuid;
93  char *uname;
94  uint32_t nodeid;
95 
96  void (*destroy) (gpointer);
97 
98 # if SUPPORT_HEARTBEAT
99  ll_cluster_t *hb_conn;
100  void (*hb_dispatch) (HA_Message * msg, void *private);
101 # endif
102 
103 # if SUPPORT_COROSYNC
104  struct cpg_name group;
105  cpg_callbacks_t cpg;
106  cpg_handle_t cpg_handle;
107 # endif
108 
109 } crm_cluster_t;
110 
111 gboolean crm_cluster_connect(crm_cluster_t * cluster);
112 void crm_cluster_disconnect(crm_cluster_t * cluster);
113 
114 /* *INDENT-OFF* */
122 };
123 
124 /* order here matters - its used to index into the crm_children array */
136 };
137 
138 /* used with crm_get_peer_full */
142 };
143 /* *INDENT-ON* */
144 
145 gboolean send_cluster_message(crm_node_t * node, enum crm_ais_msg_types service,
146  xmlNode * data, gboolean ordered);
147 
148 
150 
151 /* Initialize and refresh the remote peer cache from a cib config */
152 void crm_remote_peer_cache_refresh(xmlNode *cib);
153 void crm_remote_peer_cache_add(const char *node_name);
154 void crm_remote_peer_cache_remove(const char *node_name);
155 
156 /* allows filtering of remote and cluster nodes using crm_get_peer_flags */
157 crm_node_t *crm_get_peer_full(unsigned int id, const char *uname, int flags);
158 
159 /* only searches cluster nodes */
160 crm_node_t *crm_get_peer(unsigned int id, const char *uname);
161 
162 guint crm_active_peers(void);
163 gboolean crm_is_peer_active(const crm_node_t * node);
164 guint reap_crm_member(uint32_t id, const char *name);
165 int crm_terminate_member(int nodeid, const char *uname, void *unused);
166 int crm_terminate_member_no_mainloop(int nodeid, const char *uname, int *connection);
167 
168 # if SUPPORT_HEARTBEAT
169 gboolean crm_is_heartbeat_peer_active(const crm_node_t * node);
170 # endif
171 
172 # if SUPPORT_COROSYNC
173 extern int ais_fd_sync;
174 uint32_t get_local_nodeid(cpg_handle_t handle);
175 
176 gboolean cluster_connect_cpg(crm_cluster_t *cluster);
177 void cluster_disconnect_cpg(crm_cluster_t * cluster);
178 
179 void pcmk_cpg_membership(cpg_handle_t handle,
180  const struct cpg_name *groupName,
181  const struct cpg_address *member_list, size_t member_list_entries,
182  const struct cpg_address *left_list, size_t left_list_entries,
183  const struct cpg_address *joined_list, size_t joined_list_entries);
184 gboolean crm_is_corosync_peer_active(const crm_node_t * node);
185 gboolean send_cluster_text(int class, const char *data, gboolean local,
186  crm_node_t * node, enum crm_ais_msg_types dest);
187 # endif
188 
189 const char *crm_peer_uuid(crm_node_t *node);
190 const char *crm_peer_uname(const char *uuid);
191 void set_uuid(xmlNode *xml, const char *attr, crm_node_t *node);
192 
197  crm_status_rstate, /* remote node state */
198 };
199 
200 enum crm_ais_msg_types text2msg_type(const char *text);
201 void crm_set_status_callback(void (*dispatch) (enum crm_status_type, crm_node_t *, const void *));
202 
203 /* *INDENT-OFF* */
205 {
212 };
213 /* *INDENT-ON* */
214 
216 const char *name_for_cluster_type(enum cluster_type_e type);
217 
218 gboolean is_corosync_cluster(void);
219 gboolean is_cman_cluster(void);
220 gboolean is_openais_cluster(void);
221 gboolean is_classic_ais_cluster(void);
222 gboolean is_heartbeat_cluster(void);
223 
224 const char *get_local_node_name(void);
225 char *get_node_name(uint32_t nodeid);
226 
227 # if SUPPORT_COROSYNC
228 char *pcmk_message_common_cs(cpg_handle_t handle, uint32_t nodeid, uint32_t pid, void *msg,
229  uint32_t *kind, const char **from);
230 # endif
231 
232 #endif
void crm_peer_destroy(void)
struct crm_peer_node_s crm_node_t
void crm_set_status_callback(void(*dispatch)(enum crm_status_type, crm_node_t *, const void *))
gboolean is_openais_cluster(void)
crm_node_flags
Definition: cluster.h:58
crm_ais_msg_types
Definition: cluster.h:125
uint64_t flags
Definition: cluster.h:73
uint32_t nodeid
Definition: cluster.h:94
enum crm_join_phase join
Definition: cluster.h:77
uint32_t id
Definition: cluster.h:70
gboolean is_heartbeat_cluster(void)
gboolean crm_is_peer_active(const crm_node_t *node)
gboolean crm_have_quorum
uint64_t born
Definition: cluster.h:71
char * uuid
Definition: cluster.h:80
int crm_terminate_member(int nodeid, const char *uname, void *unused)
crm_join_phase
Definition: cluster.h:48
struct crm_cluster_s crm_cluster_t
const char * get_local_node_name(void)
void crm_peer_init(void)
void(* destroy)(gpointer)
Definition: cluster.h:96
GHashTable * crm_remote_peer_cache
char * addr
Definition: cluster.h:84
void crm_remote_peer_cache_add(const char *node_name)
crm_node_t * crm_get_peer(unsigned int id, const char *uname)
char * uuid
Definition: cluster.h:92
guint crm_active_peers(void)
uint32_t pid
Definition: internal.h:49
char * get_node_name(uint32_t nodeid)
void crm_cluster_disconnect(crm_cluster_t *cluster)
crm_node_t * crm_get_peer_full(unsigned int id, const char *uname, int flags)
char uname[MAX_NAME]
Definition: internal.h:53
uint32_t processes
Definition: cluster.h:76
enum crm_ais_msg_types text2msg_type(const char *text)
void crm_remote_peer_cache_remove(const char *node_name)
Utility functions.
cluster_type_e
Definition: cluster.h:204
crm_status_type
Definition: cluster.h:193
Wrappers for and extensions to libxml2.
unsigned long long crm_peer_seq
gboolean is_cman_cluster(void)
guint reap_crm_member(uint32_t id, const char *name)
const char * name_for_cluster_type(enum cluster_type_e type)
gboolean crm_cluster_connect(crm_cluster_t *cluster)
char * version
Definition: cluster.h:85
char * expected
Definition: cluster.h:82
gboolean is_corosync_cluster(void)
crm_ais_msg_class
Definition: cluster.h:115
char * uname
Definition: cluster.h:93
const char * crm_peer_uname(const char *uuid)
char data[0]
Definition: internal.h:58
char * state
Definition: cluster.h:81
int32_t votes
Definition: cluster.h:75
char * uname
Definition: cluster.h:79
uint64_t last_seen
Definition: cluster.h:72
void set_uuid(xmlNode *xml, const char *attr, crm_node_t *node)
int crm_terminate_member_no_mainloop(int nodeid, const char *uname, int *connection)
gboolean send_cluster_message(crm_node_t *node, enum crm_ais_msg_types service, xmlNode *data, gboolean ordered)
void crm_remote_peer_cache_refresh(xmlNode *cib)
GHashTable * crm_peer_cache
const char * crm_peer_uuid(crm_node_t *node)
gboolean is_classic_ais_cluster(void)
enum crm_ais_msg_types type
Definition: internal.h:51
enum cluster_type_e get_cluster_type(void)
crm_get_peer_flags
Definition: cluster.h:139
int crm_remote_peer_cache_size(void)
gboolean local
Definition: internal.h:50