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