root/include/crm/cluster.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. crm_join_phase_str

   1 /*
   2  * Copyright 2004-2023 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
  20 extern "C" {
  21 #endif
  22 
  23 #  if SUPPORT_COROSYNC
  24 #    include <corosync/cpg.h>
  25 #  endif
  26 
  27 extern gboolean crm_have_quorum;
  28 extern GHashTable *crm_peer_cache;
  29 extern GHashTable *crm_remote_peer_cache;
  30 extern unsigned long long crm_peer_seq;
  31 
  32 #define CRM_NODE_LOST      "lost"
  33 #define CRM_NODE_MEMBER    "member"
  34 
  35 enum crm_join_phase {
  36     /* @COMPAT: crm_join_nack_quiet can be replaced by crm_node_t:user_data
  37      *          at a compatibility break.
  38      */
  39     //! Not allowed to join, but don't send a nack message
  40     crm_join_nack_quiet = -2,
  41 
  42     crm_join_nack       = -1,
  43     crm_join_none       = 0,
  44     crm_join_welcomed   = 1,
  45     crm_join_integrated = 2,
  46     crm_join_finalized  = 3,
  47     crm_join_confirmed  = 4,
  48 };
  49 
  50 enum crm_node_flags {
  51     /* node is not a cluster node and should not be considered for cluster membership */
  52     crm_remote_node          = 0x0001,
  53 
  54     /* node's cache entry is dirty */
  55     crm_node_dirty           = 0x0010,
  56 };
  57 
  58 typedef struct crm_peer_node_s {
  59     char *uname;                // Node name as known to cluster
  60     char *uuid;                 // Node UUID to ensure uniqueness
  61     char *state;                // @TODO change to enum
  62     uint64_t flags;             // Bitmask of crm_node_flags
  63     uint64_t last_seen;         // Only needed by cluster nodes
  64     uint32_t processes;         // @TODO most not needed, merge into flags
  65 
  66     /* @TODO When we can break public API compatibility, we can make the rest of
  67      * these members separate structs and use void *cluster_data and
  68      * void *user_data here instead, to abstract the cluster layer further.
  69      */
  70 
  71     // Currently only needed by corosync stack
  72     uint32_t id;                // Node ID
  73     time_t when_lost;           // When CPG membership was last lost
  74 
  75     // Only used by controller
  76     enum crm_join_phase join;
  77     char *expected;
  78 
  79     time_t peer_lost;
  80     char *conn_host;
  81 
  82     time_t when_member;         // Since when node has been a cluster member
  83     time_t when_online;         // Since when peer has been online in CPG
  84 } crm_node_t;
  85 
  86 void crm_peer_init(void);
  87 void crm_peer_destroy(void);
  88 
  89 typedef struct crm_cluster_s {
  90     char *uuid;
  91     char *uname;
  92     uint32_t nodeid;
  93 
  94     void (*destroy) (gpointer);
  95 
  96 #  if SUPPORT_COROSYNC
  97     /* @TODO When we can break public API compatibility, make these members a
  98      * separate struct and use void *cluster_data here instead, to abstract the
  99      * cluster layer further.
 100      */
 101     struct cpg_name group;
 102     cpg_callbacks_t cpg;
 103     cpg_handle_t cpg_handle;
 104 #  endif
 105 
 106 } crm_cluster_t;
 107 
 108 gboolean crm_cluster_connect(crm_cluster_t *cluster);
 109 void crm_cluster_disconnect(crm_cluster_t *cluster);
 110 
 111 crm_cluster_t *pcmk_cluster_new(void);
 112 void pcmk_cluster_free(crm_cluster_t *cluster);
 113 
 114 enum crm_ais_msg_class {
 115     crm_class_cluster = 0,
 116 };
 117 
 118 enum crm_ais_msg_types {
 119     crm_msg_none     = 0,
 120     crm_msg_ais      = 1,
 121     crm_msg_lrmd     = 2,
 122     crm_msg_cib      = 3,
 123     crm_msg_crmd     = 4,
 124     crm_msg_attrd    = 5,
 125     crm_msg_stonithd = 6,
 126     crm_msg_te       = 7,
 127     crm_msg_pe       = 8,
 128     crm_msg_stonith_ng = 9,
 129 };
 130 
 131 /* used with crm_get_peer_full */
 132 enum crm_get_peer_flags {
 133     CRM_GET_PEER_CLUSTER   = 0x0001,
 134     CRM_GET_PEER_REMOTE    = 0x0002,
 135     CRM_GET_PEER_ANY       = CRM_GET_PEER_CLUSTER|CRM_GET_PEER_REMOTE,
 136 };
 137 
 138 gboolean send_cluster_message(const crm_node_t *node,
 139                               enum crm_ais_msg_types service,
 140                               const xmlNode *data, gboolean ordered);
 141 
 142 int crm_remote_peer_cache_size(void);
 143 
 144 /* Initialize and refresh the remote peer cache from a cib config */
 145 void crm_remote_peer_cache_refresh(xmlNode *cib);
 146 crm_node_t *crm_remote_peer_get(const char *node_name);
 147 void crm_remote_peer_cache_remove(const char *node_name);
 148 
 149 /* allows filtering of remote and cluster nodes using crm_get_peer_flags */
 150 crm_node_t *crm_get_peer_full(unsigned int id, const char *uname, int flags);
 151 
 152 /* only searches cluster nodes */
 153 crm_node_t *crm_get_peer(unsigned int id, const char *uname);
 154 
 155 guint crm_active_peers(void);
 156 gboolean crm_is_peer_active(const crm_node_t * node);
 157 guint reap_crm_member(uint32_t id, const char *name);
 158 
 159 #  if SUPPORT_COROSYNC
 160 uint32_t get_local_nodeid(cpg_handle_t handle);
 161 
 162 gboolean cluster_connect_cpg(crm_cluster_t *cluster);
 163 void cluster_disconnect_cpg(crm_cluster_t * cluster);
 164 
 165 void pcmk_cpg_membership(cpg_handle_t handle,
 166                          const struct cpg_name *groupName,
 167                          const struct cpg_address *member_list, size_t member_list_entries,
 168                          const struct cpg_address *left_list, size_t left_list_entries,
 169                          const struct cpg_address *joined_list, size_t joined_list_entries);
 170 gboolean crm_is_corosync_peer_active(const crm_node_t * node);
 171 gboolean send_cluster_text(enum crm_ais_msg_class msg_class, const char *data,
 172                            gboolean local, const crm_node_t *node,
 173                            enum crm_ais_msg_types dest);
 174 char *pcmk_message_common_cs(cpg_handle_t handle, uint32_t nodeid, uint32_t pid, void *msg,
 175                         uint32_t *kind, const char **from);
 176 #  endif
 177 
 178 const char *crm_peer_uuid(crm_node_t *node);
 179 const char *crm_peer_uname(const char *uuid);
 180 
 181 enum crm_status_type {
 182     crm_status_uname,
 183     crm_status_nstate,
 184     crm_status_processes,
 185 };
 186 
 187 enum crm_ais_msg_types text2msg_type(const char *text);
 188 void crm_set_status_callback(void (*dispatch) (enum crm_status_type, crm_node_t *, const void *));
 189 void crm_set_autoreap(gboolean autoreap);
 190 
 191 enum cluster_type_e {
 192     pcmk_cluster_unknown     = 0x0001,
 193     pcmk_cluster_invalid     = 0x0002,
 194     // 0x0004 was heartbeat
 195     // 0x0010 was corosync 1 with plugin
 196     pcmk_cluster_corosync    = 0x0020,
 197     // 0x0040 was corosync 1 with CMAN
 198 };
 199 
 200 enum cluster_type_e get_cluster_type(void);
 201 const char *name_for_cluster_type(enum cluster_type_e type);
 202 
 203 gboolean is_corosync_cluster(void);
 204 
 205 const char *get_local_node_name(void);
 206 char *get_node_name(uint32_t nodeid);
 207 
 208 /*!
 209  * \brief Get log-friendly string equivalent of a join phase
 210  *
 211  * \param[in] phase  Join phase
 212  *
 213  * \return Log-friendly string equivalent of \p phase
 214  */
 215 static inline const char *
 216 crm_join_phase_str(enum crm_join_phase phase)
     /* [previous][next][first][last][top][bottom][index][help] */
 217 {
 218     switch (phase) {
 219         case crm_join_nack_quiet:   return "nack_quiet";
 220         case crm_join_nack:         return "nack";
 221         case crm_join_none:         return "none";
 222         case crm_join_welcomed:     return "welcomed";
 223         case crm_join_integrated:   return "integrated";
 224         case crm_join_finalized:    return "finalized";
 225         case crm_join_confirmed:    return "confirmed";
 226         default:                    return "invalid";
 227     }
 228 }
 229 
 230 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
 231 #include <crm/cluster/compat.h>
 232 #endif
 233 
 234 #ifdef __cplusplus
 235 }
 236 #endif
 237 
 238 #endif

/* [previous][next][first][last][top][bottom][index][help] */