pacemaker  2.1.7-0f7f88312f
Scalable High-Availability cluster resource manager
internal.h
Go to the documentation of this file.
1 /*
2  * Copyright 2004-2021 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 <stdint.h> // uint32_t, uint64_t
14 # include <crm/cluster.h>
15 
16 /* *INDENT-OFF* */
18  crm_proc_none = 0x00000001,
19 
20  // Cluster layers
21  crm_proc_cpg = 0x04000000,
22 
23  // Daemons
24  crm_proc_execd = 0x00000010,
25  crm_proc_based = 0x00000100,
26  crm_proc_controld = 0x00000200,
27  crm_proc_attrd = 0x00001000,
28  crm_proc_schedulerd = 0x00010000,
29  crm_proc_fenced = 0x00100000,
30 };
31 /* *INDENT-ON* */
32 
39 static inline uint32_t
40 crm_get_cluster_proc(void)
41 {
42  switch (get_cluster_type()) {
44  return crm_proc_cpg;
45 
46  default:
47  break;
48  }
49  return crm_proc_none;
50 }
51 
60 static inline const char *
61 pcmk__cs_err_str(int error)
62 {
63 # if SUPPORT_COROSYNC
64  switch (error) {
65  case CS_OK: return "OK";
66  case CS_ERR_LIBRARY: return "Library error";
67  case CS_ERR_VERSION: return "Version error";
68  case CS_ERR_INIT: return "Initialization error";
69  case CS_ERR_TIMEOUT: return "Timeout";
70  case CS_ERR_TRY_AGAIN: return "Try again";
71  case CS_ERR_INVALID_PARAM: return "Invalid parameter";
72  case CS_ERR_NO_MEMORY: return "No memory";
73  case CS_ERR_BAD_HANDLE: return "Bad handle";
74  case CS_ERR_BUSY: return "Busy";
75  case CS_ERR_ACCESS: return "Access error";
76  case CS_ERR_NOT_EXIST: return "Doesn't exist";
77  case CS_ERR_NAME_TOO_LONG: return "Name too long";
78  case CS_ERR_EXIST: return "Exists";
79  case CS_ERR_NO_SPACE: return "No space";
80  case CS_ERR_INTERRUPT: return "Interrupt";
81  case CS_ERR_NAME_NOT_FOUND: return "Name not found";
82  case CS_ERR_NO_RESOURCES: return "No resources";
83  case CS_ERR_NOT_SUPPORTED: return "Not supported";
84  case CS_ERR_BAD_OPERATION: return "Bad operation";
85  case CS_ERR_FAILED_OPERATION: return "Failed operation";
86  case CS_ERR_MESSAGE_ERROR: return "Message error";
87  case CS_ERR_QUEUE_FULL: return "Queue full";
88  case CS_ERR_QUEUE_NOT_AVAILABLE: return "Queue not available";
89  case CS_ERR_BAD_FLAGS: return "Bad flags";
90  case CS_ERR_TOO_BIG: return "Too big";
91  case CS_ERR_NO_SECTIONS: return "No sections";
92  }
93 # endif
94  return "Corosync error";
95 }
96 
97 # if SUPPORT_COROSYNC
98 
99 #if 0
100 /* This is the new way to do it, but we still support all Corosync 2 versions,
101  * and this isn't always available. A better alternative here would be to check
102  * for support in the configure script and enable this conditionally.
103  */
104 #define pcmk__init_cmap(handle) cmap_initialize_map((handle), CMAP_MAP_ICMAP)
105 #else
106 #define pcmk__init_cmap(handle) cmap_initialize(handle)
107 #endif
108 
109 char *pcmk__corosync_cluster_name(void);
110 bool pcmk__corosync_add_nodes(xmlNode *xml_parent);
111 # endif
112 
113 crm_node_t *crm_update_peer_proc(const char *source, crm_node_t * peer,
114  uint32_t flag, const char *status);
115 crm_node_t *pcmk__update_peer_state(const char *source, crm_node_t *node,
116  const char *state, uint64_t membership);
117 
118 void pcmk__update_peer_expected(const char *source, crm_node_t *node,
119  const char *expected);
120 void pcmk__reap_unseen_nodes(uint64_t ring_id);
121 
122 void pcmk__corosync_quorum_connect(gboolean (*dispatch)(unsigned long long,
123  gboolean),
124  void (*destroy) (gpointer));
125 crm_node_t *pcmk__search_node_caches(unsigned int id, const char *uname,
126  uint32_t flags);
127 crm_node_t *pcmk__search_cluster_node_cache(unsigned int id, const char *uname,
128  const char *uuid);
129 
130 void pcmk__refresh_node_caches_from_cib(xmlNode *cib);
131 crm_node_t *pcmk__search_known_node_cache(unsigned int id, const char *uname,
132  uint32_t flags);
133 
134 crm_node_t *pcmk__get_peer(unsigned int id, const char *uname,
135  const char *uuid);
136 crm_node_t *pcmk__get_peer_full(unsigned int id, const char *uname,
137  const char *uuid, int flags);
138 
139 #endif
void pcmk__reap_unseen_nodes(uint64_t ring_id)
Definition: membership.c:1154
crm_node_t * pcmk__get_peer(unsigned int id, const char *uname, const char *uuid)
Get a cluster node cache entry.
Definition: membership.c:735
bool pcmk__corosync_add_nodes(xmlNode *xml_parent)
Definition: corosync.c:559
crm_node_t * pcmk__search_known_node_cache(unsigned int id, const char *uname, uint32_t flags)
Definition: membership.c:1323
crm_node_t * pcmk__search_cluster_node_cache(unsigned int id, const char *uname, const char *uuid)
Definition: membership.c:582
char * pcmk__corosync_cluster_name(void)
Definition: corosync.c:671
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:1141
crm_node_t * crm_update_peer_proc(const char *source, crm_node_t *peer, uint32_t flag, const char *status)
Definition: membership.c:924
void pcmk__update_peer_expected(const char *source, crm_node_t *node, const char *expected)
Definition: membership.c:1018
crm_node_t * pcmk__search_node_caches(unsigned int id, const char *uname, uint32_t flags)
Definition: membership.c:506
void pcmk__corosync_quorum_connect(gboolean(*dispatch)(unsigned long long, gboolean), void(*destroy)(gpointer))
Definition: corosync.c:341
char uname[MAX_NAME]
Definition: cpg.c:50
crm_proc_flag
Definition: internal.h:17
uint64_t flags
Definition: remote.c:215
enum cluster_type_e get_cluster_type(void)
Get (and validate) the local cluster type.
Definition: cluster.c:325
void pcmk__refresh_node_caches_from_cib(xmlNode *cib)
Definition: membership.c:1306
crm_node_t * pcmk__get_peer_full(unsigned int id, const char *uname, const char *uuid, int flags)
Get a node cache entry (cluster or Pacemaker Remote)
Definition: membership.c:536