1CMAP_TRACK_ADD(3) Corosync Cluster Engine Programmer's ManualCMAP_TRACK_ADD(3)
2
3
4
6 cmap_track_add - Set tracking function for values in CMAP
7
8
10 #include <corosync/cmap.h>
11
12
13 cs_error_t cmap_track_add (cmap_handle_t handle, const char *key_name,
14 int32_t track_type, cmap_notify_fn_t notify_fn, void *user_data,
15 cmap_track_handle_t *cmap_track_handle);
16
17
19 The cmap_track_add function is used to set function which tracks
20 changes in CMAP. One CMAP connection can track multiple keys and also
21 it's possible to track one key multiple times. The handle argument is
22 connection to CMAP database obtained by calling cmap_initialize(3)
23 function. key_name argument is ether exact key name or prefix of key
24 name to track changes on. track_type is bitfield which may consist of
25 following values:
26
27 CMAP_TRACK_ADD - track addition of new key (or key added in callback)
28
29 CMAP_TRACK_DELETE - track deletion of key (or key deleted in callback)
30
31 CMAP_TRACK_MODIFY - track modification of key (or key modified in call‐
32 back)
33
34 CMAP_TRACK_PREFIX - whole prefix is tracked, instead of key only, so
35 "totem." tracking means that "totem.nodeid", "totem.version", ...
36 applies (this value is never returned in callback)
37
38 notify_fn is pointer to function which is called when value is changed.
39 It's definition and meaning of parameters is discussed below.
40 user_data argument is passed directly to notify_fn without any changes.
41 cmap_track_handle is used for removing of tracking when no longer
42 needed by calling cmap_track_delete(3) function.
43
44 Callback function is defined as:
45
46 typedef void (*cmap_notify_fn_t) (
47 cmap_handle_t cmap_handle,
48 cmap_track_handle_t cmap_track_handle,
49 int32_t event,
50 const char *key_name,
51 struct cmap_notify_value new_value,
52 struct cmap_notify_value old_value,
53 void *user_data);
54
55 where cmap_handle is handle used in registration of track function.
56 cmap_track_handle is handle returned by cmap_track_add function. event
57 is one of CMAP_TRACK_ADD, CMAP_TRACK_DELETE or CMAP_TRACK_MODIFY.
58 key_name is name of changed key. new_value is new value of key, or
59 unset if event is CMAP_TRACK_DELETE. old_value is previous value of
60 key or unset if event is CMAP_TRACK_ADD or for some special keys set
61 directly by Corosync due to speed optimizations. Both new_value and
62 old_value are structures defined as:
63
64 struct cmap_notify_value {
65 cmap_value_types_t type;
66 size_t len;
67 const void *data;
68 };
69
70 If value is unset, all fields are set to 0. Otherwise type is one of
71 cmap types (as described in cmap_get(3) function), len is length of
72 value in cmap and data is pointer to value of item. Data storage is
73 dynamically allocated by caller and notify function must not try to
74 free it.
75
76
78 This call returns the CS_OK value if successful. It can return
79 CS_ERR_INVALID_PARAM if notify_fn is NULL or track_type is invalid
80 value.
81
82
84 cmap_track_delete(3), cmap_initialize(3), cmap_get(3), cmap_dis‐
85 patch(3), cmap_overview(8)
86
87 CS_ERR_TRY_AGAIN Resource temporarily unavailable
88
89 CS_ERR_INVALID_PARAM Invalid argument
90
91 CS_ERR_ACCESS Permission denied
92
93 CS_ERR_LIBRARY The connection failed
94
95 CS_ERR_INTERRUPT System call interrupted by a signal
96
97 CS_ERR_NOT_SUPPORTED The requested protocol/functionality not supported
98
99 CS_ERR_MESSAGE_ERROR Incorrect auth message received
100
101 CS_ERR_NO_MEMORY Not enough memory to complete the requested task
102
103
104
105corosync Man Page 06/02/2012 CMAP_TRACK_ADD(3)