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-2018 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_COMMON_CLUSTER__H
  11 #  define CRM_COMMON_CLUSTER__H
  12 
  13 #ifdef __cplusplus
  14 extern "C" {
  15 #endif
  16 
  17 #  include <stdint.h>           // uint32_t, uint64_t
  18 #  include <glib.h>             // gboolean, GHashTable
  19 #  include <libxml/tree.h>      // xmlNode
  20 #  include <crm/common/xml.h>
  21 #  include <crm/common/util.h>
  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 /* *INDENT-OFF* */
  33 #define CRM_NODE_LOST      "lost"
  34 #define CRM_NODE_MEMBER    "member"
  35 
  36 enum crm_join_phase
  37 {
  38     crm_join_nack       = -1,
  39     crm_join_none       = 0,
  40     crm_join_welcomed   = 1,
  41     crm_join_integrated = 2,
  42     crm_join_finalized  = 3,
  43     crm_join_confirmed  = 4,
  44 };
  45 
  46 enum crm_node_flags
  47 {
  48     /* node is not a cluster node and should not be considered for cluster membership */
  49     crm_remote_node          = 0x0001,
  50 
  51     /* node's cache entry is dirty */
  52     crm_node_dirty           = 0x0010,
  53 };
  54 /* *INDENT-ON* */
  55 
  56 typedef struct crm_peer_node_s {
  57     char *uname;                // Node name as known to cluster
  58     char *uuid;                 // Node UUID to ensure uniqueness
  59     char *state;                // @TODO change to enum
  60     uint64_t flags;             // Bitmask of crm_node_flags
  61     uint64_t last_seen;         // Only needed by cluster nodes
  62     uint32_t processes;         // @TODO most not needed, merge into flags
  63 
  64     // Currently only needed by corosync stack
  65     uint32_t id;                // Node ID
  66     time_t when_lost;           // When CPG membership was last lost
  67 
  68     // Only used by controller
  69     enum crm_join_phase join;
  70     char *expected;
  71 } crm_node_t;
  72 
  73 void crm_peer_init(void);
  74 void crm_peer_destroy(void);
  75 
  76 typedef struct crm_cluster_s {
  77     char *uuid;
  78     char *uname;
  79     uint32_t nodeid;
  80 
  81     void (*destroy) (gpointer);
  82 
  83 #  if SUPPORT_COROSYNC
  84     struct cpg_name group;
  85     cpg_callbacks_t cpg;
  86     cpg_handle_t cpg_handle;
  87 #  endif
  88 
  89 } crm_cluster_t;
  90 
  91 gboolean crm_cluster_connect(crm_cluster_t * cluster);
  92 void crm_cluster_disconnect(crm_cluster_t * cluster);
  93 
  94 /* *INDENT-OFF* */
  95 enum crm_ais_msg_class {
  96     crm_class_cluster = 0,
  97 };
  98 
  99 enum crm_ais_msg_types {
 100     crm_msg_none     = 0,
 101     crm_msg_ais      = 1,
 102     crm_msg_lrmd     = 2,
 103     crm_msg_cib      = 3,
 104     crm_msg_crmd     = 4,
 105     crm_msg_attrd    = 5,
 106     crm_msg_stonithd = 6,
 107     crm_msg_te       = 7,
 108     crm_msg_pe       = 8,
 109     crm_msg_stonith_ng = 9,
 110 };
 111 
 112 /* used with crm_get_peer_full */
 113 enum crm_get_peer_flags {
 114     CRM_GET_PEER_CLUSTER   = 0x0001,
 115     CRM_GET_PEER_REMOTE    = 0x0002,
 116     CRM_GET_PEER_ANY       = CRM_GET_PEER_CLUSTER|CRM_GET_PEER_REMOTE,
 117 };
 118 /* *INDENT-ON* */
 119 
 120 gboolean send_cluster_message(crm_node_t * node, enum crm_ais_msg_types service,
 121                               xmlNode * data, gboolean ordered);
 122 
 123 
 124 int crm_remote_peer_cache_size(void);
 125 
 126 /* Initialize and refresh the remote peer cache from a cib config */
 127 void crm_remote_peer_cache_refresh(xmlNode *cib);
 128 crm_node_t *crm_remote_peer_get(const char *node_name);
 129 void crm_remote_peer_cache_remove(const char *node_name);
 130 
 131 /* allows filtering of remote and cluster nodes using crm_get_peer_flags */
 132 crm_node_t *crm_get_peer_full(unsigned int id, const char *uname, int flags);
 133 
 134 /* only searches cluster nodes */
 135 crm_node_t *crm_get_peer(unsigned int id, const char *uname);
 136 
 137 guint crm_active_peers(void);
 138 gboolean crm_is_peer_active(const crm_node_t * node);
 139 guint reap_crm_member(uint32_t id, const char *name);
 140 int crm_terminate_member(int nodeid, const char *uname, void *unused);
 141 int crm_terminate_member_no_mainloop(int nodeid, const char *uname, int *connection);
 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 /* *INDENT-OFF* */
 177 enum cluster_type_e
 178 {
 179     pcmk_cluster_unknown     = 0x0001,
 180     pcmk_cluster_invalid     = 0x0002,
 181     // 0x0004 was heartbeat
 182     // 0x0010 was corosync 1 with plugin
 183     pcmk_cluster_corosync    = 0x0020,
 184     // 0x0040 was corosync 1 with CMAN
 185 };
 186 /* *INDENT-ON* */
 187 
 188 enum cluster_type_e get_cluster_type(void);
 189 const char *name_for_cluster_type(enum cluster_type_e type);
 190 
 191 gboolean is_corosync_cluster(void);
 192 
 193 const char *get_local_node_name(void);
 194 char *get_node_name(uint32_t nodeid);
 195 
 196 static inline const char *
 197 crm_join_phase_str(enum crm_join_phase phase)
     /* [previous][next][first][last][top][bottom][index][help] */
 198 {
 199     switch (phase) {
 200         case crm_join_nack:         return "nack";
 201         case crm_join_none:         return "none";
 202         case crm_join_welcomed:     return "welcomed";
 203         case crm_join_integrated:   return "integrated";
 204         case crm_join_finalized:    return "finalized";
 205         case crm_join_confirmed:    return "confirmed";
 206     }
 207     return "invalid";
 208 }
 209 
 210 #ifdef __cplusplus
 211 }
 212 #endif
 213 
 214 #endif

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