4
0

cmap_track_add.3.in 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. .\"/*
  2. .\" * Copyright (c) 2012 Red Hat, Inc.
  3. .\" *
  4. .\" * All rights reserved.
  5. .\" *
  6. .\" * Author: Jan Friesse (jfriesse@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 Red Hat, 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 "CMAP_TRACK_ADD" 3 "06/02/2012" "corosync Man Page" "Corosync Cluster Engine Programmer's Manual"
  35. .SH NAME
  36. .P
  37. cmap_track_add \- Set tracking function for values in CMAP
  38. .SH SYNOPSIS
  39. .P
  40. \fB#include <corosync/cmap.h>\fR
  41. .P
  42. \fBcs_error_t
  43. cmap_track_add (cmap_handle_t \fIhandle\fB, const char *\fIkey_name\fB, int32_t \fItrack_type\fB,
  44. cmap_notify_fn_t \fInotify_fn\fB, void *\fIuser_data\fB, cmap_track_handle_t *\fIcmap_track_handle\fB);\fR
  45. .SH DESCRIPTION
  46. .P
  47. The
  48. .B cmap_track_add
  49. function is used to set function which tracks changes in CMAP. One CMAP connection can
  50. track multiple keys and also it's possible to track one key multiple times. The
  51. .I handle
  52. argument is connection to CMAP database obtained by calling
  53. .B cmap_initialize(3)
  54. function.
  55. .I key_name
  56. argument is ether exact key name or prefix of key name to track changes on.
  57. .I track_type
  58. is bitfield which may consist of following values:
  59. .PP
  60. \fBCMAP_TRACK_ADD\fR - track addition of new key (or key added in callback)
  61. .PP
  62. \fBCMAP_TRACK_DELETE\fR - track deletion of key (or key deleted in callback)
  63. .PP
  64. \fBCMAP_TRACK_MODIFY\fR - track modification of key (or key modified in callback)
  65. .PP
  66. \fBCMAP_TRACK_PREFIX\fR - whole prefix is tracked, instead of key only, so "totem." tracking means
  67. that "totem.nodeid", "totem.version", ... applies (this value is never returned
  68. in callback)
  69. .PP
  70. .I notify_fn
  71. is pointer to function which is called when value is changed. It's definition and meaning of parameters
  72. is discussed below.
  73. .I user_data
  74. argument is passed directly to
  75. .I notify_fn
  76. without any changes.
  77. .I cmap_track_handle
  78. is used for removing of tracking when no longer needed by calling
  79. .B cmap_track_delete(3)
  80. function.
  81. Callback function is defined as:
  82. .IP
  83. .RS
  84. .ne 18
  85. .nf
  86. .PP
  87. typedef void (*cmap_notify_fn_t) (
  88. cmap_handle_t cmap_handle,
  89. cmap_track_handle_t cmap_track_handle,
  90. int32_t event,
  91. const char *key_name,
  92. struct cmap_notify_value new_value,
  93. struct cmap_notify_value old_value,
  94. void *user_data);
  95. .ta
  96. .fi
  97. .RE
  98. .IP
  99. .PP
  100. where
  101. .I cmap_handle
  102. is handle used in registration of track function.
  103. .I cmap_track_handle
  104. is handle returned by
  105. .B cmap_track_add
  106. function.
  107. .I event
  108. is one of \fBCMAP_TRACK_ADD\fR, \fBCMAP_TRACK_DELETE\fR or \fBCMAP_TRACK_MODIFY\fR.
  109. .I key_name
  110. is name of changed key.
  111. .I new_value
  112. is new value of key, or unset if
  113. .I event
  114. is \fBCMAP_TRACK_DELETE\fR.
  115. .I old_value
  116. is previous value of key or unset if
  117. .I event
  118. is \fBCMAP_TRACK_ADD\fR or for some special keys set directly by Corosync due to speed optimizations.
  119. Both
  120. .I new_value
  121. and
  122. .I old_value
  123. are structures defined as:
  124. .IP
  125. .RS
  126. .ne 18
  127. .nf
  128. .PP
  129. struct cmap_notify_value {
  130. cmap_value_types_t type;
  131. size_t len;
  132. const void *data;
  133. };
  134. .ta
  135. .fi
  136. .RE
  137. .IP
  138. .PP
  139. If value is unset, all fields are set to 0. Otherwise
  140. .I type
  141. is one of cmap types (as described in
  142. .B cmap_get(3)
  143. function),
  144. .I len
  145. is length of value in cmap and
  146. .I data
  147. is pointer to value of item. Data storage is dynamically allocated by caller and notify function must not try to
  148. free it.
  149. .SH RETURN VALUE
  150. This call returns the CS_OK value if successful. It can return CS_ERR_INVALID_PARAM if
  151. notify_fn is NULL or track_type is invalid value.
  152. .SH NOTES
  153. Modification tracking of individual keys is supported in the stats map, but not
  154. prefixes. Add/Delete operations are supported on prefixes though so you can track
  155. for new ipc connections or knet interfaces.
  156. In the icmap map, prefix tracking is fully supported.
  157. .SH "SEE ALSO"
  158. .BR cmap_track_delete (3),
  159. .BR cmap_initialize (3),
  160. .BR cmap_get (3),
  161. .BR cmap_dispatch (3),
  162. .BR cmap_overview (3)