pacemaker  2.0.5-ba59be712
Scalable High-Availability cluster resource manager
Macros | Functions | Variables
membership.c File Reference
#include <crm_internal.h>
#include <sys/param.h>
#include <sys/types.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <glib.h>
#include <crm/common/ipc.h>
#include <crm/cluster/internal.h>
#include <crm/msg_xml.h>
#include <crm/stonith-ng.h>
Include dependency graph for membership.c:

Go to the source code of this file.

Macros

#define _GNU_SOURCE
 
#define XPATH_GUEST_NODE_CONFIG
 
#define XPATH_REMOTE_NODE_CONFIG
 
#define XPATH_REMOTE_NODE_STATUS
 
#define XPATH_MEMBER_NODE_CONFIG
 

Functions

int crm_remote_peer_cache_size (void)
 
crm_node_tcrm_remote_peer_get (const char *node_name)
 Get a remote node peer cache entry, creating it if necessary. More...
 
void crm_remote_peer_cache_remove (const char *node_name)
 
void crm_remote_peer_cache_refresh (xmlNode *cib)
 Repopulate the remote peer cache based on CIB XML. More...
 
gboolean crm_is_peer_active (const crm_node_t *node)
 
guint reap_crm_member (uint32_t id, const char *name)
 Remove all peer cache entries matching a node ID and/or uname. More...
 
guint crm_active_peers (void)
 
void crm_peer_init (void)
 
void crm_peer_destroy (void)
 
void crm_set_status_callback (void(*dispatch)(enum crm_status_type, crm_node_t *, const void *))
 Set a client function that will be called after peer status changes. More...
 
void crm_set_autoreap (gboolean autoreap)
 Tell the library whether to automatically reap lost nodes. More...
 
crm_node_tcrm_find_peer_full (unsigned int id, const char *uname, int flags)
 
crm_node_tcrm_get_peer_full (unsigned int id, const char *uname, int flags)
 
crm_node_tcrm_find_peer (unsigned int id, const char *uname)
 
crm_node_tcrm_get_peer (unsigned int id, const char *uname)
 
void crm_update_peer_uname (crm_node_t *node, const char *uname)
 
crm_node_tcrm_update_peer_proc (const char *source, crm_node_t *node, uint32_t flag, const char *status)
 
void crm_update_peer_expected (const char *source, crm_node_t *node, const char *expected)
 
crm_node_tcrm_update_peer_state (const char *source, crm_node_t *node, const char *state, uint64_t membership)
 Update a node's state and membership information. More...
 
void crm_reap_unseen_nodes (uint64_t membership)
 
int crm_terminate_member (int nodeid, const char *uname, void *unused)
 
int crm_terminate_member_no_mainloop (int nodeid, const char *uname, int *connection)
 
void crm_peer_caches_refresh (xmlNode *cib)
 
crm_node_tcrm_find_known_peer_full (unsigned int id, const char *uname, int flags)
 

Variables

GHashTable * crm_peer_cache = NULL
 
GHashTable * crm_remote_peer_cache = NULL
 
GHashTable * crm_known_peer_cache = NULL
 
unsigned long long crm_peer_seq = 0
 
gboolean crm_have_quorum = FALSE
 
void(* crm_status_callback )(enum crm_status_type, crm_node_t *, const void *) = NULL
 

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

Definition at line 13 of file membership.c.

◆ XPATH_GUEST_NODE_CONFIG

#define XPATH_GUEST_NODE_CONFIG
Value:
"[@name='" XML_RSC_ATTR_REMOTE_NODE "']"
#define XML_CIB_TAG_NVPAIR
Definition: msg_xml.h:167
#define XML_CIB_TAG_RESOURCE
Definition: msg_xml.h:181
#define XML_TAG_META_SETS
Definition: msg_xml.h:171
#define XML_RSC_ATTR_REMOTE_NODE
Definition: msg_xml.h:215
#define XML_TAG_CIB
Definition: msg_xml.h:76
#define XML_CIB_TAG_CONFIGURATION
Definition: msg_xml.h:145

