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 (C) 2004 Andrew Beekhof <andrew@beekhof.net>
   3  *
   4  * This program is free software; you can redistribute it and/or
   5  * modify it under the terms of the GNU Lesser General Public
   6  * License as published by the Free Software Foundation; either
   7  * version 2 of the License, or (at your option) any later version.
   8  *
   9  * This software is distributed in the hope that it will be useful,
  10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12  * General Public License for more details.
  13  *
  14  * You should have received a copy of the GNU Lesser General Public
  15  * License along with this library; if not, write to the Free Software
  16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  17  */
  18 #ifndef CRM_COMMON_CLUSTER__H
  19 #  define CRM_COMMON_CLUSTER__H
  20 
  21 #  include <crm/common/xml.h>
  22 #  include <crm/common/util.h>
  23 
  24 #  if SUPPORT_HEARTBEAT
  25 #    include <heartbeat/hb_api.h>
  26 #    include <ocf/oc_event.h>
  27 #  endif
  28 
  29 #  if SUPPORT_COROSYNC
  30 #    include <corosync/cpg.h>
  31 #  endif
  32 
  33 extern gboolean crm_have_quorum;
  34 extern GHashTable *crm_peer_cache;
  35 extern GHashTable *crm_remote_peer_cache;
  36 extern unsigned long long crm_peer_seq;
  37 
  38 #  ifndef CRM_SERVICE
  39 #    define CRM_SERVICE PCMK_SERVICE_ID
  40 #  endif
  41 
  42 /* *INDENT-OFF* */
  43 #define CRM_NODE_LOST      "lost"
  44 #define CRM_NODE_MEMBER    "member"
  45 #define CRM_NODE_ACTIVE    CRM_NODE_MEMBER
  46 #define CRM_NODE_EVICTED   "evicted"
  47 
  48 enum crm_join_phase
  49 {
  50     crm_join_nack       = -1,
  51     crm_join_none       = 0,
  52     crm_join_welcomed   = 1,
  53     crm_join_integrated = 2,
  54     crm_join_finalized  = 3,
  55     crm_join_confirmed  = 4,
  56 };
  57 
  58 enum crm_node_flags
  59 {
  60     /* node is not a cluster node and should not be considered for cluster membership */
  61     crm_remote_node          = 0x0001,
  62 
  63     /* deprecated (not used by cluster) */
  64     crm_remote_container     = 0x0002,
  65     crm_remote_baremetal     = 0x0004,
  66 
  67     /* node's cache entry is dirty */
  68     crm_node_dirty           = 0x0010,
  69 };
  70 /* *INDENT-ON* */
  71 
  72 typedef struct crm_peer_node_s {
  73     uint32_t id;                /* Only used by corosync derivatives */
  74     uint64_t born;              /* Only used by heartbeat and the legacy plugin */
  75     uint64_t last_seen;
  76     uint64_t flags;             /* Specified by crm_node_flags enum */
  77 
  78     int32_t votes;              /* Only used by the legacy plugin */
  79     uint32_t processes;
  80     enum crm_join_phase join;
  81 
  82     char *uname;
  83     char *uuid;
  84     char *state;
  85     char *expected;
  86 
  87     char *addr;                 /* Only used by the legacy plugin */
  88     char *version;              /* Unused */
  89 } crm_node_t;
  90 
  91 void crm_peer_init(void);
  92 void crm_peer_destroy(void);
  93 
  94 typedef struct crm_cluster_s {
  95     char *uuid;
  96     char *uname;
  97     uint32_t nodeid;
  98 
  99     void (*destroy) (gpointer);
 100 
 101 #  if SUPPORT_HEARTBEAT
 102     ll_cluster_t *hb_conn;
 103     void (*hb_dispatch) (HA_Message * msg, void *private);
 104 #  endif
 105 
 106 #  if SUPPORT_COROSYNC
 107     struct cpg_name group;
 108     cpg_callbacks_t cpg;
 109     cpg_handle_t cpg_handle;
 110 #  endif
 111 
 112 } crm_cluster_t;
 113 
 114 gboolean crm_cluster_connect(crm_cluster_t * cluster);
 115 void crm_cluster_disconnect(crm_cluster_t * cluster);
 116 
 117 /* *INDENT-OFF* */
 118 enum crm_ais_msg_class {
 119     crm_class_cluster = 0,
 120     crm_class_members = 1,
 121     crm_class_notify  = 2,
 122     crm_class_nodeid  = 3,
 123     crm_class_rmpeer  = 4,
 124     crm_class_quorum  = 5,
 125 };
 126 
 127 /* order here matters - it's used to index into the crm_children array */
 128 enum crm_ais_msg_types {
 129     crm_msg_none     = 0,
 130     crm_msg_ais      = 1,
 131     crm_msg_lrmd     = 2,
 132     crm_msg_cib      = 3,
 133     crm_msg_crmd     = 4,
 134     crm_msg_attrd    = 5,
 135     crm_msg_stonithd = 6,
 136     crm_msg_te       = 7,
 137     crm_msg_pe       = 8,
 138     crm_msg_stonith_ng = 9,
 139 };
 140 
 141 /* used with crm_get_peer_full */
 142 enum crm_get_peer_flags {
 143     CRM_GET_PEER_CLUSTER   = 0x0001,
 144     CRM_GET_PEER_REMOTE    = 0x0002,
 145     CRM_GET_PEER_ANY       = CRM_GET_PEER_CLUSTER|CRM_GET_PEER_REMOTE,
 146 };
 147 /* *INDENT-ON* */
 148 
 149 gboolean send_cluster_message(crm_node_t * node, enum crm_ais_msg_types service,
 150                               xmlNode * data, gboolean ordered);
 151 
 152 
 153 int crm_remote_peer_cache_size(void);
 154 
 155 /* Initialize and refresh the remote peer cache from a cib config */
 156 void crm_remote_peer_cache_refresh(xmlNode *cib);
 157 void crm_remote_peer_cache_add(const char *node_name);
 158 crm_node_t *crm_remote_peer_get(const char *node_name);
 159 void crm_remote_peer_cache_remove(const char *node_name);
 160 
 161 /* allows filtering of remote and cluster nodes using crm_get_peer_flags */
 162 crm_node_t *crm_get_peer_full(unsigned int id, const char *uname, int flags);
 163 
 164 /* only searches cluster nodes */
 165 crm_node_t *crm_get_peer(unsigned int id, const char *uname);
 166 
 167 guint crm_active_peers(void);
 168 gboolean crm_is_peer_active(const crm_node_t * node);
 169 guint reap_crm_member(uint32_t id, const char *name);
 170 int crm_terminate_member(int nodeid, const char *uname, void *unused);
 171 int crm_terminate_member_no_mainloop(int nodeid, const char *uname, int *connection);
 172 
 173 #  if SUPPORT_HEARTBEAT
 174 gboolean crm_is_heartbeat_peer_active(const crm_node_t * node);
 175 #  endif
 176 
 177 #  if SUPPORT_COROSYNC
 178 extern int ais_fd_sync;
 179 uint32_t get_local_nodeid(cpg_handle_t handle);
 180 
 181 gboolean cluster_connect_cpg(crm_cluster_t *cluster);
 182 void cluster_disconnect_cpg(crm_cluster_t * cluster);
 183 
 184 void pcmk_cpg_membership(cpg_handle_t handle,
 185                          const struct cpg_name *groupName,
 186                          const struct cpg_address *member_list, size_t member_list_entries,
 187                          const struct cpg_address *left_list, size_t left_list_entries,
 188                          const struct cpg_address *joined_list, size_t joined_list_entries);
 189 gboolean crm_is_corosync_peer_active(const crm_node_t * node);
 190 gboolean send_cluster_text(int class, const char *data, gboolean local,
 191                        crm_node_t * node, enum crm_ais_msg_types dest);
 192 #  endif
 193 
 194 const char *crm_peer_uuid(crm_node_t *node);
 195 const char *crm_peer_uname(const char *uuid);
 196 void set_uuid(xmlNode *xml, const char *attr, crm_node_t *node);
 197 
 198 enum crm_status_type {
 199     crm_status_uname,
 200     crm_status_nstate,
 201     crm_status_processes,
 202     crm_status_rstate, /* remote node state */
 203 };
 204 
 205 enum crm_ais_msg_types text2msg_type(const char *text);
 206 void crm_set_status_callback(void (*dispatch) (enum crm_status_type, crm_node_t *, const void *));
 207 void crm_set_autoreap(gboolean autoreap);
 208 
 209 /* *INDENT-OFF* */
 210 enum cluster_type_e
 211 {
 212     pcmk_cluster_unknown     = 0x0001,
 213     pcmk_cluster_invalid     = 0x0002,
 214     pcmk_cluster_heartbeat   = 0x0004,
 215     pcmk_cluster_classic_ais = 0x0010,
 216     pcmk_cluster_corosync    = 0x0020,
 217     pcmk_cluster_cman        = 0x0040,
 218 };
 219 /* *INDENT-ON* */
 220 
 221 enum cluster_type_e get_cluster_type(void);
 222 const char *name_for_cluster_type(enum cluster_type_e type);
 223 
 224 gboolean is_corosync_cluster(void);
 225 gboolean is_cman_cluster(void);
 226 gboolean is_openais_cluster(void);
 227 gboolean is_classic_ais_cluster(void);
 228 gboolean is_heartbeat_cluster(void);
 229 
 230 const char *get_local_node_name(void);
 231 char *get_node_name(uint32_t nodeid);
 232 
 233 #  if SUPPORT_COROSYNC
 234 char *pcmk_message_common_cs(cpg_handle_t handle, uint32_t nodeid, uint32_t pid, void *msg,
 235                         uint32_t *kind, const char **from);
 236 #  endif
 237 
 238 static inline const char *
 239 crm_join_phase_str(enum crm_join_phase phase)
     /* [previous][next][first][last][top][bottom][index][help] */
 240 {
 241     switch (phase) {
 242         case crm_join_nack:         return "nack";
 243         case crm_join_none:         return "none";
 244         case crm_join_welcomed:     return "welcomed";
 245         case crm_join_integrated:   return "integrated";
 246         case crm_join_finalized:    return "finalized";
 247         case crm_join_confirmed:    return "confirmed";
 248     }
 249     return "invalid";
 250 }
 251 
 252 #endif

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