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 } crm_node_t;
  82 
  83 void crm_peer_init(void);
  84 void crm_peer_destroy(void);
  85 
  86 typedef struct crm_cluster_s {
  87     char *uuid;
  88     char *uname;
  89     uint32_t nodeid;
  90 
  91     void (*destroy) (gpointer);
  92 
  93 #  if SUPPORT_COROSYNC
  94     /* @TODO When we can break public API compatibility, make these members a
  95      * separate struct and use void *cluster_data here instead, to abstract the
  96      * cluster layer further.
  97      */
  98     struct cpg_name group;
  99     cpg_callbacks_t cpg;
 100     cpg_handle_t cpg_handle;
 101 #  endif
 102 
 103 } crm_cluster_t;
 104 
 105 gboolean crm_cluster_connect(crm_cluster_t *cluster);
 106 void crm_cluster_disconnect(crm_cluster_t *cluster);
 107 
 108 crm_cluster_t *pcmk_cluster_new(void);
 109 void pcmk_cluster_free(crm_cluster_t *cluster);
 110 
 111 enum crm_ais_msg_class {
 112     crm_class_cluster = 0,
 113 };
 114 
 115 enum crm_ais_msg_types {
 116     crm_msg_none     = 0,
 117     crm_msg_ais      = 1,
 118     crm_msg_lrmd     = 2,
 119     crm_msg_cib      = 3,
 120     crm_msg_crmd     = 4,
 121     crm_msg_attrd    = 5,
 122     crm_msg_stonithd = 6,
 123     crm_msg_te       = 7,
 124     crm_msg_pe       = 8,
 125     crm_msg_stonith_ng = 9,
 126 };
 127 
 128 /* used with crm_get_peer_full */
 129 enum crm_get_peer_flags {
 130     CRM_GET_PEER_CLUSTER   = 0x0001,
 131     CRM_GET_PEER_REMOTE    = 0x0002,
 132     CRM_GET_PEER_ANY       = CRM_GET_PEER_CLUSTER|CRM_GET_PEER_REMOTE,
 133 };
 134 
 135 gboolean send_cluster_message(const crm_node_t *node,
 136                               enum crm_ais_msg_types service, xmlNode *data,
 137                               gboolean ordered);
 138 
 139 int crm_remote_peer_cache_size(void);
 140 
 141 /* Initialize and refresh the remote peer cache from a cib config */
 142 void crm_remote_peer_cache_refresh(xmlNode *cib);
 143 crm_node_t *crm_remote_peer_get(const char *node_name);
 144 void crm_remote_peer_cache_remove(const char *node_name);
 145 
 146 /* allows filtering of remote and cluster nodes using crm_get_peer_flags */
 147 crm_node_t *crm_get_peer_full(unsigned int id, const char *uname, int flags);
 148 
 149 /* only searches cluster nodes */
 150 crm_node_t *crm_get_peer(unsigned int id, const char *uname);
 151 
 152 guint crm_active_peers(void);
 153 gboolean crm_is_peer_active(const crm_node_t * node);
 154 guint reap_crm_member(uint32_t id, const char *name);
 155 
 156 #  if SUPPORT_COROSYNC
 157 uint32_t get_local_nodeid(cpg_handle_t handle);
 158 
 159 gboolean cluster_connect_cpg(crm_cluster_t *cluster);
 160 void cluster_disconnect_cpg(crm_cluster_t * cluster);
 161 
 162 void pcmk_cpg_membership(cpg_handle_t handle,
 163                          const struct cpg_name *groupName,
 164                          const struct cpg_address *member_list, size_t member_list_entries,
 165                          const struct cpg_address *left_list, size_t left_list_entries,
 166                          const struct cpg_address *joined_list, size_t joined_list_entries);
 167 gboolean crm_is_corosync_peer_active(const crm_node_t * node);
 168 gboolean send_cluster_text(enum crm_ais_msg_class msg_class, const char *data,
 169                            gboolean local, const crm_node_t *node,
 170                            enum crm_ais_msg_types dest);
 171 char *pcmk_message_common_cs(cpg_handle_t handle, uint32_t nodeid, uint32_t pid, void *msg,
 172                         uint32_t *kind, const char **from);
 173 #  endif
 174 
 175 const char *crm_peer_uuid(crm_node_t *node);
 176 const char *crm_peer_uname(const char *uuid);
 177 void set_uuid(xmlNode *xml, const char *attr, crm_node_t *node);
 178 
 179 enum crm_status_type {
 180     crm_status_uname,
 181     crm_status_nstate,
 182     crm_status_processes,
 183 };
 184 
 185 enum crm_ais_msg_types text2msg_type(const char *text);
 186 void crm_set_status_callback(void (*dispatch) (enum crm_status_type, crm_node_t *, const void *));
 187 void crm_set_autoreap(gboolean autoreap);
 188 
 189 enum cluster_type_e {
 190     pcmk_cluster_unknown     = 0x0001,
 191     pcmk_cluster_invalid     = 0x0002,
 192     // 0x0004 was heartbeat
 193     // 0x0010 was corosync 1 with plugin
 194     pcmk_cluster_corosync    = 0x0020,
 195     // 0x0040 was corosync 1 with CMAN
 196 };
 197 
 198 enum cluster_type_e get_cluster_type(void);
 199 const char *name_for_cluster_type(enum cluster_type_e type);
 200 
 201 gboolean is_corosync_cluster(void);
 202 
 203 const char *get_local_node_name(void);
 204 char *get_node_name(uint32_t nodeid);
 205 
 206 /*!
 207  * \brief Get log-friendly string equivalent of a join phase
 208  *
 209  * \param[in] phase  Join phase
 210  *
 211  * \return Log-friendly string equivalent of \p phase
 212  */
 213 static inline const char *
 214 crm_join_phase_str(enum crm_join_phase phase)
     /* [previous][next][first][last][top][bottom][index][help] */
 215 {
 216     switch (phase) {
 217         case crm_join_nack_quiet:   return "nack_quiet";
 218         case crm_join_nack:         return "nack";
 219         case crm_join_none:         return "none";
 220         case crm_join_welcomed:     return "welcomed";
 221         case crm_join_integrated:   return "integrated";
 222         case crm_join_finalized:    return "finalized";
 223         case crm_join_confirmed:    return "confirmed";
 224         default:                    return "invalid";
 225     }
 226 }
 227 
 228 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
 229 #include <crm/cluster/compat.h>
 230 #endif
 231 
 232 #ifdef __cplusplus
 233 }
 234 #endif
 235 
 236 #endif

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