Definition at line 213 of file membership.c.

◆ XPATH_MEMBER_NODE_CONFIG

#define XPATH_MEMBER_NODE_CONFIG
Value:
"/" XML_CIB_TAG_NODE "[not(@type) or @type='member']"
#define XML_CIB_TAG_NODES
Definition: msg_xml.h:148
#define XML_CIB_TAG_NODE
Definition: msg_xml.h:166
#define XML_TAG_CIB
Definition: msg_xml.h:76
#define XML_CIB_TAG_CONFIGURATION
Definition: msg_xml.h:145

Definition at line 1144 of file membership.c.

◆ XPATH_REMOTE_NODE_CONFIG

#define XPATH_REMOTE_NODE_CONFIG
Value:
"[@type='remote'][@provider='pacemaker']"
#define XML_CIB_TAG_RESOURCE
Definition: msg_xml.h:181
#define XML_TAG_CIB
Definition: msg_xml.h:76
#define XML_CIB_TAG_CONFIGURATION
Definition: msg_xml.h:145

Definition at line 219 of file membership.c.

◆ XPATH_REMOTE_NODE_STATUS

#define XPATH_REMOTE_NODE_STATUS
Value:
"[@" XML_NODE_IS_REMOTE "='true']"
#define XML_CIB_TAG_STATE
Definition: msg_xml.h:165
#define XML_NODE_IS_REMOTE
Definition: msg_xml.h:249
#define XML_TAG_CIB
Definition: msg_xml.h:76
#define XML_CIB_TAG_STATUS
Definition: msg_xml.h:146

Definition at line 224 of file membership.c.

Function Documentation

◆ crm_active_peers()

guint crm_active_peers ( void  )

Definition at line 365 of file membership.c.

◆ crm_find_known_peer_full()

crm_node_t* crm_find_known_peer_full ( unsigned int  id,
const char *  uname,
int  flags 
)

Definition at line 1170 of file membership.c.

◆ crm_find_peer()

crm_node_t* crm_find_peer ( unsigned int  id,
const char *  uname 
)

Definition at line 522 of file membership.c.

◆ crm_find_peer_full()

crm_node_t* crm_find_peer_full ( unsigned int  id,
const char *  uname,
int  flags 
)

Definition at line 484 of file membership.c.

◆ crm_get_peer()

crm_node_t* crm_get_peer ( unsigned int  id,
const char *  uname 
)

Definition at line 654 of file membership.c.

◆ crm_get_peer_full()

crm_node_t* crm_get_peer_full ( unsigned int  id,
const char *  uname,
int  flags 
)

Definition at line 503 of file membership.c.

◆ crm_is_peer_active()

gboolean crm_is_peer_active ( const crm_node_t node)

Definition at line 272 of file membership.c.

◆ crm_peer_caches_refresh()

void crm_peer_caches_refresh ( xmlNode *  cib)

Definition at line 1163 of file membership.c.

◆ crm_peer_destroy()

void crm_peer_destroy ( void  )

Definition at line 406 of file membership.c.

◆ crm_peer_init()

void crm_peer_init ( void  )

Definition at line 390 of file membership.c.

◆ crm_reap_unseen_nodes()

void crm_reap_unseen_nodes ( uint64_t  membership)

Definition at line 990 of file membership.c.

◆ crm_remote_peer_cache_refresh()

void crm_remote_peer_cache_refresh ( xmlNode *  cib)

Repopulate the remote peer cache based on CIB XML.

Parameters
[in]xmlNodeCIB XML to parse

Definition at line 234 of file membership.c.

◆ crm_remote_peer_cache_remove()

void crm_remote_peer_cache_remove ( const char *  node_name)

Definition at line 120 of file membership.c.

◆ crm_remote_peer_cache_size()

int crm_remote_peer_cache_size ( void  )

Definition at line 60 of file membership.c.

◆ crm_remote_peer_get()

crm_node_t* crm_remote_peer_get ( const char *  node_name)

Get a remote node peer cache entry, creating it if necessary.

