cpg_model_initialize.3.in 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. .\"/*
  2. .\" * Copyright (c) 2010 Red Hat, Inc.
  3. .\" *
  4. .\" * All rights reserved.
  5. .\" *
  6. .\" * Author: Jan Friesse <jfriesse@redhat.com>
  7. .\" * Author: Christine Caulfield <ccaulfie@redhat.com>
  8. .\" *
  9. .\" * This software licensed under BSD license, the text of which follows:
  10. .\" *
  11. .\" * Redistribution and use in source and binary forms, with or without
  12. .\" * modification, are permitted provided that the following conditions are met:
  13. .\" *
  14. .\" * - Redistributions of source code must retain the above copyright notice,
  15. .\" * this list of conditions and the following disclaimer.
  16. .\" * - Redistributions in binary form must reproduce the above copyright notice,
  17. .\" * this list of conditions and the following disclaimer in the documentation
  18. .\" * and/or other materials provided with the distribution.
  19. .\" * - Neither the name of the MontaVista Software, Inc. nor the names of its
  20. .\" * contributors may be used to endorse or promote products derived from this
  21. .\" * software without specific prior written permission.
  22. .\" *
  23. .\" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  24. .\" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  25. .\" * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  26. .\" * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  27. .\" * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  28. .\" * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  29. .\" * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  30. .\" * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  31. .\" * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  32. .\" * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  33. .\" * THE POSSIBILITY OF SUCH DAMAGE.
  34. .\" */
  35. .TH CPG_MODEL_INITIALIZE 3 2010-04-07 "corosync Man Page" "Corosync Cluster Engine Programmer's Manual"
  36. .SH NAME
  37. cpg_model_initialize \- Create a new connection to the CPG service
  38. .SH SYNOPSIS
  39. .B #include <corosync/cpg.h>
  40. .sp
  41. .BI "cs_error_t cpg_model_initialize(cpg_handle_t *" handle ", cpg_model_t " model ", cpg_model_data_t *" model_data ", void *" context ");
  42. .SH DESCRIPTION
  43. The
  44. .B cpg_model_initialize
  45. function is used to initialize a connection to the closed process groups API.
  46. .PP
  47. Each application may have several connections to the CPG API. Each application
  48. uses the
  49. .I handle
  50. argument to uniquely identify the connection. The
  51. .I handle
  52. argument is then used in other function calls to identify the connection to be used
  53. for communication with the CPG service.
  54. .PP
  55. Argument
  56. .I model
  57. is used to explicitly choose set of callbacks and internal parameters. Currently only model
  58. .I CPG_MODEL_V1
  59. is defined.
  60. .PP
  61. Callbacks and internal parameters are passed by
  62. .I model_data
  63. argument. This is casted pointer (idea is similar as in sockaddr function) to one of structures
  64. corresponding to chosen model. Currently only
  65. .I cpg_model_v1_data_t
  66. is needed.
  67. .SH MODEL_V1
  68. The
  69. .I MODEL_V1
  70. is backwards compatible with original callbacks initialized by
  71. .I cpg_initialize
  72. but new callback
  73. .I cpg_totem_confchg_fn
  74. is defined.
  75. .PP
  76. Every time an CPG event occurs within the joined group, one of the callbacks specified by the argument
  77. .I callbacks
  78. is called. The callback functions are described by the following type definitions:
  79. .PP
  80. .PP
  81. .IP
  82. .RS
  83. .ne 18
  84. .nf
  85. .ta 4n 20n 32n
  86. typedef void (*cpg_deliver_fn_t) (
  87. cpg_handle_t handle,
  88. const struct cpg_name *group_name,
  89. uint32_t nodeid,
  90. uint32_t pid,
  91. const void *msg,
  92. size_t msg_len);
  93. typedef void (*cpg_confchg_fn_t) (
  94. cpg_handle_t handle,
  95. const struct cpg_name *group_name,
  96. const struct cpg_address *member_list, size_t member_list_entries,
  97. const struct cpg_address *left_list, size_t left_list_entries,
  98. const struct cpg_address *joined_list, size_t joined_list_entries);
  99. typedef void (*cpg_totem_confchg_fn_t) (
  100. cpg_handle_t handle,
  101. struct cpg_ring_id ring_id,
  102. uint32_t member_list_entries,
  103. const uint32_t *member_list);
  104. .ta
  105. .fi
  106. .RE
  107. .IP
  108. .PP
  109. .PP
  110. The
  111. .I cpg_model_v1_data_t
  112. structure is defined as:
  113. .IP
  114. .RS
  115. .ne 18
  116. .nf
  117. .PP
  118. typedef struct {
  119. cpg_model_t model;
  120. cpg_deliver_fn_t cpg_deliver_fn;
  121. cpg_confchg_fn_t cpg_confchg_fn;
  122. cpg_totem_confchg_fn_t cpg_totem_confchg_fn;
  123. unsigned int flags;
  124. } cpg_model_v1_data_t;
  125. .ta
  126. .fi
  127. .RE
  128. .IP
  129. .PP
  130. When a configuration change occurs or a message is to be delivered one of the callbacks
  131. is called from the
  132. .B cpg_dispatch()
  133. function. If a configuration change occurs,
  134. .I cpg_confchg_fn
  135. is called. If a delivery of a message occurs,
  136. .I cpg_deliver_fn
  137. is called.
  138. When totem membership change occurs,
  139. .I cpg_totem_confchg_fn
  140. is called. You can OR
  141. .I CPG_MODEL_V1_DELIVER_INITIAL_TOTEM_CONF
  142. constant to flags to get callback after first confchg event.
  143. The
  144. .I cpg_address
  145. structure is defined
  146. .IP
  147. .RS
  148. .ne 18
  149. .nf
  150. .PP
  151. struct cpg_address {
  152. unsigned int nodeid;
  153. unsigned int pid;
  154. unsigned int reason;
  155. };
  156. .ta
  157. .fi
  158. .RE
  159. .IP
  160. .PP
  161. where nodeid is a 32 bit unique node identifier, pid is the process ID of the process that has joined/left the group
  162. or sent the message, and reason is an integer code indicating why the node joined/left the group.
  163. .PP
  164. .IP
  165. .RS
  166. .ne 18
  167. .nf
  168. .PP
  169. CPG_REASON_JOIN - the process joined a group using cpg_join().
  170. CPG_REASON_LEAVE - the process left a group using cpg_leave()
  171. CPG_REASON_NODEDOWN - the process left a group because the node left the cluster.
  172. 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
  173. CPG_REASON_PROCDOWN - the process left a group without calling cpg_leave()
  174. .ta
  175. .fi
  176. .RE
  177. .IP
  178. .PP
  179. The
  180. .I cpg_ring_id
  181. structure is defined
  182. .IP
  183. .RS
  184. .ne 18
  185. .nf
  186. .PP
  187. struct cpg_ring_id {
  188. uint32_t nodeid;
  189. uint64_t seq;
  190. };
  191. .ta
  192. .fi
  193. .RE
  194. .IP
  195. .PP
  196. where
  197. .I nodeid
  198. is if of node of current Totem leader and seq is increasing number.
  199. .PP
  200. .SH RETURN VALUE
  201. This call returns the CS_OK value if successful, otherwise an error is returned.
  202. .PP
  203. .SH ERRORS
  204. The errors are undocumented.
  205. .SH "SEE ALSO"
  206. .BR cpg_overview (8),
  207. .BR cpg_initialize (3),
  208. .BR cpg_finalize (3),
  209. .BR cpg_fd_get (3),
  210. .BR cpg_dispatch (3),
  211. .BR cpg_join (3),
  212. .BR cpg_leave (3),
  213. .BR cpg_mcast_joined (3),
  214. .BR cpg_membership_get (3)
  215. .BR cpg_zcb_alloc (3)
  216. .BR cpg_zcb_free (3)
  217. .BR cpg_zcb_mcast_joined (3)
  218. .BR cpg_context_get (3)
  219. .BR cpg_context_set (3)
  220. .BR cpg_local_get (3)
  221. .BR cpg_model_initialize (3)
  222. .PP