4 Copyright (C) Andrew Tridgell 2006
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 2 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, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #ifndef _CTDB_PRIVATE_H
22 #define _CTDB_PRIVATE_H
25 #include <sys/socket.h>
26 #include <netinet/in.h>
28 /* location of daemon socket */
29 #define CTDB_PATH "/tmp/ctdb.socket"
31 /* default ctdb port number */
32 #define CTDB_PORT 9001
34 /* we must align packets to ensure ctdb works on all architectures (eg. sparc) */
35 #define CTDB_DS_ALIGNMENT 8
38 #define CTDB_NULL_FUNC 0xFF000001
39 #define CTDB_FETCH_FUNC 0xFF000002
41 /* all tunable variables go in here */
43 uint32_t max_redirect_count;
44 uint32_t seqnum_frequency;
45 uint32_t control_timeout;
46 uint32_t traverse_timeout;
47 uint32_t monitoring_timeout;
48 uint32_t monitoring_limit;
53 an installed ctdb remote call
55 struct ctdb_registered_call {
56 struct ctdb_registered_call *next, *prev;
62 this address structure might need to be generalised later for some
73 #define ctdb_validate_vnn(ctdb, vnn) (((uint32_t)(vnn)) < (ctdb)->num_nodes)
76 /* called from the queue code when a packet comes in. Called with data==NULL
78 typedef void (*ctdb_queue_cb_fn_t)(uint8_t *data, size_t length,
81 /* used for callbacks in ctdb_control requests */
82 typedef void (*ctdb_control_callback_fn_t)(struct ctdb_context *,
83 int32_t status, TDB_DATA data,
88 structure describing a connected client in the daemon
91 struct ctdb_context *ctdb;
93 struct ctdb_queue *queue;
95 struct ctdb_tcp_list *tcp_list;
100 state associated with one node
103 struct ctdb_context *ctdb;
104 struct ctdb_address address;
105 const char *name; /* for debug messages */
106 void *private_data; /* private to transport */
108 #define NODE_FLAGS_CONNECTED 0x00000001
111 /* used by the dead node monitoring */
116 /* a list of controls pending to this node, so we can time them out quickly
117 if the node becomes disconnected */
118 struct daemon_control_state *pending_controls;
120 /* the public address of this node, if known */
121 const char *public_address;
122 uint8_t public_netmask_bits;
124 /* the node number that has taken over this nodes public address, if any.
125 If not taken over, then set to -1 */
126 int32_t takeover_vnn;
130 transport specific methods
132 struct ctdb_methods {
133 int (*initialise)(struct ctdb_context *); /* initialise transport structures */
134 int (*start)(struct ctdb_context *); /* start protocol processing */
135 int (*add_node)(struct ctdb_node *); /* setup a new node */
136 int (*queue_pkt)(struct ctdb_node *, uint8_t *data, uint32_t length);
137 void *(*allocate_pkt)(TALLOC_CTX *mem_ctx, size_t );
138 void (*shutdown)(struct ctdb_context *); /* shutdown transport */
142 transport calls up to the ctdb layer
144 struct ctdb_upcalls {
145 /* recv_pkt is called when a packet comes in */
146 void (*recv_pkt)(struct ctdb_context *, uint8_t *data, uint32_t length);
148 /* node_dead is called when an attempt to send to a node fails */
149 void (*node_dead)(struct ctdb_node *);
151 /* node_connected is called when a connection to a node is established */
152 void (*node_connected)(struct ctdb_node *);
155 /* list of message handlers - needs to be changed to a more efficient data
156 structure so we can find a message handler given a srvid quickly */
157 struct ctdb_message_list {
158 struct ctdb_context *ctdb;
159 struct ctdb_message_list *next, *prev;
161 ctdb_message_fn_t message_handler;
162 void *message_private;
165 /* additional data required for the daemon mode */
166 struct ctdb_daemon_data {
169 struct ctdb_queue *queue;
173 ctdb status information
175 struct ctdb_statistics {
176 uint32_t num_clients;
179 uint32_t client_packets_sent;
180 uint32_t client_packets_recv;
181 uint32_t node_packets_sent;
182 uint32_t node_packets_recv;
183 uint32_t keepalive_packets_sent;
184 uint32_t keepalive_packets_recv;
188 uint32_t req_dmaster;
189 uint32_t reply_dmaster;
190 uint32_t reply_error;
191 uint32_t req_message;
192 uint32_t req_control;
193 uint32_t reply_control;
197 uint32_t req_message;
198 uint32_t req_control;
206 uint32_t process_exists;
207 uint32_t traverse_start;
208 uint32_t traverse_all;
209 uint32_t traverse_data;
210 uint32_t update_seqnum;
211 uint32_t enable_seqnum;
212 uint32_t set_seqnum_frequency;
213 uint32_t register_srvid;
214 uint32_t deregister_srvid;
221 uint32_t total_calls;
222 uint32_t pending_calls;
223 uint32_t lockwait_calls;
224 uint32_t pending_lockwait_calls;
225 uint32_t memory_used;
226 uint32_t __last_counter; /* hack for control_statistics_all */
227 uint32_t max_hop_count;
228 double max_call_latency;
229 double max_lockwait_latency;
232 /* table that contains the mapping between a hash value and lmaster
234 struct ctdb_vnn_map {
241 a wire representation of the vnn map
243 struct ctdb_vnn_map_wire {
249 /* a structure that contains the elements required for the write record
252 struct ctdb_write_record {
256 unsigned char blob[1];
259 enum ctdb_freeze_mode {CTDB_FREEZE_NONE, CTDB_FREEZE_PENDING, CTDB_FREEZE_FROZEN};
261 #define CTDB_MONITORING_ACTIVE 0
262 #define CTDB_MONITORING_DISABLED 1
264 /* information about IP takeover */
265 struct ctdb_takeover {
267 const char *interface;
268 const char *event_script;
269 TALLOC_CTX *last_ctx;
273 /* main state of the ctdb daemon */
274 struct ctdb_context {
275 struct event_context *ev;
276 uint32_t recovery_mode;
277 uint32_t monitoring_mode;
278 struct ctdb_tunable tunable;
279 enum ctdb_freeze_mode freeze_mode;
280 struct ctdb_freeze_handle *freeze_handle;
281 struct ctdb_address address;
283 const char *db_directory;
284 const char *transport;
286 char *node_list_file;
287 char *recovery_lock_file;
288 int recovery_lock_fd;
289 uint32_t vnn; /* our own vnn */
291 uint32_t num_connected;
293 struct idr_context *idr;
295 struct ctdb_node **nodes; /* array of nodes in the cluster - indexed by vnn */
297 const struct ctdb_methods *methods; /* transport methods */
298 const struct ctdb_upcalls *upcalls; /* transport upcalls */
299 void *private_data; /* private to transport */
300 struct ctdb_db_context *db_list;
301 struct ctdb_message_list *message_list;
302 struct ctdb_daemon_data daemon;
303 struct ctdb_statistics statistics;
304 struct ctdb_vnn_map *vnn_map;
305 uint32_t num_clients;
306 uint32_t recovery_master;
307 struct ctdb_call_state *pending_calls;
308 struct ctdb_takeover takeover;
309 struct ctdb_tcp_list *tcp_list;
312 struct ctdb_db_context {
313 struct ctdb_db_context *next, *prev;
314 struct ctdb_context *ctdb;
318 struct tdb_wrap *ltdb;
319 struct ctdb_registered_call *calls; /* list of registered calls */
321 struct timed_event *te;
325 #define CTDB_NO_MEMORY(ctdb, p) do { if (!(p)) { \
326 DEBUG(0,("Out of memory for %s at %s\n", #p, __location__)); \
327 ctdb_set_error(ctdb, "Out of memory at %s:%d", __FILE__, __LINE__); \
328 return -1; }} while (0)
330 #define CTDB_NO_MEMORY_VOID(ctdb, p) do { if (!(p)) { \
331 DEBUG(0,("Out of memory for %s at %s\n", #p, __location__)); \
332 ctdb_set_error(ctdb, "Out of memory at %s:%d", __FILE__, __LINE__); \
335 #define CTDB_NO_MEMORY_NULL(ctdb, p) do { if (!(p)) { \
336 DEBUG(0,("Out of memory for %s at %s\n", #p, __location__)); \
337 ctdb_set_error(ctdb, "Out of memory at %s:%d", __FILE__, __LINE__); \
338 return NULL; }} while (0)
340 #define CTDB_NO_MEMORY_FATAL(ctdb, p) do { if (!(p)) { \
341 DEBUG(0,("Out of memory for %s at %s\n", #p, __location__)); \
342 ctdb_fatal(ctdb, "Out of memory in " __location__ ); \
346 the extended header for records in the ltdb
348 struct ctdb_ltdb_header {
355 enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS = 0,
356 CTDB_CONTROL_STATISTICS = 1,
358 CTDB_CONTROL_PING = 3,
359 CTDB_CONTROL_GETDBPATH = 4,
360 CTDB_CONTROL_GETVNNMAP = 5,
361 CTDB_CONTROL_SETVNNMAP = 6,
362 CTDB_CONTROL_GET_DEBUG = 7,
363 CTDB_CONTROL_SET_DEBUG = 8,
364 CTDB_CONTROL_GET_DBMAP = 9,
365 CTDB_CONTROL_GET_NODEMAP = 10,
366 CTDB_CONTROL_SET_DMASTER = 11,
367 CTDB_CONTROL_CLEAR_DB = 12,
368 CTDB_CONTROL_PULL_DB = 13,
369 CTDB_CONTROL_PUSH_DB = 14,
370 CTDB_CONTROL_GET_RECMODE = 15,
371 CTDB_CONTROL_SET_RECMODE = 16,
372 CTDB_CONTROL_STATISTICS_RESET = 17,
373 CTDB_CONTROL_DB_ATTACH = 18,
374 CTDB_CONTROL_SET_CALL = 19,
375 CTDB_CONTROL_TRAVERSE_START = 20,
376 CTDB_CONTROL_TRAVERSE_ALL = 21,
377 CTDB_CONTROL_TRAVERSE_DATA = 22,
378 CTDB_CONTROL_REGISTER_SRVID = 23,
379 CTDB_CONTROL_DEREGISTER_SRVID = 24,
380 CTDB_CONTROL_GET_DBNAME = 25,
381 CTDB_CONTROL_ENABLE_SEQNUM = 26,
382 CTDB_CONTROL_UPDATE_SEQNUM = 27,
384 CTDB_CONTROL_DUMP_MEMORY = 29,
385 CTDB_CONTROL_GET_PID = 30,
386 CTDB_CONTROL_GET_RECMASTER = 31,
387 CTDB_CONTROL_SET_RECMASTER = 32,
388 CTDB_CONTROL_FREEZE = 33,
389 CTDB_CONTROL_THAW = 34,
390 CTDB_CONTROL_GET_VNN = 35,
391 CTDB_CONTROL_SHUTDOWN = 36,
392 CTDB_CONTROL_GET_MONMODE = 37,
393 CTDB_CONTROL_SET_MONMODE = 38,
394 CTDB_CONTROL_MAX_RSN = 39,
395 CTDB_CONTROL_SET_RSN_NONEMPTY = 40,
396 CTDB_CONTROL_DELETE_LOW_RSN = 41,
397 CTDB_CONTROL_TAKEOVER_IP = 42,
398 CTDB_CONTROL_RELEASE_IP = 43,
399 CTDB_CONTROL_TCP_CLIENT = 44,
400 CTDB_CONTROL_TCP_ADD = 45,
401 CTDB_CONTROL_TCP_REMOVE = 46,
402 CTDB_CONTROL_STARTUP = 47,
406 structure passed in ctdb_control_set_rsn_nonempty
408 struct ctdb_control_set_rsn_nonempty {
414 structure passed in ctdb_control_delete_low_rsn
416 struct ctdb_control_delete_low_rsn {
422 structure passed in set_call control
424 struct ctdb_control_set_call {
431 struct for tcp_client control
433 struct ctdb_control_tcp {
434 struct sockaddr_in src;
435 struct sockaddr_in dest;
439 struct for tcp_add and tcp_remove controls
441 struct ctdb_control_tcp_vnn {
443 struct sockaddr_in src;
444 struct sockaddr_in dest;
447 enum call_state {CTDB_CALL_WAIT, CTDB_CALL_DONE, CTDB_CALL_ERROR};
449 #define CTDB_LMASTER_ANY 0xffffffff
452 state of a in-progress ctdb call
454 struct ctdb_call_state {
455 struct ctdb_call_state *next, *prev;
456 enum call_state state;
458 struct ctdb_req_call *c;
459 struct ctdb_db_context *ctdb_db;
461 struct ctdb_call call;
464 void (*fn)(struct ctdb_call_state *);
470 /* used for fetch_lock */
471 struct ctdb_fetch_handle {
472 struct ctdb_db_context *ctdb_db;
475 struct ctdb_ltdb_header header;
481 enum ctdb_operation {
484 CTDB_REQ_DMASTER = 2,
485 CTDB_REPLY_DMASTER = 3,
486 CTDB_REPLY_ERROR = 4,
487 CTDB_REQ_MESSAGE = 5,
489 CTDB_REQ_CONTROL = 7,
490 CTDB_REPLY_CONTROL = 8,
491 CTDB_REQ_KEEPALIVE = 9,
494 #define CTDB_MAGIC 0x43544442 /* CTDB */
495 #define CTDB_VERSION 1
500 struct ctdb_req_header {
503 uint32_t ctdb_version;
511 struct ctdb_req_call {
512 struct ctdb_req_header hdr;
518 uint32_t calldatalen;
519 uint8_t data[1]; /* key[] followed by calldata[] */
522 struct ctdb_reply_call {
523 struct ctdb_req_header hdr;
529 struct ctdb_reply_error {
530 struct ctdb_req_header hdr;
536 struct ctdb_req_dmaster {
537 struct ctdb_req_header hdr;
546 struct ctdb_reply_dmaster {
547 struct ctdb_req_header hdr;
555 struct ctdb_req_message {
556 struct ctdb_req_header hdr;
562 struct ctdb_req_getdbpath {
563 struct ctdb_req_header hdr;
567 struct ctdb_reply_getdbpath {
568 struct ctdb_req_header hdr;
573 struct ctdb_req_control {
574 struct ctdb_req_header hdr;
578 #define CTDB_CTRL_FLAG_NOREPLY 1
584 struct ctdb_reply_control {
585 struct ctdb_req_header hdr;
592 struct ctdb_req_keepalive {
593 struct ctdb_req_header hdr;
596 /* internal prototypes */
597 void ctdb_set_error(struct ctdb_context *ctdb, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
598 void ctdb_fatal(struct ctdb_context *ctdb, const char *msg);
599 bool ctdb_same_address(struct ctdb_address *a1, struct ctdb_address *a2);
600 int ctdb_parse_address(struct ctdb_context *ctdb,
601 TALLOC_CTX *mem_ctx, const char *str,
602 struct ctdb_address *address);
603 uint32_t ctdb_hash(const TDB_DATA *key);
604 uint32_t ctdb_hash_string(const char *str);
605 void ctdb_request_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
606 void ctdb_request_dmaster(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
607 void ctdb_request_message(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
608 void ctdb_reply_dmaster(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
609 void ctdb_reply_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
610 void ctdb_reply_error(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
612 uint32_t ctdb_lmaster(struct ctdb_context *ctdb, const TDB_DATA *key);
613 int ctdb_ltdb_fetch(struct ctdb_db_context *ctdb_db,
614 TDB_DATA key, struct ctdb_ltdb_header *header,
615 TALLOC_CTX *mem_ctx, TDB_DATA *data);
616 int ctdb_ltdb_store(struct ctdb_db_context *ctdb_db, TDB_DATA key,
617 struct ctdb_ltdb_header *header, TDB_DATA data);
618 void ctdb_queue_packet(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
619 int ctdb_ltdb_lock_requeue(struct ctdb_db_context *ctdb_db,
620 TDB_DATA key, struct ctdb_req_header *hdr,
621 void (*recv_pkt)(void *, struct ctdb_req_header *),
622 void *recv_context, bool ignore_generation);
623 int ctdb_ltdb_lock_fetch_requeue(struct ctdb_db_context *ctdb_db,
624 TDB_DATA key, struct ctdb_ltdb_header *header,
625 struct ctdb_req_header *hdr, TDB_DATA *data,
626 void (*recv_pkt)(void *, struct ctdb_req_header *),
627 void *recv_context, bool ignore_generation);
628 void ctdb_input_pkt(struct ctdb_context *ctdb, struct ctdb_req_header *);
630 struct ctdb_call_state *ctdb_call_local_send(struct ctdb_db_context *ctdb_db,
631 struct ctdb_call *call,
632 struct ctdb_ltdb_header *header,
636 int ctdbd_start(struct ctdb_context *ctdb);
637 struct ctdb_call_state *ctdbd_call_send(struct ctdb_db_context *ctdb_db, struct ctdb_call *call);
638 int ctdbd_call_recv(struct ctdb_call_state *state, struct ctdb_call *call);
641 queue a packet for sending
643 int ctdb_queue_send(struct ctdb_queue *queue, uint8_t *data, uint32_t length);
646 setup the fd used by the queue
648 int ctdb_queue_set_fd(struct ctdb_queue *queue, int fd);
651 setup a packet queue on a socket
653 struct ctdb_queue *ctdb_queue_setup(struct ctdb_context *ctdb,
654 TALLOC_CTX *mem_ctx, int fd, int alignment,
656 ctdb_queue_cb_fn_t callback,
660 allocate a packet for use in client<->daemon communication
662 struct ctdb_req_header *_ctdbd_allocate_pkt(struct ctdb_context *ctdb,
664 enum ctdb_operation operation,
665 size_t length, size_t slength,
667 #define ctdbd_allocate_pkt(ctdb, mem_ctx, operation, length, type) \
668 (type *)_ctdbd_allocate_pkt(ctdb, mem_ctx, operation, length, sizeof(type), #type)
670 struct ctdb_req_header *_ctdb_transport_allocate(struct ctdb_context *ctdb,
672 enum ctdb_operation operation,
673 size_t length, size_t slength,
675 #define ctdb_transport_allocate(ctdb, mem_ctx, operation, length, type) \
676 (type *)_ctdb_transport_allocate(ctdb, mem_ctx, operation, length, sizeof(type), #type)
680 lock a record in the ltdb, given a key
682 int ctdb_ltdb_lock(struct ctdb_db_context *ctdb_db, TDB_DATA key);
685 unlock a record in the ltdb, given a key
687 int ctdb_ltdb_unlock(struct ctdb_db_context *ctdb_db, TDB_DATA key);
691 make a ctdb call to the local daemon - async send. Called from client context.
693 This constructs a ctdb_call request and queues it for processing.
694 This call never blocks.
696 struct ctdb_call_state *ctdb_client_call_send(struct ctdb_db_context *ctdb_db,
697 struct ctdb_call *call);
700 make a recv call to the local ctdb daemon - called from client context
702 This is called when the program wants to wait for a ctdb_call to complete and get the
703 results. This call will block unless the call has already completed.
705 int ctdb_client_call_recv(struct ctdb_call_state *state, struct ctdb_call *call);
707 int ctdb_daemon_set_message_handler(struct ctdb_context *ctdb, uint64_t srvid,
708 ctdb_message_fn_t handler,
711 int ctdb_client_send_message(struct ctdb_context *ctdb, uint32_t vnn,
712 uint64_t srvid, TDB_DATA data);
717 int ctdb_daemon_send_message(struct ctdb_context *ctdb, uint32_t vnn,
718 uint64_t srvid, TDB_DATA data);
721 struct lockwait_handle *ctdb_lockwait(struct ctdb_db_context *ctdb_db,
723 void (*callback)(void *), void *private_data);
725 struct ctdb_call_state *ctdb_daemon_call_send(struct ctdb_db_context *ctdb_db,
726 struct ctdb_call *call);
728 int ctdb_daemon_call_recv(struct ctdb_call_state *state, struct ctdb_call *call);
730 struct ctdb_call_state *ctdb_daemon_call_send_remote(struct ctdb_db_context *ctdb_db,
731 struct ctdb_call *call,
732 struct ctdb_ltdb_header *header);
734 int ctdb_call_local(struct ctdb_db_context *ctdb_db, struct ctdb_call *call,
735 struct ctdb_ltdb_header *header, TALLOC_CTX *mem_ctx, TDB_DATA *data,
738 #define ctdb_reqid_find(ctdb, reqid, type) (type *)_ctdb_reqid_find(ctdb, reqid, #type, __location__)
740 void ctdb_recv_raw_pkt(void *p, uint8_t *data, uint32_t length);
742 int ctdb_socket_connect(struct ctdb_context *ctdb);
744 void ctdb_latency(double *latency, struct timeval t);
746 uint32_t ctdb_reqid_new(struct ctdb_context *ctdb, void *state);
747 void *_ctdb_reqid_find(struct ctdb_context *ctdb, uint32_t reqid, const char *type, const char *location);
748 void ctdb_reqid_remove(struct ctdb_context *ctdb, uint32_t reqid);
750 void ctdb_request_control(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
751 void ctdb_reply_control(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
753 int ctdb_daemon_send_control(struct ctdb_context *ctdb, uint32_t destnode,
754 uint64_t srvid, uint32_t opcode, uint32_t client_id, uint32_t flags,
756 ctdb_control_callback_fn_t callback,
759 int32_t ctdb_control_db_attach(struct ctdb_context *ctdb, TDB_DATA indata,
762 int ctdb_daemon_set_call(struct ctdb_context *ctdb, uint32_t db_id,
763 ctdb_fn_t fn, int id);
765 int ctdb_control(struct ctdb_context *ctdb, uint32_t destnode, uint64_t srvid,
766 uint32_t opcode, uint32_t flags, TDB_DATA data,
767 TALLOC_CTX *mem_ctx, TDB_DATA *outdata, int32_t *status,
768 struct timeval *timeout, char **errormsg);
773 #define CHECK_CONTROL_DATA_SIZE(size) do { \
774 if (indata.dsize != size) { \
775 DEBUG(0,(__location__ " Invalid data size in opcode %u. Got %u expected %u\n", \
776 opcode, (unsigned)indata.dsize, (unsigned)size)); \
781 int ctdb_control_getvnnmap(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata);
782 int ctdb_control_setvnnmap(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata);
783 int ctdb_control_getdbmap(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata);
784 int ctdb_control_getnodemap(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata);
785 int ctdb_control_writerecord(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata);
788 struct ctdb_traverse_start {
795 structure used to pass record data between the child and parent
797 struct ctdb_rec_data {
806 /* structure used for pulldb control */
807 struct ctdb_control_pulldb {
812 /* structure used for pulldb control */
813 struct ctdb_control_pulldb_reply {
819 /* set dmaster control structure */
820 struct ctdb_control_set_dmaster {
825 /* table that contains a list of all nodes a ctdb knows about and their
828 struct ctdb_node_and_flags {
831 struct sockaddr_in sin;
835 struct ctdb_node_map {
837 struct ctdb_node_and_flags nodes[1];
840 int32_t ctdb_control_traverse_start(struct ctdb_context *ctdb, TDB_DATA indata,
841 TDB_DATA *outdata, uint32_t srcnode);
842 int32_t ctdb_control_traverse_all(struct ctdb_context *ctdb, TDB_DATA data, TDB_DATA *outdata);
843 int32_t ctdb_control_traverse_data(struct ctdb_context *ctdb, TDB_DATA data, TDB_DATA *outdata);
845 int ctdb_dispatch_message(struct ctdb_context *ctdb, uint64_t srvid, TDB_DATA data);
847 int daemon_register_message_handler(struct ctdb_context *ctdb, uint32_t client_id, uint64_t srvid);
848 int ctdb_deregister_message_handler(struct ctdb_context *ctdb, uint64_t srvid, void *private_data);
849 int daemon_deregister_message_handler(struct ctdb_context *ctdb, uint32_t client_id, uint64_t srvid);
851 int32_t ctdb_ltdb_enable_seqnum(struct ctdb_context *ctdb, uint32_t db_id);
852 int32_t ctdb_ltdb_update_seqnum(struct ctdb_context *ctdb, uint32_t db_id, uint32_t srcnode);
853 int32_t ctdb_ltdb_set_seqnum_frequency(struct ctdb_context *ctdb, uint32_t frequency);
855 struct ctdb_rec_data *ctdb_marshall_record(TALLOC_CTX *mem_ctx, uint32_t reqid, TDB_DATA key, TDB_DATA data);
857 int32_t ctdb_control_pull_db(struct ctdb_context *ctdb, TDB_DATA indata, TDB_DATA *outdata);
858 int32_t ctdb_control_push_db(struct ctdb_context *ctdb, TDB_DATA indata);
859 int32_t ctdb_control_set_dmaster(struct ctdb_context *ctdb, TDB_DATA indata);
860 int32_t ctdb_control_clear_db(struct ctdb_context *ctdb, TDB_DATA indata);
862 int32_t ctdb_control_set_recmode(struct ctdb_context *ctdb,
863 struct ctdb_req_control *c,
864 TDB_DATA indata, bool *async_reply,
865 const char **errormsg);
866 void ctdb_request_control_reply(struct ctdb_context *ctdb, struct ctdb_req_control *c,
867 TDB_DATA *outdata, int32_t status, const char *errormsg);
869 int32_t ctdb_control_freeze(struct ctdb_context *ctdb, struct ctdb_req_control *c, bool *async_reply);
870 int32_t ctdb_control_thaw(struct ctdb_context *ctdb);
872 int ctdb_start_recoverd(struct ctdb_context *ctdb);
874 uint32_t ctdb_get_num_connected_nodes(struct ctdb_context *ctdb);
876 int ctdb_start_monitoring(struct ctdb_context *ctdb);
877 void ctdb_send_keepalive(struct ctdb_context *ctdb, uint32_t destnode);
879 void ctdb_daemon_cancel_controls(struct ctdb_context *ctdb, struct ctdb_node *node);
880 void ctdb_call_resend_all(struct ctdb_context *ctdb);
881 void ctdb_node_dead(struct ctdb_node *node);
882 void ctdb_node_connected(struct ctdb_node *node);
883 bool ctdb_blocking_freeze(struct ctdb_context *ctdb);
884 int32_t ctdb_control_max_rsn(struct ctdb_context *ctdb, TDB_DATA indata, TDB_DATA *outdata);
885 int32_t ctdb_control_set_rsn_nonempty(struct ctdb_context *ctdb, TDB_DATA indata, TDB_DATA *outdata);
886 int32_t ctdb_control_delete_low_rsn(struct ctdb_context *ctdb, TDB_DATA indata, TDB_DATA *outdata);
887 int ctdb_ctrl_get_max_rsn(struct ctdb_context *ctdb, struct timeval timeout,
888 uint32_t destnode, uint32_t db_id, uint64_t *max_rsn);
889 int ctdb_ctrl_set_rsn_nonempty(struct ctdb_context *ctdb, struct timeval timeout,
890 uint32_t destnode, uint32_t db_id, uint64_t rsn);
891 int ctdb_ctrl_delete_low_rsn(struct ctdb_context *ctdb, struct timeval timeout,
892 uint32_t destnode, uint32_t db_id, uint64_t rsn);
893 void ctdb_set_realtime(bool enable);
894 int32_t ctdb_control_takeover_ip(struct ctdb_context *ctdb,
895 struct ctdb_req_control *c,
898 int ctdb_ctrl_takeover_ip(struct ctdb_context *ctdb, struct timeval timeout,
899 uint32_t destnode, const char *ip);
900 int32_t ctdb_control_release_ip(struct ctdb_context *ctdb,
901 struct ctdb_req_control *c,
904 int ctdb_ctrl_release_ip(struct ctdb_context *ctdb, struct timeval timeout,
905 uint32_t destnode, const char *ip);
907 /* from takeover/system.c */
908 int ctdb_sys_send_arp(const struct sockaddr_in *saddr, const char *iface);
909 bool ctdb_sys_have_ip(const char *ip);
910 int ctdb_sys_send_ack(const struct sockaddr_in *dest,
911 const struct sockaddr_in *src);
913 int ctdb_set_public_addresses(struct ctdb_context *ctdb, const char *alist);
914 int ctdb_set_event_script(struct ctdb_context *ctdb, const char *script);
915 int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap);
917 int32_t ctdb_control_tcp_client(struct ctdb_context *ctdb, uint32_t client_id,
918 uint32_t srcnode, TDB_DATA indata);
919 int32_t ctdb_control_tcp_add(struct ctdb_context *ctdb, TDB_DATA indata);
920 int32_t ctdb_control_tcp_remove(struct ctdb_context *ctdb, TDB_DATA indata);
921 int32_t ctdb_control_startup(struct ctdb_context *ctdb, uint32_t vnn);
923 void ctdb_takeover_client_destructor_hook(struct ctdb_client *client);
924 int ctdb_event_script(struct ctdb_context *ctdb, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
925 int ctdb_event_script_callback(struct ctdb_context *ctdb,
927 void (*callback)(struct ctdb_context *, int, void *),
929 const char *fmt, ...) PRINTF_ATTRIBUTE(5,6);
930 void ctdb_release_all_ips(struct ctdb_context *ctdb);
932 void set_nonblocking(int fd);
933 void set_close_on_exec(int fd);
935 bool ctdb_recovery_lock(struct ctdb_context *ctdb, bool keep);
937 int ctdb_set_recovery_lock_file(struct ctdb_context *ctdb, const char *file);