pacemaker  2.1.3-ea053b43a
Scalable High-Availability cluster resource manager
Macros | Typedefs | Functions | Variables
cpg.c File Reference
#include <crm_internal.h>
#include <bzlib.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <crm/common/ipc.h>
#include <crm/cluster/internal.h>
#include <crm/common/mainloop.h>
#include <sys/utsname.h>
#include <qb/qbipc_common.h>
#include <qb/qbipcc.h>
#include <qb/qbutil.h>
#include <corosync/corodefs.h>
#include <corosync/corotypes.h>
#include <corosync/hdb.h>
#include <corosync/cpg.h>
#include <crm/msg_xml.h>
#include <crm/common/ipc_internal.h>
#include "crmcluster_private.h"
Include dependency graph for cpg.c:

Go to the source code of this file.

Macros

#define msg_data_len(msg)   (msg->is_compressed?msg->compressed_size:msg->size)
 
#define cs_repeat(rc, counter, max, code)
 
#define CS_SEND_MAX   200
 

Typedefs

typedef struct pcmk__cpg_host_s pcmk__cpg_host_t
 
typedef struct pcmk__cpg_msg_s pcmk__cpg_msg_t
 

Functions

struct pcmk__cpg_host_s __attribute__ ((packed))
 
struct qb_ipc_response_header header __attribute__ ((aligned(8)))
 
void cluster_disconnect_cpg (crm_cluster_t *cluster)
 Disconnect from Corosync CPG. More...
 
uint32_t get_local_nodeid (cpg_handle_t handle)
 Get the local Corosync node ID (via CPG) More...
 
char * pcmk_message_common_cs (cpg_handle_t handle, uint32_t nodeid, uint32_t pid, void *content, uint32_t *kind, const char **from)
 Extract text data from a Corosync CPG message. More...
 
void pcmk_cpg_membership (cpg_handle_t handle, const struct cpg_name *groupName, const struct cpg_address *member_list, size_t member_list_entries, const struct cpg_address *left_list, size_t left_list_entries, const struct cpg_address *joined_list, size_t joined_list_entries)
 Handle a CPG configuration change event. More...
 
gboolean cluster_connect_cpg (crm_cluster_t *cluster)
 Connect to Corosync CPG. More...
 
gboolean pcmk__cpg_send_xml (xmlNode *msg, crm_node_t *node, enum crm_ais_msg_types dest)
 
gboolean send_cluster_text (enum crm_ais_msg_class msg_class, const char *data, gboolean local, crm_node_t *node, enum crm_ais_msg_types dest)
 
enum crm_ais_msg_types text2msg_type (const char *text)
 Get the message type equivalent of a string. More...
 

Variables

uint32_t id
 
uint32_t pid
 
gboolean local
 
enum crm_ais_msg_types type
 
uint32_t size
 
char uname [MAX_NAME]
 
gboolean is_compressed
 
pcmk__cpg_host_t host
 
pcmk__cpg_host_t sender
 
uint32_t compressed_size
 
char data [0]
 

Macro Definition Documentation

◆ cs_repeat

#define cs_repeat (   rc,
  counter,
  max,
  code 
)
Value:
do { \
rc = code; \
if ((rc == CS_ERR_TRY_AGAIN) || (rc == CS_ERR_QUEUE_FULL)) { \
counter++; \
crm_debug("Retrying operation after %ds", counter); \
sleep(counter); \
} else { \
break; \
} \
} while (counter < max)

Definition at line 78 of file cpg.c.

◆ CS_SEND_MAX

#define CS_SEND_MAX   200

Definition at line 202 of file cpg.c.

◆ msg_data_len

#define msg_data_len (   msg)    (msg->is_compressed?msg->compressed_size:msg->size)

Definition at line 76 of file cpg.c.

Typedef Documentation

◆ pcmk__cpg_host_t

typedef struct pcmk__cpg_host_s pcmk__cpg_host_t

Definition at line 55 of file cpg.c.

◆ pcmk__cpg_msg_t

typedef struct pcmk__cpg_msg_s pcmk__cpg_msg_t

Definition at line 72 of file cpg.c.

Function Documentation

◆ __attribute__() [1/2]

struct pcmk__cpg_host_s __attribute__ ( (packed)  )

