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

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