1CPG_MODEL_INITIALIZCEo(r3o)sync Cluster Engine Programmer's MCaPnGu_aMlODEL_INITIALIZE(3)
2
3
4
6 cpg_model_initialize - Create a new connection to the CPG service
7
9 #include <corosync/cpg.h>
10
11 cs_error_t cpg_model_initialize(cpg_handle_t *handle, cpg_model_t
12 model, cpg_model_data_t *model_data, void *context);
13
14
16 The cpg_model_initialize function is used to initialize a connection to
17 the closed process groups API.
18
19 Each application may have several connections to the CPG API. Each
20 application uses the handle argument to uniquely identify the connec‐
21 tion. The handle argument is then used in other function calls to
22 identify the connection to be used for communication with the CPG ser‐
23 vice.
24
25 Argument model is used to explicitly choose set of callbacks and inter‐
26 nal parameters. Currently only model CPG_MODEL_V1 is defined.
27
28 Callbacks and internal parameters are passed by model_data argument.
29 This is casted pointer (idea is similar as in sockaddr function) to one
30 of structures corresponding to chosen model. Currently only
31 cpg_model_v1_data_t is needed.
32
34 The MODEL_V1 is backwards compatible with original callbacks initial‐
35 ized by cpg_initialize but new callback cpg_totem_confchg_fn is
36 defined.
37
38 Every time an CPG event occurs within the joined group, one of the
39 callbacks specified by the argument callbacks is called. The callback
40 functions are described by the following type definitions:
41
42 typedef void (*cpg_deliver_fn_t) (
43 cpg_handle_t handle,
44 const struct cpg_name *group_name,
45 uint32_t nodeid,
46 uint32_t pid,
47 const void *msg,
48 size_t msg_len);
49
50
51 typedef void (*cpg_confchg_fn_t) (
52 cpg_handle_t handle,
53 const struct cpg_name *group_name,
54 const struct cpg_address *member_list, size_t member_list_entries,
55 const struct cpg_address *left_list, size_t left_list_entries,
56 const struct cpg_address *joined_list, size_t joined_list_entries);
57
58
59 typedef void (*cpg_totem_confchg_fn_t) (
60 cpg_handle_t handle,
61 struct cpg_ring_id ring_id,
62 uint32_t member_list_entries,
63 const uint32_t *member_list);
64
65 The cpg_model_v1_data_t structure is defined as:
66
67 typedef struct {
68 cpg_model_t model;
69 cpg_deliver_fn_t cpg_deliver_fn;
70 cpg_confchg_fn_t cpg_confchg_fn;
71 cpg_totem_confchg_fn_t cpg_totem_confchg_fn;
72 unsigned int flags;
73 } cpg_model_v1_data_t;
74
75 When a configuration change occurs or a message is to be delivered one
76 of the callbacks is called from the cpg_dispatch() function. If a con‐
77 figuration change occurs, cpg_confchg_fn is called. If a delivery of a
78 message occurs, cpg_deliver_fn is called. When totem membership change
79 occurs, cpg_totem_confchg_fn is called. You can OR
80 CPG_MODEL_V1_DELIVER_INITIAL_TOTEM_CONF constant to flags to get call‐
81 back after first confchg event.
82
83 The cpg_address structure is defined
84
85 struct cpg_address {
86 unsigned int nodeid;
87 unsigned int pid;
88 unsigned int reason;
89 };
90
91 where nodeid is a 32 bit unique node identifier, pid is the process ID
92 of the process that has joined/left the group or sent the message, and
93 reason is an integer code indicating why the node joined/left the
94 group.
95
96 CPG_REASON_JOIN - the process joined a group using cpg_join().
97 CPG_REASON_LEAVE - the process left a group using cpg_leave()
98 CPG_REASON_NODEDOWN - the process left a group because the node left the cluster.
99 CPG_REASON_NODEUP - the process joined a group because it was already a member of a group on a node that has just joined the cluster
100 CPG_REASON_PROCDOWN - the process left a group without calling cpg_leave()
101
102 The cpg_ring_id structure is defined
103
104 struct cpg_ring_id {
105 uint32_t nodeid;
106 uint64_t seq;
107 };
108
109 where nodeid is if of node of current Totem leader and seq is increas‐
110 ing number.
111
112
114 This call returns the CS_OK value if successful, otherwise an error is
115 returned.
116
118 The errors are undocumented.
119
121 cpg_overview(3), cpg_initialize(3), cpg_finalize(3), cpg_fd_get(3),
122 cpg_dispatch(3), cpg_join(3), cpg_leave(3), cpg_mcast_joined(3),
123 cpg_membership_get(3) cpg_zcb_alloc(3) cpg_zcb_free(3)
124 cpg_zcb_mcast_joined(3) cpg_context_get(3) cpg_context_set(3)
125 cpg_local_get(3) cpg_model_initialize(3)
126
127
128 CS_ERR_TRY_AGAIN Resource temporarily unavailable
129
130 CS_ERR_INVALID_PARAM Invalid argument
131
132 CS_ERR_ACCESS Permission denied
133
134 CS_ERR_LIBRARY The connection failed
135
136 CS_ERR_INTERRUPT System call interrupted by a signal
137
138 CS_ERR_NOT_SUPPORTED The requested protocol/functionality not supported
139
140 CS_ERR_MESSAGE_ERROR Incorrect auth message received
141
142 CS_ERR_NO_MEMORY Not enough memory to complete the requested task
143
144
145
146corosync Man Page 2010-04-07 CPG_MODEL_INITIALIZE(3)