Parameters
[in]node_nameName of remote node
Returns
Cache entry for node on success, NULL (and set errno) otherwise
Note
When creating a new entry, this will leave the node state undetermined, so the caller should also call crm_update_peer_state() if the state is known.

Definition at line 80 of file membership.c.

◆ crm_set_autoreap()

void crm_set_autoreap ( gboolean  autoreap)

Tell the library whether to automatically reap lost nodes.

If TRUE (the default), calling crm_update_peer_proc() will also update the peer state to CRM_NODE_MEMBER or CRM_NODE_LOST, and crm_update_peer_state() will reap peers whose state changes to anything other than CRM_NODE_MEMBER. Callers should leave this enabled unless they plan to manage the cache separately on their own.

Parameters
[in]autoreapTRUE to enable automatic reaping, FALSE to disable

Definition at line 458 of file membership.c.

◆ crm_set_status_callback()

void crm_set_status_callback ( void(*)(enum crm_status_type, crm_node_t *, const void *)  dispatch)

Set a client function that will be called after peer status changes.

Parameters
[in]dispatchPointer to function to use as callback
Note
Previously, client callbacks were responsible for peer cache management. This is no longer the case, and client callbacks should do only client-specific handling. Callbacks MUST NOT add or remove entries in the peer caches.

Definition at line 441 of file membership.c.

◆ crm_terminate_member()

int crm_terminate_member ( int  nodeid,
const char *  uname,
void *  unused 
)

Definition at line 1017 of file membership.c.

◆ crm_terminate_member_no_mainloop()

int crm_terminate_member_no_mainloop ( int  nodeid,
const char *  uname,
int *  connection 
)

Definition at line 1024 of file membership.c.

◆ crm_update_peer_expected()

void crm_update_peer_expected ( const char *  source,
crm_node_t node,
const char *  expected 
)

Definition at line 864 of file membership.c.

◆ crm_update_peer_proc()

crm_node_t* crm_update_peer_proc ( const char *  source,
crm_node_t node,
uint32_t  flag,
const char *  status 
)

Definition at line 786 of file membership.c.

◆ crm_update_peer_state()

crm_node_t* crm_update_peer_state ( const char *  source,
crm_node_t node,
const char *  state,
uint64_t  membership 
)

Update a node's state and membership information.

Parameters
[in]sourceCaller's function name (for log messages)
[in]nodeNode object to update
[in]stateNode's new state
[in]membershipNode's new membership ID
Returns
NULL if any node was reaped, value of node otherwise
Note
If this function returns NULL, the supplied node object was likely freed and should not be used again. This function should not be called within a cache iteration if reaping is possible, otherwise reaping could invalidate the iterator.

Definition at line 978 of file membership.c.

◆ crm_update_peer_uname()

void crm_update_peer_uname ( crm_node_t node,
const char *  uname 
)

Definition at line 733 of file membership.c.

◆ reap_crm_member()

guint reap_crm_member ( uint32_t  id,
const char *  name 
)

Remove all peer cache entries matching a node ID and/or uname.

Parameters
[in]idID of node to remove (or 0 to ignore)
[in]nameUname of node to remove (or NULL to ignore)
Returns
Number of cache entries removed

Definition at line 324 of file membership.c.

Variable Documentation

◆ crm_have_quorum

gboolean crm_have_quorum = FALSE

Definition at line 56 of file membership.c.

◆ crm_known_peer_cache

GHashTable* crm_known_peer_cache = NULL

Definition at line 53 of file membership.c.

◆ crm_peer_cache

GHashTable* crm_peer_cache = NULL

Definition at line 34 of file membership.c.

◆ crm_peer_seq

unsigned long long crm_peer_seq = 0

Definition at line 55 of file membership.c.

◆ crm_remote_peer_cache

GHashTable* crm_remote_peer_cache = NULL

Definition at line 51 of file membership.c.

◆ crm_status_callback

void(* crm_status_callback) (enum crm_status_type, crm_node_t *, const void *) = NULL

Definition at line 428 of file membership.c.