client: Add ctdb_ctrl_getdbstatistics() function
[ctdb.git] / include / ctdb_client.h
1 /*
2    ctdb database library: old client interface
3
4    Copyright (C) Andrew Tridgell  2006
5
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.
10
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.
15
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/>.
18 */
19
20 #ifndef _CTDB_CLIENT_H
21 #define _CTDB_CLIENT_H
22 #include "ctdb_protocol.h"
23
24 enum control_state {CTDB_CONTROL_WAIT, CTDB_CONTROL_DONE, CTDB_CONTROL_ERROR, CTDB_CONTROL_TIMEOUT};
25
26 struct ctdb_client_control_state {
27         struct ctdb_context *ctdb;
28         uint32_t reqid;
29         int32_t status;
30         TDB_DATA outdata;
31         enum control_state state;
32         char *errormsg;
33         struct ctdb_req_control *c;
34
35         /* if we have a callback registered for the completion (or failure) of
36            this control
37            if a callback is used, it MUST talloc_free the cb_data passed to it
38         */
39         struct {
40                 void (*fn)(struct ctdb_client_control_state *);
41                 void *private_data;
42         } async;
43 };
44
45 struct ctdb_client_notify_register {
46         uint64_t srvid;
47         uint32_t len;
48         uint8_t notify_data[1];
49 };
50
51 struct ctdb_client_notify_deregister {
52         uint64_t srvid;
53 };
54
55 struct tevent_context;
56
57 /*
58   initialise ctdb subsystem
59 */
60 struct ctdb_context *ctdb_init(struct tevent_context *ev);
61
62 /*
63   choose the transport
64 */
65 int ctdb_set_transport(struct ctdb_context *ctdb, const char *transport);
66
67 /*
68   set the directory for the local databases
69 */
70 int ctdb_set_tdb_dir(struct ctdb_context *ctdb, const char *dir);
71 int ctdb_set_tdb_dir_persistent(struct ctdb_context *ctdb, const char *dir);
72 int ctdb_set_tdb_dir_state(struct ctdb_context *ctdb, const char *dir);
73
74 /*
75   set some flags
76 */
77 void ctdb_set_flags(struct ctdb_context *ctdb, unsigned flags);
78
79 /*
80   tell ctdb what address to listen on, in transport specific format
81 */
82 int ctdb_set_address(struct ctdb_context *ctdb, const char *address);
83
84 int ctdb_set_socketname(struct ctdb_context *ctdb, const char *socketname);
85 const char *ctdb_get_socketname(struct ctdb_context *ctdb);
86
87 /*
88   tell ctdb what nodes are available. This takes a filename, which will contain
89   1 node address per line, in a transport specific format
90 */
91 int ctdb_set_nlist(struct ctdb_context *ctdb, const char *nlist);
92
93 /*
94   Check that a specific ip address exists in the node list and returns
95   the id for the node or -1
96 */
97 int ctdb_ip_to_nodeid(struct ctdb_context *ctdb, const char *nodeip);
98
99 /*
100   start the ctdb protocol
101 */
102 int ctdb_start(struct ctdb_context *ctdb);
103
104 /*
105   attach to a ctdb database
106 */
107 struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb,
108                                     struct timeval timeout,
109                                     const char *name,
110                                     bool persistent,
111                                     uint32_t tdb_flags);
112
113
114 /*
115   find an attached ctdb_db handle given a name
116  */
117 struct ctdb_db_context *ctdb_db_handle(struct ctdb_context *ctdb, const char *name);
118
119 /*
120   error string for last ctdb error
121 */
122 const char *ctdb_errstr(struct ctdb_context *);
123
124 /* a ctdb call function */
125 typedef int (*ctdb_fn_t)(struct ctdb_call_info *);
126
127 /*
128   setup a ctdb call function
129 */
130 int ctdb_set_call(struct ctdb_db_context *ctdb_db, ctdb_fn_t fn, uint32_t id);
131
132
133
134 /*
135   make a ctdb call. The associated ctdb call function will be called on the DMASTER
136   for the given record
137 */
138 int ctdb_call(struct ctdb_db_context *ctdb_db, struct ctdb_call *call);
139
140 /*
141   initiate an ordered ctdb cluster shutdown
142   this function will never return
143 */
144 void ctdb_shutdown(struct ctdb_context *ctdb);
145
146 /* return pnn of this node */
147 uint32_t ctdb_get_pnn(struct ctdb_context *ctdb);
148
149 /*
150   return the number of nodes
151 */
152 uint32_t ctdb_get_num_nodes(struct ctdb_context *ctdb);
153
154 /* setup a handler for ctdb messages */
155 typedef void (*ctdb_msg_fn_t)(struct ctdb_context *, uint64_t srvid,
156                                   TDB_DATA data, void *);
157 int ctdb_client_set_message_handler(struct ctdb_context *ctdb, uint64_t srvid,
158                              ctdb_msg_fn_t handler,
159                              void *private_data);
160 int ctdb_client_remove_message_handler(struct ctdb_context *ctdb,
161                                        uint64_t srvid, void *private_data);
162 int ctdb_client_check_message_handlers(struct ctdb_context *ctdb,
163                                        uint64_t *ids, uint32_t num,
164                                        uint8_t *result);
165
166 int ctdb_call(struct ctdb_db_context *ctdb_db, struct ctdb_call *call);
167 struct ctdb_client_call_state *ctdb_call_send(struct ctdb_db_context *ctdb_db, struct ctdb_call *call);
168 int ctdb_call_recv(struct ctdb_client_call_state *state, struct ctdb_call *call);
169
170 /* send a ctdb message */
171 int ctdb_client_send_message(struct ctdb_context *ctdb, uint32_t pnn,
172                       uint64_t srvid, TDB_DATA data);
173
174
175 /*
176    Fetch a ctdb record from a remote node
177  . Underneath this will force the
178    dmaster for the record to be moved to the local node.
179 */
180 struct ctdb_record_handle *ctdb_fetch_lock(struct ctdb_db_context *ctdb_db, TALLOC_CTX *mem_ctx,
181                                            TDB_DATA key, TDB_DATA *data);
182
183 struct ctdb_record_handle *ctdb_fetch_readonly_lock(struct ctdb_db_context *ctdb_db, TALLOC_CTX *mem_ctx, TDB_DATA key, TDB_DATA *data, int read_only);
184
185 int ctdb_record_store(struct ctdb_record_handle *h, TDB_DATA data);
186
187 int ctdb_fetch(struct ctdb_db_context *ctdb_db, TALLOC_CTX *mem_ctx,
188                TDB_DATA key, TDB_DATA *data);
189
190 int ctdb_register_message_handler(struct ctdb_context *ctdb,
191                                   TALLOC_CTX *mem_ctx,
192                                   uint64_t srvid,
193                                   ctdb_msg_fn_t handler,
194                                   void *private_data);
195
196 struct ctdb_db_context *find_ctdb_db(struct ctdb_context *ctdb, uint32_t id);
197
198
199 struct ctdb_context *ctdb_cmdline_client(struct tevent_context *ev,
200                                          struct timeval req_timeout);
201
202 struct ctdb_statistics;
203 int ctdb_ctrl_statistics(struct ctdb_context *ctdb, uint32_t destnode, struct ctdb_statistics *status);
204 int ctdb_ctrl_dbstatistics(struct ctdb_context *ctdb, uint32_t destnode, uint32_t dbid,
205                            TALLOC_CTX *mem_ctx, struct ctdb_db_statistics **dbstat);
206
207 int ctdb_ctrl_shutdown(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
208
209 struct ctdb_vnn_map;
210 int ctdb_ctrl_getvnnmap(struct ctdb_context *ctdb,
211                 struct timeval timeout, uint32_t destnode,
212                 TALLOC_CTX *mem_ctx, struct ctdb_vnn_map **vnnmap);
213 int ctdb_ctrl_setvnnmap(struct ctdb_context *ctdb,
214                 struct timeval timeout, uint32_t destnode,
215                 TALLOC_CTX *mem_ctx, struct ctdb_vnn_map *vnnmap);
216
217 /* table that contains a list of all dbids on a node
218  */
219 struct ctdb_dbid_map {
220         uint32_t num;
221         struct ctdb_dbid {
222                 uint32_t dbid;
223 #define CTDB_DB_FLAGS_PERSISTENT        0x01
224 #define CTDB_DB_FLAGS_READONLY          0x02
225 #define CTDB_DB_FLAGS_STICKY            0x04
226                 uint8_t flags;
227         } dbs[1];
228 };
229 int ctdb_ctrl_getdbmap(struct ctdb_context *ctdb,
230         struct timeval timeout, uint32_t destnode,
231         TALLOC_CTX *mem_ctx, struct ctdb_dbid_map **dbmap);
232
233
234 struct ctdb_node_map;
235
236 int ctdb_ctrl_getnodemap(struct ctdb_context *ctdb,
237                     struct timeval timeout, uint32_t destnode,
238                     TALLOC_CTX *mem_ctx, struct ctdb_node_map **nodemap);
239
240 int ctdb_ctrl_getnodemapv4(struct ctdb_context *ctdb,
241                     struct timeval timeout, uint32_t destnode,
242                     TALLOC_CTX *mem_ctx, struct ctdb_node_map **nodemap);
243
244 int ctdb_ctrl_reload_nodes_file(struct ctdb_context *ctdb,
245                     struct timeval timeout, uint32_t destnode);
246
247 struct ctdb_key_list {
248         uint32_t dbid;
249         uint32_t num;
250         TDB_DATA *keys;
251         struct ctdb_ltdb_header *headers;
252         TDB_DATA *data;
253 };
254
255 int ctdb_ctrl_pulldb(
256        struct ctdb_context *ctdb, uint32_t destnode, uint32_t dbid,
257        uint32_t lmaster, TALLOC_CTX *mem_ctx,
258        struct timeval timeout, TDB_DATA *outdata);
259
260 struct ctdb_client_control_state *ctdb_ctrl_pulldb_send(
261        struct ctdb_context *ctdb, uint32_t destnode, uint32_t dbid,
262        uint32_t lmaster, TALLOC_CTX *mem_ctx, struct timeval timeout);
263
264 int ctdb_ctrl_pulldb_recv(
265        struct ctdb_context *ctdb,
266        TALLOC_CTX *mem_ctx, struct ctdb_client_control_state *state,
267        TDB_DATA *outdata);
268
269 int ctdb_ctrl_pushdb(
270        struct ctdb_context *ctdb, uint32_t destnode, uint32_t dbid,
271        TALLOC_CTX *mem_ctx,
272        struct timeval timeout, TDB_DATA indata);
273
274 struct ctdb_client_control_state *ctdb_ctrl_pushdb_send(
275        struct ctdb_context *ctdb, uint32_t destnode, uint32_t dbid,
276        TALLOC_CTX *mem_ctx, struct timeval timeout,
277        TDB_DATA indata);
278
279 int ctdb_ctrl_pushdb_recv(
280        struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx,
281        struct ctdb_client_control_state *state);
282
283
284 int ctdb_ctrl_copydb(struct ctdb_context *ctdb,
285         struct timeval timeout, uint32_t sourcenode,
286         uint32_t destnode, uint32_t dbid, uint32_t lmaster,
287         TALLOC_CTX *mem_ctx);
288
289 int ctdb_ctrl_getdbpath(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t dbid, TALLOC_CTX *mem_ctx, const char **path);
290 int ctdb_ctrl_getdbname(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t dbid, TALLOC_CTX *mem_ctx, const char **name);
291 int ctdb_ctrl_getdbhealth(struct ctdb_context *ctdb,
292                           struct timeval timeout,
293                           uint32_t destnode,
294                           uint32_t dbid, TALLOC_CTX *mem_ctx,
295                           const char **reason);
296 int ctdb_ctrl_createdb(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, TALLOC_CTX *mem_ctx, const char *name, bool persistent);
297
298 int ctdb_ctrl_process_exists(struct ctdb_context *ctdb, uint32_t destnode, pid_t pid);
299
300 int ctdb_ctrl_ping(struct ctdb_context *ctdb, uint32_t destnode);
301
302 int ctdb_ctrl_get_runstate(struct ctdb_context *ctdb, 
303                            struct timeval timeout, 
304                            uint32_t destnode,
305                            uint32_t *runstate);
306
307 int ctdb_ctrl_get_config(struct ctdb_context *ctdb);
308
309 int ctdb_ctrl_get_debuglevel(struct ctdb_context *ctdb, uint32_t destnode, int32_t *level);
310 int ctdb_ctrl_set_debuglevel(struct ctdb_context *ctdb, uint32_t destnode, int32_t level);
311
312 /*
313   change dmaster for all keys in the database to the new value
314  */
315 int ctdb_ctrl_setdmaster(struct ctdb_context *ctdb,
316         struct timeval timeout, uint32_t destnode,
317         TALLOC_CTX *mem_ctx, uint32_t dbid, uint32_t dmaster);
318
319 /*
320   write a record on a specific db (this implicitely updates dmaster of the record to locally be the vnn of the node where the control is executed on)
321  */
322 int ctdb_ctrl_write_record(struct ctdb_context *ctdb, uint32_t destnode, TALLOC_CTX *mem_ctx, uint32_t dbid, TDB_DATA key, TDB_DATA data);
323
324 #define CTDB_RECOVERY_NORMAL            0
325 #define CTDB_RECOVERY_ACTIVE            1
326
327 /*
328   get the recovery mode of a remote node
329  */
330 int ctdb_ctrl_getrecmode(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode, uint32_t *recmode);
331
332 struct ctdb_client_control_state *ctdb_ctrl_getrecmode_send(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode);
333
334 int ctdb_ctrl_getrecmode_recv(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct ctdb_client_control_state *state, uint32_t *recmode);
335
336
337 /*
338   set the recovery mode of a remote node
339  */
340 int ctdb_ctrl_setrecmode(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t recmode);
341 /*
342   get the monitoring mode of a remote node
343  */
344 int ctdb_ctrl_getmonmode(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t *monmode);
345
346 /*
347   set the monitoring mode of a remote node to active
348  */
349 int ctdb_ctrl_enable_monmode(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
350
351 /*
352   set the monitoring mode of a remote node to disabled
353  */
354 int ctdb_ctrl_disable_monmode(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
355
356
357 /*
358   get the recovery master of a remote node
359  */
360 int ctdb_ctrl_getrecmaster(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode, uint32_t *recmaster);
361
362 struct ctdb_client_control_state *ctdb_ctrl_getrecmaster_send(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode);
363
364 int ctdb_ctrl_getrecmaster_recv(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct ctdb_client_control_state *state, uint32_t *recmaster);
365
366
367
368 /*
369   set the recovery master of a remote node
370  */
371 int ctdb_ctrl_setrecmaster(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t recmaster);
372
373 uint32_t *ctdb_get_connected_nodes(struct ctdb_context *ctdb,
374                                    struct timeval timeout,
375                                    TALLOC_CTX *mem_ctx,
376                                    uint32_t *num_nodes);
377
378 int ctdb_statistics_reset(struct ctdb_context *ctdb, uint32_t destnode);
379
380 int ctdb_set_logfile(struct ctdb_context *ctdb, const char *logfile, bool use_syslog);
381
382 typedef int (*ctdb_traverse_func)(struct ctdb_context *, TDB_DATA, TDB_DATA, void *);
383 int ctdb_traverse(struct ctdb_db_context *ctdb_db, ctdb_traverse_func fn, void *private_data);
384
385 struct ctdb_dump_db_context {
386         FILE *f;
387         bool printemptyrecords;
388         bool printdatasize;
389         bool printlmaster;
390         bool printhash;
391         bool printrecordflags;
392 };
393
394 int ctdb_dumpdb_record(struct ctdb_context *ctdb, TDB_DATA key, TDB_DATA data, void *p);
395 int ctdb_dump_db(struct ctdb_db_context *ctdb_db,
396                  struct ctdb_dump_db_context *ctx);
397
398 /*
399   get the pid of a ctdb daemon
400  */
401 int ctdb_ctrl_getpid(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t *pid);
402
403 int ctdb_ctrl_freeze(struct ctdb_context *ctdb, struct timeval timeout,
404                         uint32_t destnode);
405 int ctdb_ctrl_freeze_priority(struct ctdb_context *ctdb, struct timeval timeout,
406                               uint32_t destnode, uint32_t priority);
407
408 struct ctdb_client_control_state *
409 ctdb_ctrl_freeze_send(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx,
410                       struct timeval timeout, uint32_t destnode,
411                       uint32_t priority);
412
413 int ctdb_ctrl_freeze_recv(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx,
414                         struct ctdb_client_control_state *state);
415
416 int ctdb_ctrl_thaw_priority(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t priority);
417 int ctdb_ctrl_thaw(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
418
419 int ctdb_ctrl_getpnn(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
420
421 int ctdb_ctrl_get_tunable(struct ctdb_context *ctdb,
422                           struct timeval timeout,
423                           uint32_t destnode,
424                           const char *name, uint32_t *value);
425
426 int ctdb_ctrl_set_tunable(struct ctdb_context *ctdb,
427                           struct timeval timeout,
428                           uint32_t destnode,
429                           const char *name, uint32_t value);
430
431 int ctdb_ctrl_list_tunables(struct ctdb_context *ctdb,
432                             struct timeval timeout,
433                             uint32_t destnode,
434                             TALLOC_CTX *mem_ctx,
435                             const char ***list, uint32_t *count);
436
437 int ctdb_ctrl_modflags(struct ctdb_context *ctdb,
438                        struct timeval timeout,
439                        uint32_t destnode,
440                        uint32_t set, uint32_t clear);
441
442 enum ctdb_server_id_type {
443         SERVER_TYPE_SAMBA=1,
444         SERVER_TYPE_NFSD=2,
445         SERVER_TYPE_ISCSID=3
446 };
447
448 struct ctdb_server_id {
449         enum ctdb_server_id_type type;
450         uint32_t pnn;
451         uint32_t server_id;
452 };
453
454 struct ctdb_server_id_list {
455         uint32_t num;
456         struct ctdb_server_id server_ids[1];
457 };
458
459
460 int ctdb_ctrl_register_server_id(struct ctdb_context *ctdb,
461                 struct timeval timeout,
462                 struct ctdb_server_id *id);
463 int ctdb_ctrl_unregister_server_id(struct ctdb_context *ctdb,
464                 struct timeval timeout,
465                 struct ctdb_server_id *id);
466 int ctdb_ctrl_check_server_id(struct ctdb_context *ctdb,
467                 struct timeval timeout, uint32_t destnode,
468                 struct ctdb_server_id *id, uint32_t *status);
469 int ctdb_ctrl_get_server_id_list(struct ctdb_context *ctdb,
470                 TALLOC_CTX *mem_ctx,
471                 struct timeval timeout, uint32_t destnode,
472                 struct ctdb_server_id_list **svid_list);
473
474 struct ctdb_uptime {
475         struct timeval current_time;
476         struct timeval ctdbd_start_time;
477         struct timeval last_recovery_started;
478         struct timeval last_recovery_finished;
479 };
480
481 /*
482   struct for tcp_client control
483   this is an ipv4 only version of this structure used by samba
484   samba will later be migrated over to use the
485   ctdb_control_tcp_addr structure instead
486  */
487 struct ctdb_control_tcp {
488         struct sockaddr_in src; // samba uses this
489         struct sockaddr_in dest;// samba uses this
490 };
491 /* new style structure */
492 struct ctdb_control_tcp_addr {
493         ctdb_sock_addr src;
494         ctdb_sock_addr dest;
495 };
496
497 int ctdb_socket_connect(struct ctdb_context *ctdb);
498
499 /*
500   get the uptime of a remote node
501  */
502 int ctdb_ctrl_uptime(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode, struct ctdb_uptime **uptime);
503
504 struct ctdb_client_control_state *ctdb_ctrl_uptime_send(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode);
505
506 int ctdb_ctrl_uptime_recv(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct ctdb_client_control_state *state, struct ctdb_uptime **uptime);
507
508 int ctdb_ctrl_end_recovery(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
509
510 int ctdb_ctrl_getreclock(struct ctdb_context *ctdb,
511         struct timeval timeout, uint32_t destnode,
512         TALLOC_CTX *mem_ctx, const char **reclock);
513 int ctdb_ctrl_setreclock(struct ctdb_context *ctdb,
514         struct timeval timeout, uint32_t destnode,
515         const char *reclock);
516
517
518 uint32_t *list_of_nodes(struct ctdb_context *ctdb,
519                         struct ctdb_node_map *node_map,
520                         TALLOC_CTX *mem_ctx,
521                         uint32_t mask,
522                         int exclude_pnn);
523 uint32_t *list_of_connected_nodes(struct ctdb_context *ctdb,
524                                 struct ctdb_node_map *node_map,
525                                 TALLOC_CTX *mem_ctx,
526                                 bool include_self);
527 uint32_t *list_of_active_nodes(struct ctdb_context *ctdb,
528                                 struct ctdb_node_map *node_map,
529                                 TALLOC_CTX *mem_ctx,
530                                 bool include_self);
531 uint32_t *list_of_vnnmap_nodes(struct ctdb_context *ctdb,
532                                 struct ctdb_vnn_map *vnn_map,
533                                 TALLOC_CTX *mem_ctx,
534                                 bool include_self);
535
536 int ctdb_read_pnn_lock(int fd, int32_t pnn);
537
538 /*
539   get capabilities of a remote node
540  */
541 int ctdb_ctrl_getcapabilities(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t *capabilities);
542
543 struct ctdb_client_control_state *ctdb_ctrl_getcapabilities_send(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode);
544
545 int ctdb_ctrl_getcapabilities_recv(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct ctdb_client_control_state *state, uint32_t *capabilities);
546
547
548 int32_t ctdb_ctrl_transaction_active(struct ctdb_context *ctdb,
549                                      uint32_t destnode,
550                                      uint32_t db_id);
551
552 struct ctdb_marshall_buffer *ctdb_marshall_add(TALLOC_CTX *mem_ctx,
553                                                struct ctdb_marshall_buffer *m,
554                                                uint64_t db_id,
555                                                uint32_t reqid,
556                                                TDB_DATA key,
557                                                struct ctdb_ltdb_header *header,
558                                                TDB_DATA data);
559 TDB_DATA ctdb_marshall_finish(struct ctdb_marshall_buffer *m);
560
561 struct ctdb_transaction_handle *ctdb_transaction_start(struct ctdb_db_context *ctdb_db,
562                                                        TALLOC_CTX *mem_ctx);
563 int ctdb_transaction_fetch(struct ctdb_transaction_handle *h,
564                            TALLOC_CTX *mem_ctx,
565                            TDB_DATA key, TDB_DATA *data);
566 int ctdb_transaction_store(struct ctdb_transaction_handle *h,
567                            TDB_DATA key, TDB_DATA data);
568 int ctdb_transaction_commit(struct ctdb_transaction_handle *h);
569
570 int ctdb_ctrl_recd_ping(struct ctdb_context *ctdb);
571
572 int switch_from_server_to_client(struct ctdb_context *ctdb, const char *fmt,
573                                  ...);
574
575 int ctdb_ctrl_getscriptstatus(struct ctdb_context *ctdb,
576                     struct timeval timeout, uint32_t destnode,
577                     TALLOC_CTX *mem_ctx, enum ctdb_eventscript_call type,
578                     struct ctdb_scripts_wire **script_status);
579
580
581 struct debug_levels {
582         int32_t level;
583         const char *description;
584 };
585 extern struct debug_levels debug_levels[];
586
587 const char *get_debug_by_level(int32_t level);
588 int32_t get_debug_by_desc(const char *desc);
589
590 int ctdb_ctrl_stop_node(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
591 int ctdb_ctrl_continue_node(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
592
593 int ctdb_ctrl_setnatgwstate(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t natgwstate);
594 int ctdb_ctrl_setlmasterrole(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t lmasterrole);
595 int ctdb_ctrl_setrecmasterrole(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t recmasterrole);
596
597 int ctdb_ctrl_enablescript(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, const char *script);
598 int ctdb_ctrl_disablescript(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, const char *script);
599
600 struct ctdb_ban_time {
601         uint32_t pnn;
602         uint32_t time;
603 };
604
605 int ctdb_ctrl_set_ban(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, struct ctdb_ban_time *bantime);
606 int ctdb_ctrl_get_ban(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, TALLOC_CTX *mem_ctx, struct ctdb_ban_time **bantime);
607
608 struct ctdb_db_priority {
609         uint32_t db_id;
610         uint32_t priority;
611 };
612
613 int ctdb_ctrl_set_db_priority(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, struct ctdb_db_priority *db_prio);
614 int ctdb_ctrl_get_db_priority(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t db_id, uint32_t *priority);
615
616 int ctdb_ctrl_getstathistory(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, TALLOC_CTX *mem_ctx, struct ctdb_statistics_wire **stats);
617
618
619
620 struct ctdb_client_control_state *
621 ctdb_ctrl_updaterecord_send(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode, struct ctdb_db_context *ctdb_db, TDB_DATA key, struct ctdb_ltdb_header *header, TDB_DATA data);
622
623 int ctdb_ctrl_updaterecord_recv(struct ctdb_context *ctdb, struct ctdb_client_control_state *state);
624
625 int
626 ctdb_ctrl_updaterecord(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode, struct ctdb_db_context *ctdb_db, TDB_DATA key, struct ctdb_ltdb_header *header, TDB_DATA data);
627
628
629 struct ctdb_client_control_state *
630 ctdb_ctrl_set_db_readonly_send(struct ctdb_context *ctdb, uint32_t destnode, uint32_t dbid);
631 int ctdb_ctrl_set_db_readonly_recv(struct ctdb_context *ctdb, struct ctdb_client_control_state *state);
632 int ctdb_ctrl_set_db_readonly(struct ctdb_context *ctdb, uint32_t destnode, uint32_t dbid);
633
634 struct ctdb_client_control_state *
635 ctdb_ctrl_set_db_sticky_send(struct ctdb_context *ctdb, uint32_t destnode, uint32_t dbid);
636 int ctdb_ctrl_set_db_sticky_recv(struct ctdb_context *ctdb, struct ctdb_client_control_state *state);
637 int ctdb_ctrl_set_db_sticky(struct ctdb_context *ctdb, uint32_t destnode, uint32_t dbid);
638
639 #endif /* _CTDB_CLIENT_H */