4 Copyright (C) Ronnie sahlberg 2010
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, see <http://www.gnu.org/licenses/>.
23 /* Functions are not thread safe so all function calls must be wrapped
24 * inside a pthread_mutex for threaded applications.
26 * All _send() functions are guaranteed to be non-blocking and fully
29 * Avoid using the synchronous calls
33 * Connect to ctdb using the specified domain socket.
34 * Returns a ctdb context if successful or NULL.
36 struct ctdb_context *ctdb_connect(const char *addr);
38 int ctdb_get_fd(struct ctdb_context *ctdb);
40 int ctdb_which_events(struct ctdb_context *ctdb);
42 int ctdb_service(struct ctdb_context *ctdb);
46 * Special node addresses :
48 /* used on the domain socket, send a pdu to the local daemon */
49 #define CTDB_CURRENT_NODE 0xF0000001
50 /* send a broadcast to all nodes in the cluster, active or not */
51 #define CTDB_BROADCAST_ALL 0xF0000002
52 /* send a broadcast to all nodes in the current vnn map */
53 #define CTDB_BROADCAST_VNNMAP 0xF0000003
54 /* send a broadcast to all connected nodes */
55 #define CTDB_BROADCAST_CONNECTED 0xF0000004
61 typedef void ctdb_handle;
66 * these functions provide a messaging layer for applications to communicate
67 * with eachother across
69 typedef void (*ctdb_message_fn_t)(struct ctdb_context *, uint64_t srvid, TDB_DATA data, void *);
72 * register a message handler and start listening on a service port
74 typedef void (*ctdb_set_message_handler_cb)(int32_t status, void *private_data);
77 ctdb_set_message_handler_send(struct ctdb_context *ctdb, uint64_t srvid,
78 ctdb_set_message_handler_cb callback,
79 ctdb_message_fn_t handler, void *private_data);
81 int ctdb_set_message_handler_recv(struct ctdb_context *ctdb,
84 int ctdb_set_message_handler(struct ctdb_context *ctdb, uint64_t srvid,
85 ctdb_message_fn_t handler, void *private_data);
90 * unregister a message handler and stop listening on teh specified port
92 typedef void (*ctdb_remove_message_handler_cb)(int32_t status, void *private_data);
95 ctdb_remove_message_handler_send(struct ctdb_context *ctdb, uint64_t srvid,
96 ctdb_remove_message_handler_cb callback,
99 int ctdb_remove_message_handler_recv(struct ctdb_context *ctdb,
100 ctdb_handle *handle);
102 int ctdb_remove_message_handler(struct ctdb_context *ctdb, uint64_t srvid);
107 * send a message to a specific node/port
108 * this function is non-blocking
110 int ctdb_send_message(struct ctdb_context *ctdb, uint32_t pnn, uint64_t srvid, TDB_DATA data);
116 * functions to read the pnn number of the local node
118 typedef void (*ctdb_getpnn_cb)(int32_t status, int32_t pnn, void *private_data);
121 ctdb_getpnn_send(struct ctdb_context *ctdb,
123 ctdb_getpnn_cb callback,
125 int ctdb_getpnn_recv(struct ctdb_context *ctdb,
128 int ctdb_getpnn(struct ctdb_context *ctdb,
136 * functions to read the recovery master of a node
138 typedef void (*ctdb_getrecmaster_cb)(int32_t status, int32_t recmaster, void *private_data);
141 ctdb_getrecmaster_send(struct ctdb_context *ctdb,
143 ctdb_getrecmaster_cb callback,
145 int ctdb_getrecmaster_recv(struct ctdb_context *ctdb,
147 uint32_t *recmaster);
148 int ctdb_getrecmaster(struct ctdb_context *ctdb,
150 uint32_t *recmaster);
156 * functions to create a database
157 * if the database already exists this function is a NOP
159 typedef void (*ctdb_createdb_cb)(int32_t status, uint32_t db_id, void *private_data);
162 ctdb_createdb_send(struct ctdb_context *ctdb, uint32_t destnode,
163 const char *name, int persistent,
164 ctdb_createdb_cb callback,
166 int ctdb_createdb_recv(struct ctdb_context *ctdb,
167 ctdb_handle *handle, uint32_t *db_id);
168 int ctdb_createdb(struct ctdb_context *ctdb, uint32_t destnode,
169 const char *name, int persistent, uint32_t *db_id);
174 * cancel a request/call
176 int ctdb_cancel(ctdb_handle *);