4
0

cpg_initialize.3 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. .\"/*
  2. .\" * Copyright (c) 2006 Red Hat, Inc.
  3. .\" *
  4. .\" * All rights reserved.
  5. .\" *
  6. .\" * Author: Patrick Caulfield <pcaulfie@redhat.com>
  7. .\" *
  8. .\" * This software licensed under BSD license, the text of which follows:
  9. .\" *
  10. .\" * Redistribution and use in source and binary forms, with or without
  11. .\" * modification, are permitted provided that the following conditions are met:
  12. .\" *
  13. .\" * - Redistributions of source code must retain the above copyright notice,
  14. .\" * this list of conditions and the following disclaimer.
  15. .\" * - Redistributions in binary form must reproduce the above copyright notice,
  16. .\" * this list of conditions and the following disclaimer in the documentation
  17. .\" * and/or other materials provided with the distribution.
  18. .\" * - Neither the name of the MontaVista Software, Inc. nor the names of its
  19. .\" * contributors may be used to endorse or promote products derived from this
  20. .\" * software without specific prior written permission.
  21. .\" *
  22. .\" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. .\" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. .\" * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  25. .\" * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  26. .\" * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  27. .\" * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  28. .\" * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  29. .\" * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  30. .\" * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  31. .\" * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  32. .\" * THE POSSIBILITY OF SUCH DAMAGE.
  33. .\" */
  34. .TH CPG_INITIALIZE 3 2004-08-31 "openais Man Page" "Openais Programmer's Manual"
  35. .SH NAME
  36. cpg_initialize \- Create a new connection to the CPG service
  37. .SH SYNOPSIS
  38. .B #include <openais/cpg.h>
  39. .sp
  40. .BI "int cpg_initialize(cpg_handle_t *" handle ", cpg_callbacks_t *" callbacks ");
  41. .SH DESCRIPTION
  42. The
  43. .B cpg_initialize
  44. function is used to initialize a connection to the closed process groups API.
  45. .PP
  46. Each application may have several connections to the CPG API. Each application
  47. uses the
  48. .I handle
  49. argument to uniquely identify the connection. The
  50. .I handle
  51. argument is then used in other function calls to identify the connection to be used
  52. for communication with the CPG service.
  53. .PP
  54. Every time an CPG event occurs within the joined group, one of the callbacks specified by the argument
  55. .I callbacks
  56. is called. The callback functions are described by the following type definitions:
  57. .PP
  58. .PP
  59. .IP
  60. .RS
  61. .ne 18
  62. .nf
  63. .ta 4n 20n 32n
  64. typedef void (*cpg_deliver_fn_t) (
  65. cpg_handle_t handle,
  66. struct cpg_name *group_name,
  67. uint32_t nodeid,
  68. uint32_t pid,
  69. void *msg,
  70. int msg_len);
  71. typedef void (*cpg_confchg_fn_t) (
  72. cpg_handle_t handle,
  73. struct cpg_name *group_name,
  74. struct cpg_address *member_list, int member_list_entries,
  75. struct cpg_address *left_list, int left_list_entries,
  76. struct cpg_address *joined_list, int joined_list_entries);
  77. .ta
  78. .fi
  79. .RE
  80. .IP
  81. .PP
  82. .PP
  83. The
  84. .I callbacks
  85. argument is of the type:
  86. .IP
  87. .RS
  88. .ne 18
  89. .nf
  90. .PP
  91. typedef struct {
  92. cpg_deliver_fn_t cpg_deliver_fn;
  93. cpg_confchg_fn_t cpg_confchg_fn;
  94. } cpg_callbacks_t;
  95. .ta
  96. .fi
  97. .RE
  98. .IP
  99. .PP
  100. When a configuration change occurs or a message is to be delivered one of the callbacks
  101. is called from the
  102. .B cpg_dispatch()
  103. function. If a configuration change occurs,
  104. .I cpg_confchg_fn
  105. is called. If a delivery of a message occurs,
  106. .I cpg_deliver_fn
  107. is called.
  108. The
  109. .I cpg_address
  110. structure is defined
  111. .IP
  112. .RS
  113. .ne 18
  114. .nf
  115. .PP
  116. struct cpg_address {
  117. unsigned int nodeid;
  118. unsigned int pid;
  119. unsigned int reason;
  120. };
  121. .ta
  122. .fi
  123. .RE
  124. .IP
  125. .PP
  126. where nodeid is a 32 bit unique node identifier, pid is the process ID of the process that has joined/left the group
  127. or sent the message, and reason is an integer code indicating why the node join/left the group.
  128. .PP
  129. .IP
  130. .RS
  131. .ne 18
  132. .nf
  133. .PP
  134. CPG_REASON_JOIN - the process joined a group using cpg_join().
  135. CPG_REASON_LEAVE - the process left a group using cpg_leave()
  136. CPG_REASON_NODEDOWN - the process left a group because the node left the cluster.
  137. 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
  138. CPG_REASON_PROCDOWN - the process left a group without calling cpg_leave()
  139. .ta
  140. .fi
  141. .RE
  142. .IP
  143. .PP
  144. .SH RETURN VALUE
  145. This call returns the CPG_OK value if successful, otherwise an error is returned.
  146. .PP
  147. .SH ERRORS
  148. The errors are undocumented.
  149. .SH "SEE ALSO"
  150. .BR cpg_overview (8),
  151. .BR cpg_finalize (3),
  152. .BR cpg_fd_get (3),
  153. .BR cpg_dispatch (3),
  154. .BR cpg_join (3),
  155. .BR cpg_leave (3),
  156. .BR cpg_mcast_joined (3),
  157. .BR cpg_membership_get (3)
  158. .PP