◆ __attribute__() [2/2]

struct qb_ipc_response_header header __attribute__::__attribute__ ( (aligned(8))  )

◆ cluster_connect_cpg()

gboolean cluster_connect_cpg ( crm_cluster_t cluster)

Connect to Corosync CPG.

Parameters
[in]clusterCluster object
Returns
TRUE on success, otherwise FALSE

Definition at line 785 of file cpg.c.

◆ cluster_disconnect_cpg()

void cluster_disconnect_cpg ( crm_cluster_t cluster)

Disconnect from Corosync CPG.

Parameters
[in]Clusterto disconnect

Definition at line 95 of file cpg.c.

◆ get_local_nodeid()

uint32_t get_local_nodeid ( cpg_handle_t  handle)

Get the local Corosync node ID (via CPG)

Parameters
[in]handleCPG connection to use (or 0 to use new connection)
Returns
Corosync ID of local node (or 0 if not known)

Definition at line 117 of file cpg.c.

◆ pcmk__cpg_send_xml()

gboolean pcmk__cpg_send_xml ( xmlNode *  msg,
crm_node_t node,
enum crm_ais_msg_types  dest 
)

Definition at line 892 of file cpg.c.

◆ pcmk_cpg_membership()

void pcmk_cpg_membership ( cpg_handle_t  handle,
const struct cpg_name *  groupName,
const struct cpg_address *  member_list,
size_t  member_list_entries,
const struct cpg_address *  left_list,
size_t  left_list_entries,
const struct cpg_address *  joined_list,
size_t  joined_list_entries 
)

Handle a CPG configuration change event.

Parameters
[in]handleCPG connection
[in]cpg_nameCPG group name
[in]member_listList of current CPG members
[in]member_list_entriesNumber of entries in member_list
[in]left_listList of CPG members that left
[in]left_list_entriesNumber of entries in left_list
[in]joined_listList of CPG members that joined
[in]joined_list_entriesNumber of entries in joined_list

Definition at line 687 of file cpg.c.

◆ pcmk_message_common_cs()

char* pcmk_message_common_cs ( cpg_handle_t  handle,
uint32_t  nodeid,
uint32_t  pid,
void *  content,
uint32_t *  kind,
const char **  from 
)

Extract text data from a Corosync CPG message.

Parameters
[in]handleCPG connection (to get local node ID if not yet known)
[in]nodeidCorosync ID of node that sent message
[in]pidProcess ID of message sender (for logging only)
[in]contentCPG message
[out]kindIf not NULL, will be set to CPG header ID (which should be an enum crm_ais_msg_class value, currently always crm_class_cluster)
[out]fromIf not NULL, will be set to sender uname (valid for the lifetime of content)
Returns
Newly allocated string with message data
Note
It is the caller's responsibility to free the return value with free().

Definition at line 441 of file cpg.c.

◆ send_cluster_text()

gboolean send_cluster_text ( enum crm_ais_msg_class  msg_class,
const char *  data,
gboolean  local,
crm_node_t node,
enum crm_ais_msg_types  dest 
)

Definition at line 916 of file cpg.c.

◆ text2msg_type()

enum crm_ais_msg_types text2msg_type ( const char *  text)

Get the message type equivalent of a string.

Parameters
[in]textString of message type
Returns
Message type equivalent of text

Definition at line 1053 of file cpg.c.

Variable Documentation

◆ compressed_size

uint32_t compressed_size

Definition at line 53 of file cpg.c.

◆ data

char data[0]

Definition at line 55 of file cpg.c.

◆ host

Definition at line 49 of file cpg.c.

◆ id

uint32_t id

Definition at line 45 of file cpg.c.

◆ is_compressed

gboolean is_compressed

Definition at line 47 of file cpg.c.

◆ local

gboolean local

Definition at line 47 of file cpg.c.

◆ pid

uint32_t pid

Definition at line 46 of file cpg.c.

◆ sender

Definition at line 50 of file cpg.c.

◆ size

uint32_t size

Definition at line 49 of file cpg.c.

◆ type

enum crm_ais_msg_types type

Definition at line 48 of file cpg.c.

◆ uname

char uname[MAX_NAME]

Definition at line 50 of file cpg.c.