| 1 |
/* |
| 2 |
* ccm.h: definitions Consensus Cluster Manager internal header |
| 3 |
* file |
| 4 |
* |
| 5 |
* Copyright (c) International Business Machines Corp., 2002 |
| 6 |
* Author: Ram Pai ([email protected]) |
| 7 |
* |
| 8 |
* This program is free software; you can redistribute it and/or modify |
| 9 |
* it under the terms of the GNU General Public License as published by |
| 10 |
* the Free Software Foundation; either version 2 of the License, or |
| 11 |
* (at your option) any later version. |
| 12 |
* |
| 13 |
* This program is distributed in the hope that it will be useful, |
| 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
* GNU General Public License for more details. |
| 17 |
* |
| 18 |
* You should have received a copy of the GNU General Public License |
| 19 |
* along with this program; if not, write to the Free Software |
| 20 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 21 |
* |
| 22 |
*/ |
| 23 |
#ifndef _CLUSTER_MANAGER_H_ |
| 24 |
#define _CLUSTER_MANAGER_H_ |
| 25 |
|
| 26 |
#include <stdio.h> |
| 27 |
#include <stdlib.h> |
| 28 |
#include <string.h> |
| 29 |
#include <strings.h> |
| 30 |
#include <fcntl.h> |
| 31 |
#include <unistd.h> |
| 32 |
#include <errno.h> |
| 33 |
#include <math.h> |
| 34 |
#include <sys/types.h> |
| 35 |
#include <sys/wait.h> |
| 36 |
#include <sys/utsname.h> |
| 37 |
#include <sys/time.h> |
| 38 |
#include <unistd.h> |
| 39 |
#include <sys/stat.h> |
| 40 |
#include <stdarg.h> |
| 41 |
#include <assert.h> |
| 42 |
#include <glib.h> |
| 43 |
#include <ipc.h> |
| 44 |
#include <clplumbing/Gmain_timeout.h> |
| 45 |
#include <clplumbing/GSource.h> |
| 46 |
#include <clplumbing/realtime.h> |
| 47 |
#include <base64.h> |
| 48 |
|
| 49 |
#include <heartbeat.h> |
| 50 |
#include <hb_api.h> |
| 51 |
|
| 52 |
#include <ocf/oc_event.h> |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
/* */ |
| 57 |
/* ccm defined new type tokens used by the CCM protocol. */ |
| 58 |
/* */ |
| 59 |
#define CCM_VERSIONVAL "ccmpverval" /* version value token */ |
| 60 |
#define CCM_UPTIME "ccmuptime" /* Uptime for Consensus */ |
| 61 |
#define CCM_MEMLIST "ccmmemlist" /* bitmap for membership */ |
| 62 |
#define CCM_PROTOCOL "ccmproto" /* protocol version */ |
| 63 |
#define CCM_MAJORTRANS "ccmmajor" /* major transition version*/ |
| 64 |
#define CCM_MINORTRANS "ccmminor" /* minor transition version */ |
| 65 |
#define CCM_MAXTRANS "ccmmaxt" /* minor transition version */ |
| 66 |
#define CCM_COOKIE "ccmcookie" /* communication context */ |
| 67 |
#define CCM_NEWCOOKIE "ccmnewcookie" /* new communication context */ |
| 68 |
#define CCM_CLSIZE "ccmclsize" /* new cluster size */ |
| 69 |
#define CCM_UPTIMELIST "ccmuptimelist" /*uptime list*/ |
| 70 |
#define CCM_QUORUM "ccmquorum" /*do we have quorum?*/ |
| 71 |
|
| 72 |
|
| 73 |
/* ccm_types for easier processing. */ |
| 74 |
enum ccm_type { |
| 75 |
CCM_TYPE_PROTOVERSION, |
| 76 |
CCM_TYPE_PROTOVERSION_RESP, |
| 77 |
CCM_TYPE_JOIN, |
| 78 |
CCM_TYPE_REQ_MEMLIST, |
| 79 |
CCM_TYPE_RES_MEMLIST, |
| 80 |
CCM_TYPE_FINAL_MEMLIST, |
| 81 |
CCM_TYPE_ABORT, |
| 82 |
CCM_TYPE_LEAVE, |
| 83 |
CCM_TYPE_TIMEOUT, |
| 84 |
CCM_TYPE_NODE_LEAVE_NOTICE, |
| 85 |
CCM_TYPE_NODE_LEAVE, |
| 86 |
CCM_TYPE_MEM_LIST, |
| 87 |
CCM_TYPE_ALIVE, |
| 88 |
CCM_TYPE_NEW_NODE, |
| 89 |
CCM_TYPE_STATE_INFO, |
| 90 |
CCM_TYPE_RESTART, |
| 91 |
CCM_TYPE_LAST |
| 92 |
}; |
| 93 |
|
| 94 |
|
| 95 |
#define BitsInByte CHAR_BIT |
| 96 |
|
| 97 |
/* BEGINNING OF version request tracking interfaces */ |
| 98 |
typedef struct ccm_version_s { |
| 99 |
longclock_t time; |
| 100 |
int numtries; |
| 101 |
int n_resp; /* keeps track of the number of version */ |
| 102 |
/* responses recevied from other nodes */ |
| 103 |
/* after we received the first response. */ |
| 104 |
} ccm_version_t; |
| 105 |
void version_reset(ccm_version_t *); |
| 106 |
void version_some_activity(ccm_version_t *); |
| 107 |
int version_retry(ccm_version_t *, longclock_t); |
| 108 |
void version_inc_nresp(ccm_version_t *); |
| 109 |
void version_set_nresp(ccm_version_t *, int); |
| 110 |
unsigned int version_get_nresp(ccm_version_t *); |
| 111 |
#define VER_TRY_AGAIN 1 |
| 112 |
#define VER_NO_CHANGE 2 |
| 113 |
#define VER_TRY_END 3 |
| 114 |
|
| 115 |
/* END OF version request tracking interfaces */ |
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
/* BEGINING OF Low Level Membership interfaces */ |
| 120 |
#define NODEIDSIZE 255 /* if this value is changed, change it |
| 121 |
also in ccmlib.h */ |
| 122 |
#define STATUSSIZE 15 |
| 123 |
#define CCMFIFO HA_VARRUNDIR "/heartbeat/ccm/ccm" /* if this value is |
| 124 |
changed change it also in ccmlib.h */ |
| 125 |
|
| 126 |
typedef struct llm_node_s { |
| 127 |
char nodename[NODEIDSIZE]; |
| 128 |
char status[STATUSSIZE]; |
| 129 |
int uptime; |
| 130 |
gboolean join_request; |
| 131 |
int join_request_major_trans; |
| 132 |
gboolean receive_change_msg; |
| 133 |
char site[PATH_MAX]; |
| 134 |
int weight; |
| 135 |
}llm_node_t; |
| 136 |
|
| 137 |
typedef struct llm_info_s { |
| 138 |
int nodecount; |
| 139 |
int myindex; |
| 140 |
llm_node_t nodes[MAXNODE]; |
| 141 |
} llm_info_t; |
| 142 |
|
| 143 |
int llm_get_live_nodecount(llm_info_t *); |
| 144 |
int llm_node_cmp(llm_info_t *llm, int indx1, int indx2); |
| 145 |
const char* llm_get_nodename(llm_info_t *, const int ); |
| 146 |
int llm_status_update(llm_info_t *, const char *, |
| 147 |
const char *, char*); |
| 148 |
void llm_display(llm_info_t *llm); |
| 149 |
int llm_init(llm_info_t *); |
| 150 |
int llm_is_valid_node(llm_info_t *, const char *); |
| 151 |
int llm_add(llm_info_t *, const char *, const char *, const char * |
| 152 |
, const char *,int); |
| 153 |
int llm_del(llm_info_t* llm,const char* node); |
| 154 |
int llm_get_index(llm_info_t *, const char *); |
| 155 |
int llm_get_myindex(llm_info_t *); |
| 156 |
int llm_get_nodecount(llm_info_t* llm); |
| 157 |
const char* llm_get_mynodename(llm_info_t* llm); |
| 158 |
char* llm_get_nodestatus(llm_info_t* llm, const int index); |
| 159 |
int llm_set_joinrequest(llm_info_t* llm, int index, gboolean value, int ); |
| 160 |
gboolean llm_get_joinrequest(llm_info_t* llm, int index); |
| 161 |
gboolean llm_get_joinrequest_majortrans(llm_info_t* llm, int index); |
| 162 |
int llm_set_change(llm_info_t* llm, int index, gboolean value); |
| 163 |
gboolean llm_get_change(llm_info_t* llm, int index); |
| 164 |
int llm_set_uptime(llm_info_t* llm, int index, int uptime); |
| 165 |
int llm_get_uptime(llm_info_t* llm, int index); |
| 166 |
|
| 167 |
/* ccm prototypes */ |
| 168 |
longclock_t ccm_get_time(void); |
| 169 |
int ccm_timeout(longclock_t, longclock_t, unsigned long); |
| 170 |
int ccm_need_control(void *); |
| 171 |
int ccm_take_control(void *); |
| 172 |
void* ccm_initialize(void); |
| 173 |
void ccm_on_quorum_changed(void); |
| 174 |
IPC_Channel * ccm_get_ipcchan(void *); |
| 175 |
void ccm_send_init_state(void *); |
| 176 |
void ccm_check_memoryleak(void); |
| 177 |
|
| 178 |
/* BEGINING OF update interfaces */ |
| 179 |
/* structure that keeps track of new joining requests. */ |
| 180 |
typedef struct update_s { |
| 181 |
int index; /* index of the node in the ccm_llm table */ |
| 182 |
int uptime;/* uptime as specified by the node */ |
| 183 |
} update_t; |
| 184 |
|
| 185 |
typedef struct ccm_update_s { |
| 186 |
int leader; |
| 187 |
uint nodeCount; |
| 188 |
longclock_t inittime; |
| 189 |
update_t update[MAXNODE]; |
| 190 |
GSList *cl_head; /* a linked list of cached cluster leader */ |
| 191 |
/* requests */ |
| 192 |
} ccm_update_t; |
| 193 |
#define UPDATE_GET_LEADER(updt) updt->leader |
| 194 |
#define UPDATE_GET_NODECOUNT(updt) updt->nodeCount |
| 195 |
#define UPDATE_GET_INITTIME(updt) updt->inittime |
| 196 |
#define UPDATE_GET_INDEX(updt, i) updt->update[i].index |
| 197 |
#define UPDATE_GET_UPTIME(updt, i) updt->update[i].uptime |
| 198 |
#define UPDATE_GET_CLHEAD(updt) (updt)->cl_head |
| 199 |
#define UPDATE_SET_LEADER(updt, lead) updt->leader = lead |
| 200 |
#define UPDATE_SET_NODECOUNT(updt, count) updt->nodeCount = count |
| 201 |
#define UPDATE_SET_INITTIME(updt, time) updt->inittime = time |
| 202 |
#define UPDATE_SET_INDEX(updt, i, value) updt->update[i].index = value |
| 203 |
#define UPDATE_SET_UPTIME(updt, i, value) updt->update[i].uptime = value |
| 204 |
#define UPDATE_SET_CLHEAD(updt, ptr) (updt)->cl_head = ptr |
| 205 |
#define UPDATE_INCR_NODECOUNT(updt) (updt->nodeCount)++ |
| 206 |
#define UPDATE_DECR_NODECOUNT(updt) (updt->nodeCount)-- |
| 207 |
|
| 208 |
|
| 209 |
void update_add_memlist_request(ccm_update_t *, llm_info_t *, const char *, const int); |
| 210 |
void update_free_memlist_request(ccm_update_t *); |
| 211 |
void update_reset(ccm_update_t *); |
| 212 |
void update_init(ccm_update_t *); |
| 213 |
int update_timeout_expired(ccm_update_t *, unsigned long); |
| 214 |
void update_add(ccm_update_t *, llm_info_t *, const char *, int, gboolean); |
| 215 |
void update_remove(ccm_update_t *, llm_info_t *, const char *); |
| 216 |
int update_am_i_leader(ccm_update_t *, llm_info_t *); |
| 217 |
int update_can_be_leader(ccm_update_t *, llm_info_t *llm, const char *, int ); |
| 218 |
const char * update_get_cl_name(ccm_update_t *, llm_info_t *); |
| 219 |
void * update_initlink(ccm_update_t *); |
| 220 |
const char * update_next_link(ccm_update_t *, llm_info_t *, void *, uint *); |
| 221 |
void update_freelink(ccm_update_t *, void *); |
| 222 |
int update_get_next_index(ccm_update_t *, llm_info_t *, int *); |
| 223 |
int update_strcreate(ccm_update_t *tab, char *memlist,llm_info_t *llm); |
| 224 |
int update_is_node_updated(ccm_update_t *, llm_info_t *, const char *); |
| 225 |
int update_get_uptime(ccm_update_t *, llm_info_t *, int ); |
| 226 |
void update_display(int pri,llm_info_t* llm, ccm_update_t* tab); |
| 227 |
/* END OF update interfaces */ |
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
/* BEGINNING OF graph interfaces */ |
| 232 |
|
| 233 |
typedef struct vertex_s { |
| 234 |
char *bitmap; /* bitmap sent by each node */ |
| 235 |
int count; /* connectivity number for each node */ |
| 236 |
int uuid; /* the uuid of the node */ |
| 237 |
} vertex_t; |
| 238 |
|
| 239 |
typedef struct graph_s { |
| 240 |
vertex_t *graph_node[MAXNODE]; |
| 241 |
int graph_nodes;/* no of nodes that had sent the join message */ |
| 242 |
/* whose bitmaps we are now expecting */ |
| 243 |
int graph_rcvd; /* no of nodes that have sent a memlistbitmap */ |
| 244 |
} graph_t; |
| 245 |
graph_t * graph_init(void); |
| 246 |
void graph_free(graph_t *); |
| 247 |
void graph_add_uuid(graph_t *, int ); |
| 248 |
void graph_update_membership(graph_t *, int , char *); |
| 249 |
int graph_filled_all(graph_t *); |
| 250 |
int graph_get_maxclique(graph_t *, char **); |
| 251 |
void graph_add_to_membership(graph_t *, int, int); |
| 252 |
/* END OF graph interfaces */ |
| 253 |
|
| 254 |
|
| 255 |
/* BEGINNING OF bitmap interfaces */ |
| 256 |
int bitmap_create(char **, int); |
| 257 |
void bitmap_delete(char *); |
| 258 |
void bitmap_mark(int, char *, int); |
| 259 |
void bitmap_clear(int, char *, int); |
| 260 |
int bitmap_test(int, const char *, int); |
| 261 |
int bitmap_count(const char *, int); |
| 262 |
void bitmap_print(char *, int, char *); |
| 263 |
void bitmap_reset(char *, int); |
| 264 |
int bitmap_size(int); |
| 265 |
int bitmap_copy(char *, char *); |
| 266 |
/* END OF bitmap interfaces */ |
| 267 |
|
| 268 |
|
| 269 |
size_t strnlen(const char *, size_t); /*TOBEDONE*/ |
| 270 |
/* end ccm */ |
| 271 |
|
| 272 |
/* BEGINNING OF client management interfaces */ |
| 273 |
void client_init(void); |
| 274 |
int client_add(struct IPC_CHANNEL *); |
| 275 |
void client_delete(struct IPC_CHANNEL *); |
| 276 |
void client_delete_all(void); |
| 277 |
void client_llm_init(llm_info_t *); |
| 278 |
void client_influx(void); |
| 279 |
void client_evicted(void); |
| 280 |
/* END OF client management interfaces */ |
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
/* */ |
| 287 |
/* the various states of the CCM state machine. */ |
| 288 |
/* */ |
| 289 |
enum ccm_state { |
| 290 |
CCM_STATE_NONE=0, /* is in NULL state */ |
| 291 |
CCM_STATE_VERSION_REQUEST, /* sent a request for protocol version */ |
| 292 |
CCM_STATE_JOINING, /* has initiated a join protocol */ |
| 293 |
CCM_STATE_SENT_MEMLISTREQ, /* CL has sent a request for member list */ |
| 294 |
/* this state is applicable only on CL */ |
| 295 |
CCM_STATE_MEMLIST_RES, /* Responded member list to the Cluster */ |
| 296 |
/* Leader */ |
| 297 |
CCM_STATE_JOINED, /* PART of the CCM cluster membership! */ |
| 298 |
CCM_STATE_WAIT_FOR_MEM_LIST, |
| 299 |
CCM_STATE_WAIT_FOR_CHANGE, |
| 300 |
CCM_STATE_NEW_NODE_WAIT_FOR_MEM_LIST, |
| 301 |
CCM_STATE_END |
| 302 |
}; |
| 303 |
|
| 304 |
/* the times for repeating sending message */ |
| 305 |
#define REPEAT_TIMES 10 |
| 306 |
|
| 307 |
/* add new enums to this structure as and when new protocols are added */ |
| 308 |
enum ccm_protocol { |
| 309 |
CCM_VER_NONE = 0, |
| 310 |
CCM_VER_1, |
| 311 |
CCM_VER_LAST |
| 312 |
}; |
| 313 |
|
| 314 |
typedef struct ccm_proto_s { |
| 315 |
enum ccm_protocol com_hiproto;/* highest protocol version that */ |
| 316 |
/* this node can handle */ |
| 317 |
int com_active_proto;/* protocol version */ |
| 318 |
} ccm_proto_t; |
| 319 |
|
| 320 |
|
| 321 |
typedef struct memcomp_s { |
| 322 |
graph_t *mem_graph; /* memlist calculation graph */ |
| 323 |
|
| 324 |
GSList *mem_maxt; /* the maxtrans of each node */ |
| 325 |
/* participating in the computation . */ |
| 326 |
/* NOTE: the transition number of the */ |
| 327 |
/* next transition is always 1 higher */ |
| 328 |
/* than that of all transitions seen */ |
| 329 |
/* by each node participating in the */ |
| 330 |
/* membership */ |
| 331 |
longclock_t mem_inittime; /* the time got intialized */ |
| 332 |
} memcomp_t; |
| 333 |
#define MEMCOMP_GET_GRAPH(memc) memc->mem_graph |
| 334 |
#define MEMCOMP_GET_MAXT(memc) memc->mem_maxt |
| 335 |
#define MEMCOMP_GET_INITTIME(memc) memc->mem_inittime |
| 336 |
#define MEMCOMP_SET_GRAPH(memc, gr) memc->mem_graph=gr |
| 337 |
#define MEMCOMP_SET_MAXT(memc, list) memc->mem_maxt=list |
| 338 |
#define MEMCOMP_SET_INITTIME(memc,time) memc->mem_inittime=time |
| 339 |
|
| 340 |
#define CCM_SET_ACTIVEPROTO(info, val) \ |
| 341 |
info->ccm_active_proto = val |
| 342 |
#define CCM_SET_MAJORTRANS(info, val) \ |
| 343 |
{ \ |
| 344 |
info->ccm_transition_major = val; \ |
| 345 |
info->ccm_max_transition = \ |
| 346 |
(info->ccm_max_transition < val ? \ |
| 347 |
val: info->ccm_max_transition); \ |
| 348 |
} |
| 349 |
#define CCM_SET_MINORTRANS(info, val) \ |
| 350 |
info->ccm_transition_minor = val |
| 351 |
#define CCM_INIT_MAXTRANS(info) \ |
| 352 |
info->ccm_max_transition = 0 |
| 353 |
|
| 354 |
/* NOTE the reason the increment for majortrans is done */ |
| 355 |
/* as below is to force recomputation of ccm_max_transition */ |
| 356 |
#define CCM_INCREMENT_MAJORTRANS(info) \ |
| 357 |
CCM_SET_MAJORTRANS(info, \ |
| 358 |
CCM_GET_MAJORTRANS(info)+1) |
| 359 |
|
| 360 |
#define CCM_INCREMENT_MINORTRANS(info) \ |
| 361 |
info->ccm_transition_minor++ |
| 362 |
#define CCM_RESET_MAJORTRANS(info) \ |
| 363 |
info->ccm_transition_major = 0 |
| 364 |
#define CCM_RESET_MINORTRANS(info) \ |
| 365 |
info->ccm_transition_minor = 0 |
| 366 |
|
| 367 |
#define CCM_SET_JOINED_TRANSITION(info, trans) \ |
| 368 |
info->ccm_joined_transition = trans |
| 369 |
#define CCM_SET_COOKIE(info, val) \ |
| 370 |
strncpy(info->ccm_cookie, val, COOKIESIZE) |
| 371 |
#define CCM_SET_CL(info, index) info->ccm_cluster_leader = index |
| 372 |
|
| 373 |
|
| 374 |
#define CCM_GET_ACTIVEPROTO(info) info->ccm_active_proto |
| 375 |
#define CCM_GET_MAJORTRANS(info) info->ccm_transition_major |
| 376 |
#define CCM_GET_MINORTRANS(info) info->ccm_transition_minor |
| 377 |
#define CCM_GET_MAXTRANS(info) info->ccm_max_transition |
| 378 |
#define CCM_GET_STATE(info) info->state |
| 379 |
#define CCM_GET_HIPROTO(info) info->ccm_hiproto |
| 380 |
#define CCM_GET_LLM(info) (&(info->llm)) |
| 381 |
#define CCM_GET_UPDATETABLE(info) (&(info->ccm_update)) |
| 382 |
#define CCM_GET_MEMCOMP(info) (&(info->ccm_memcomp)) |
| 383 |
#define CCM_GET_JOINED_TRANSITION(info) info->ccm_joined_transition |
| 384 |
#define CCM_GET_LLM_NODECOUNT(info) llm_get_nodecount(&info->llm) |
| 385 |
#define CCM_GET_MY_HOSTNAME(info) ccm_get_my_hostname(info) |
| 386 |
#define CCM_GET_COOKIE(info) info->ccm_cookie |
| 387 |
|
| 388 |
#define CCM_GET_MEMINDEX(info, i) info->ccm_member[i] |
| 389 |
#define CCM_GET_MEMTABLE(info) info->ccm_member |
| 390 |
#define CCM_GET_CL(info) info->ccm_cluster_leader |
| 391 |
#define CCM_TRANS_EARLIER(trans1, trans2) (trans1 < trans2) /*TOBEDONE*/ |
| 392 |
#define CCM_GET_VERSION(info) &(info->ccm_version) |
| 393 |
|
| 394 |
|
| 395 |
#define CCM_TMOUT_SET_U(info,t) info->tmout.u=t |
| 396 |
#define CCM_TMOUT_SET_LU(info,t) info->tmout.lu=t |
| 397 |
#define CCM_TMOUT_SET_VRS(info,t) info->tmout.vrs=t |
| 398 |
#define CCM_TMOUT_SET_ITF(info,t) info->tmout.itf=t |
| 399 |
#define CCM_TMOUT_SET_IFF(info,t) info->tmout.iff=t |
| 400 |
#define CCM_TMOUT_SET_FL(info,t) info->tmout.fl=t |
| 401 |
#define CCM_TMOUT_GET_U(info) info->tmout.u |
| 402 |
#define CCM_TMOUT_GET_LU(info) info->tmout.lu |
| 403 |
#define CCM_TMOUT_GET_VRS(info) info->tmout.vrs |
| 404 |
#define CCM_TMOUT_GET_ITF(info) info->tmout.itf |
| 405 |
#define CCM_TMOUT_GET_IFF(info) info->tmout.iff |
| 406 |
#define CCM_TMOUT_GET_FL(info) info->tmout.fl |
| 407 |
|
| 408 |
typedef struct ccm_tmout_s { |
| 409 |
long iff; /* membership_Info_From_Followers_timeout */ |
| 410 |
long itf; /* membership_Info_To_Followers_timeout */ |
| 411 |
long fl; /* membership_Final_List_timeout */ |
| 412 |
long u; /* update timeout */ |
| 413 |
long lu; /* long update timeout */ |
| 414 |
long vrs; /* version timeout */ |
| 415 |
} ccm_tmout_t; |
| 416 |
|
| 417 |
enum change_event_type{ |
| 418 |
TYPE_NONE, |
| 419 |
NODE_LEAVE, |
| 420 |
NEW_NODE |
| 421 |
}; |
| 422 |
|
| 423 |
#define COOKIESIZE 15 |
| 424 |
typedef struct ccm_info_s { |
| 425 |
llm_info_t llm; /* low level membership info */ |
| 426 |
|
| 427 |
int memcount; /* number of nodes in the ccm cluster */ |
| 428 |
int ccm_member[MAXNODE];/* members of the ccm cluster */ |
| 429 |
memcomp_t ccm_memcomp; /* the datastructure to compute the */ |
| 430 |
/* final membership for each membership */ |
| 431 |
/* computation instance of the ccm protocol. */ |
| 432 |
/* used by the leader only. */ |
| 433 |
|
| 434 |
ccm_proto_t ccm_proto; /* protocol version information */ |
| 435 |
#define ccm_active_proto ccm_proto.com_active_proto |
| 436 |
#define ccm_hiproto ccm_proto.com_hiproto |
| 437 |
|
| 438 |
char ccm_cookie[COOKIESIZE];/* context identification string. */ |
| 439 |
uint32_t ccm_transition_major;/* transition number of the cluster */ |
| 440 |
int ccm_cluster_leader; /* cluster leader of the last major */ |
| 441 |
/* transition. index of cl in ccm_member table */ |
| 442 |
int ccm_joined_transition; |
| 443 |
/* this indicates the major transition */ |
| 444 |
/* number during which this node became */ |
| 445 |
/* a member of the cluster. */ |
| 446 |
/* A sideeffect of this is it also */ |
| 447 |
/* is used to figure out if this node */ |
| 448 |
/* was ever a part of the cluster. */ |
| 449 |
/* Should be intially set to 0 */ |
| 450 |
uint32_t ccm_max_transition; /* the maximum transition number seen */ |
| 451 |
/* by this node ever since it was born. */ |
| 452 |
enum ccm_state state; /* cluster state of this node */ |
| 453 |
uint32_t ccm_transition_minor;/* minor transition number of the */ |
| 454 |
/* cluster */ |
| 455 |
|
| 456 |
ccm_update_t ccm_update; /* structure that keeps track */ |
| 457 |
/* of uptime of each member */ |
| 458 |
ccm_version_t ccm_version; /* keeps track of version request */ |
| 459 |
/* related info */ |
| 460 |
ccm_tmout_t tmout; |
| 461 |
uint32_t change_event_remaining_count; |
| 462 |
enum change_event_type change_type; |
| 463 |
char change_node_id[NODEIDSIZE]; |
| 464 |
char cluster[PATH_MAX]; |
| 465 |
char quorum_server[PATH_MAX]; |
| 466 |
int has_quorum; /* -1, not set, 0, no quorum, 1, has quorum */ |
| 467 |
} ccm_info_t; |
| 468 |
|
| 469 |
/* |
| 470 |
* datastructure passed to the event loop. |
| 471 |
* This acts a handle, and should not be interpreted |
| 472 |
* by the event loop. |
| 473 |
*/ |
| 474 |
typedef struct ccm_s { |
| 475 |
ll_cluster_t *hbfd; |
| 476 |
void *info; |
| 477 |
} ccm_t; |
| 478 |
|
| 479 |
|
| 480 |
void client_new_mbrship(ccm_info_t*, void*); |
| 481 |
void ccm_reset(ccm_info_t *info); |
| 482 |
const char* state2string(int state); |
| 483 |
int ccm_control_process(ccm_info_t *info, ll_cluster_t * hb); |
| 484 |
int jump_to_joining_state(ll_cluster_t* hb, |
| 485 |
ccm_info_t* info, |
| 486 |
struct ha_msg* msg); |
| 487 |
gboolean ccm_calculate_quorum(ccm_info_t* info); |
| 488 |
gboolean ccm_stop_query_quorum(void); |
| 489 |
|
| 490 |
typedef void (*state_msg_handler_t)(enum ccm_type ccm_msg_type, |
| 491 |
struct ha_msg *reply, |
| 492 |
ll_cluster_t *hb, |
| 493 |
ccm_info_t *info); |
| 494 |
|
| 495 |
#define ccm_log(priority, fmt...); \ |
| 496 |
cl_log(priority, fmt); \ |
| 497 |
|
| 498 |
#define ccm_debug(priority, fmt...); \ |
| 499 |
if ( debug_level >= 1 ) { \ |
| 500 |
cl_log(priority, fmt); \ |
| 501 |
} |
| 502 |
|
| 503 |
#define ccm_debug2(priority, fmt...); \ |
| 504 |
if ( debug_level >= 2 ) { \ |
| 505 |
cl_log(priority, fmt); \ |
| 506 |
} |
| 507 |
|
| 508 |
#define ccm_message_debug2(priority,msg); \ |
| 509 |
if ( debug_level >= 2) { \ |
| 510 |
cl_log_message(priority, msg); \ |
| 511 |
} |
| 512 |
|
| 513 |
#endif |