client: Reimplement persistent transaction code using TRANS3_COMMIT
[vlendec/samba-autobuild/.git] / ctdb / 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_getdbseqnum(struct ctdb_context *ctdb, struct timeval timeout,
297                           uint32_t destnode, uint32_t dbid, uint64_t *seqnum);
298 int ctdb_ctrl_createdb(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, TALLOC_CTX *mem_ctx, const char *name, bool persistent);
299
300 int ctdb_ctrl_process_exists(struct ctdb_context *ctdb, uint32_t destnode, pid_t pid);
301
302 int ctdb_ctrl_ping(struct ctdb_context *ctdb, uint32_t destnode);
303
304 int ctdb_ctrl_get_runstate(struct ctdb_context *ctdb, 
305                            struct timeval timeout, 
306                            uint32_t destnode,
307                            uint32_t *runstate);
308
309 int ctdb_ctrl_get_config(struct ctdb_context *ctdb);
310
311 int ctdb_ctrl_get_debuglevel(struct ctdb_context *ctdb, uint32_t destnode, int32_t *level);
312 int ctdb_ctrl_set_debuglevel(struct ctdb_context *ctdb, uint32_t destnode, int32_t level);
313
314 /*
315   change dmaster for all keys in the database to the new value
316  */
317 int ctdb_ctrl_setdmaster(struct ctdb_context *ctdb,
318         struct timeval timeout, uint32_t destnode,
319         TALLOC_CTX *mem_ctx, uint32_t dbid, uint32_t dmaster);
320
321 /*
322   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)
323  */
324 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);
325
326 #define CTDB_RECOVERY_NORMAL            0
327 #define CTDB_RECOVERY_ACTIVE            1
328
329 /*
330   get the recovery mode of a remote node
331  */
332 int ctdb_ctrl_getrecmode(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode, uint32_t *recmode);
333
334 struct ctdb_client_control_state *ctdb_ctrl_getrecmode_send(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode);
335
336 int ctdb_ctrl_getrecmode_recv(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct ctdb_client_control_state *state, uint32_t *recmode);
337
338
339 /*
340   set the recovery mode of a remote node
341  */
342 int ctdb_ctrl_setrecmode(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t recmode);
343 /*
344   get the monitoring mode of a remote node
345  */
346 int ctdb_ctrl_getmonmode(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t *monmode);
347
348 /*
349   set the monitoring mode of a remote node to active
350  */
351 int ctdb_ctrl_enable_monmode(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
352
353 /*
354   set the monitoring mode of a remote node to disabled
355  */
356 int ctdb_ctrl_disable_monmode(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
357
358
359 /*
360   get the recovery master of a remote node
361  */
362 int ctdb_ctrl_getrecmaster(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode, uint32_t *recmaster);
363
364 struct ctdb_client_control_state *ctdb_ctrl_getrecmaster_send(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode);
365
366 int ctdb_ctrl_getrecmaster_recv(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct ctdb_client_control_state *state, uint32_t *recmaster);
367
368
369
370 /*
371   set the recovery master of a remote node
372  */
373 int ctdb_ctrl_setrecmaster(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t recmaster);
374
375 uint32_t *ctdb_get_connected_nodes(struct ctdb_context *ctdb,
376                                    struct timeval timeout,
377                                    TALLOC_CTX *mem_ctx,
378                                    uint32_t *num_nodes);
379
380 int ctdb_statistics_reset(struct ctdb_context *ctdb, uint32_t destnode);
381
382 int ctdb_set_logfile(struct ctdb_context *ctdb, const char *logfile, bool use_syslog);
383
384 typedef int (*ctdb_traverse_func)(struct ctdb_context *, TDB_DATA, TDB_DATA, void *);
385 int ctdb_traverse(struct ctdb_db_context *ctdb_db, ctdb_traverse_func fn, void *private_data);
386
387 struct ctdb_dump_db_context {
388         FILE *f;
389         bool printemptyrecords;
390         bool printdatasize;
391         bool printlmaster;
392         bool printhash;
393         bool printrecordflags;
394 };
395
396 int ctdb_dumpdb_record(struct ctdb_context *ctdb, TDB_DATA key, TDB_DATA data, void *p);
397 int ctdb_dump_db(struct ctdb_db_context *ctdb_db,
398                  struct ctdb_dump_db_context *ctx);
399
400 /*
401   get the pid of a ctdb daemon
402  */
403 int ctdb_ctrl_getpid(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t *pid);
404
405 int ctdb_ctrl_freeze(struct ctdb_context *ctdb, struct timeval timeout,
406                         uint32_t destnode);
407 int ctdb_ctrl_freeze_priority(struct ctdb_context *ctdb, struct timeval timeout,
408                               uint32_t destnode, uint32_t priority);
409
410 struct ctdb_client_control_state *
411 ctdb_ctrl_freeze_send(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx,
412                       struct timeval timeout, uint32_t destnode,
413                       uint32_t priority);
414
415 int ctdb_ctrl_freeze_recv(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx,
416                         struct ctdb_client_control_state *state);
417
418 int ctdb_ctrl_thaw_priority(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t priority);
419 int ctdb_ctrl_thaw(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
420
421 int ctdb_ctrl_getpnn(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
422
423 int ctdb_ctrl_get_tunable(struct ctdb_context *ctdb,
424                           struct timeval timeout,
425                           uint32_t destnode,
426                           const char *name, uint32_t *value);
427
428 int ctdb_ctrl_set_tunable(struct ctdb_context *ctdb,
429                           struct timeval timeout,
430                           uint32_t destnode,
431                           const char *name, uint32_t value);
432
433 int ctdb_ctrl_list_tunables(struct ctdb_context *ctdb,
434                             struct timeval timeout,
435                             uint32_t destnode,
436                             TALLOC_CTX *mem_ctx,
437                             const char ***list, uint32_t *count);
438
439 int ctdb_ctrl_modflags(struct ctdb_context *ctdb,
440                        struct timeval timeout,
441                        uint32_t destnode,
442                        uint32_t set, uint32_t clear);
443
444 enum ctdb_server_id_type {
445         SERVER_TYPE_SAMBA=1,
446         SERVER_TYPE_NFSD=2,
447         SERVER_TYPE_ISCSID=3
448 };
449
450 struct ctdb_server_id {
451         enum ctdb_server_id_type type;
452         uint32_t pnn;
453         uint32_t server_id;
454 };
455
456 struct ctdb_server_id_list {
457         uint32_t num;
458         struct ctdb_server_id server_ids[1];
459 };
460
461
462 int ctdb_ctrl_register_server_id(struct ctdb_context *ctdb,
463                 struct timeval timeout,
464                 struct ctdb_server_id *id);
465 int ctdb_ctrl_unregister_server_id(struct ctdb_context *ctdb,
466                 struct timeval timeout,
467                 struct ctdb_server_id *id);
468 int ctdb_ctrl_check_server_id(struct ctdb_context *ctdb,
469                 struct timeval timeout, uint32_t destnode,
470                 struct ctdb_server_id *id, uint32_t *status);
471 int ctdb_ctrl_get_server_id_list(struct ctdb_context *ctdb,
472                 TALLOC_CTX *mem_ctx,
473                 struct timeval timeout, uint32_t destnode,
474                 struct ctdb_server_id_list **svid_list);
475
476 struct ctdb_uptime {
477         struct timeval current_time;
478         struct timeval ctdbd_start_time;
479         struct timeval last_recovery_started;
480         struct timeval last_recovery_finished;
481 };
482
483 /*
484   struct for tcp_client control
485   this is an ipv4 only version of this structure used by samba
486   samba will later be migrated over to use the
487   ctdb_control_tcp_addr structure instead
488  */
489 struct ctdb_control_tcp {
490         struct sockaddr_in src; // samba uses this
491         struct sockaddr_in dest;// samba uses this
492 };
493 /* new style structure */
494 struct ctdb_control_tcp_addr {
495         ctdb_sock_addr src;
496         ctdb_sock_addr dest;
497 };
498
499 int ctdb_socket_connect(struct ctdb_context *ctdb);
500
501 /*
502   get the uptime of a remote node
503  */
504 int ctdb_ctrl_uptime(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode, struct ctdb_uptime **uptime);
505
506 struct ctdb_client_control_state *ctdb_ctrl_uptime_send(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode);
507
508 int ctdb_ctrl_uptime_recv(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct ctdb_client_control_state *state, struct ctdb_uptime **uptime);
509
510 int ctdb_ctrl_end_recovery(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
511
512 int ctdb_ctrl_getreclock(struct ctdb_context *ctdb,
513         struct timeval timeout, uint32_t destnode,
514         TALLOC_CTX *mem_ctx, const char **reclock);
515 int ctdb_ctrl_setreclock(struct ctdb_context *ctdb,
516         struct timeval timeout, uint32_t destnode,
517         const char *reclock);
518
519
520 uint32_t *list_of_nodes(struct ctdb_context *ctdb,
521                         struct ctdb_node_map *node_map,
522                         TALLOC_CTX *mem_ctx,
523                         uint32_t mask,
524                         int exclude_pnn);
525 uint32_t *list_of_connected_nodes(struct ctdb_context *ctdb,
526                                 struct ctdb_node_map *node_map,
527                                 TALLOC_CTX *mem_ctx,
528                                 bool include_self);
529 uint32_t *list_of_active_nodes(struct ctdb_context *ctdb,
530                                 struct ctdb_node_map *node_map,
531                                 TALLOC_CTX *mem_ctx,
532                                 bool include_self);
533 uint32_t *list_of_vnnmap_nodes(struct ctdb_context *ctdb,
534                                 struct ctdb_vnn_map *vnn_map,
535                                 TALLOC_CTX *mem_ctx,
536                                 bool include_self);
537
538 int ctdb_read_pnn_lock(int fd, int32_t pnn);
539
540 /*
541   get capabilities of a remote node
542  */
543 int ctdb_ctrl_getcapabilities(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t *capabilities);
544
545 struct ctdb_client_control_state *ctdb_ctrl_getcapabilities_send(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode);
546
547 int ctdb_ctrl_getcapabilities_recv(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct ctdb_client_control_state *state, uint32_t *capabilities);
548
549 struct ctdb_marshall_buffer *ctdb_marshall_add(TALLOC_CTX *mem_ctx,
550                                                struct ctdb_marshall_buffer *m,
551                                                uint64_t db_id,
552                                                uint32_t reqid,
553                                                TDB_DATA key,
554                                                struct ctdb_ltdb_header *header,
555                                                TDB_DATA data);
556 TDB_DATA ctdb_marshall_finish(struct ctdb_marshall_buffer *m);
557
558 struct ctdb_transaction_handle *ctdb_transaction_start(struct ctdb_db_context *ctdb_db,
559                                                        TALLOC_CTX *mem_ctx);
560 int ctdb_transaction_fetch(struct ctdb_transaction_handle *h,
561                            TALLOC_CTX *mem_ctx,
562                            TDB_DATA key, TDB_DATA *data);
563 int ctdb_transaction_store(struct ctdb_transaction_handle *h,
564                            TDB_DATA key, TDB_DATA data);
565 int ctdb_transaction_commit(struct ctdb_transaction_handle *h);
566
567 int ctdb_ctrl_recd_ping(struct ctdb_context *ctdb);
568
569 int switch_from_server_to_client(struct ctdb_context *ctdb, const char *fmt,
570                                  ...);
571
572 int ctdb_ctrl_getscriptstatus(struct ctdb_context *ctdb,
573                     struct timeval timeout, uint32_t destnode,
574                     TALLOC_CTX *mem_ctx, enum ctdb_eventscript_call type,
575                     struct ctdb_scripts_wire **script_status);
576
577
578 struct debug_levels {
579         int32_t level;
580         const char *description;
581 };
582 extern struct debug_levels debug_levels[];
583
584 const char *get_debug_by_level(int32_t level);
585 int32_t get_debug_by_desc(const char *desc);
586
587 int ctdb_ctrl_stop_node(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
588 int ctdb_ctrl_continue_node(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
589
590 int ctdb_ctrl_setnatgwstate(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t natgwstate);
591 int ctdb_ctrl_setlmasterrole(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t lmasterrole);
592 int ctdb_ctrl_setrecmasterrole(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t recmasterrole);
593
594 int ctdb_ctrl_enablescript(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, const char *script);
595 int ctdb_ctrl_disablescript(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, const char *script);
596
597 struct ctdb_ban_time {
598         uint32_t pnn;
599         uint32_t time;
600 };
601
602 int ctdb_ctrl_set_ban(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, struct ctdb_ban_time *bantime);
603 int ctdb_ctrl_get_ban(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, TALLOC_CTX *mem_ctx, struct ctdb_ban_time **bantime);
604
605 struct ctdb_db_priority {
606         uint32_t db_id;
607         uint32_t priority;
608 };
609
610 int ctdb_ctrl_set_db_priority(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, struct ctdb_db_priority *db_prio);
611 int ctdb_ctrl_get_db_priority(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t db_id, uint32_t *priority);
612
613 int ctdb_ctrl_getstathistory(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, TALLOC_CTX *mem_ctx, struct ctdb_statistics_wire **stats);
614
615
616
617 struct ctdb_client_control_state *
618 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);
619
620 int ctdb_ctrl_updaterecord_recv(struct ctdb_context *ctdb, struct ctdb_client_control_state *state);
621
622 int
623 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);
624
625
626 struct ctdb_client_control_state *
627 ctdb_ctrl_set_db_readonly_send(struct ctdb_context *ctdb, uint32_t destnode, uint32_t dbid);
628 int ctdb_ctrl_set_db_readonly_recv(struct ctdb_context *ctdb, struct ctdb_client_control_state *state);
629 int ctdb_ctrl_set_db_readonly(struct ctdb_context *ctdb, uint32_t destnode, uint32_t dbid);
630
631 struct ctdb_client_control_state *
632 ctdb_ctrl_set_db_sticky_send(struct ctdb_context *ctdb, uint32_t destnode, uint32_t dbid);
633 int ctdb_ctrl_set_db_sticky_recv(struct ctdb_context *ctdb, struct ctdb_client_control_state *state);
634 int ctdb_ctrl_set_db_sticky(struct ctdb_context *ctdb, uint32_t destnode, uint32_t dbid);
635
636 #endif /* _CTDB_CLIENT_H */