Add current headers from ctdb master.
[ddiss/samba.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 int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork, bool use_syslog, const char *public_address_list);
104
105 /*
106   attach to a ctdb database
107 */
108 struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb,
109                                     struct timeval timeout,
110                                     const char *name,
111                                     bool persistent,
112                                     uint32_t tdb_flags);
113
114
115 /*
116   find an attached ctdb_db handle given a name
117  */
118 struct ctdb_db_context *ctdb_db_handle(struct ctdb_context *ctdb, const char *name);
119
120 /*
121   error string for last ctdb error
122 */
123 const char *ctdb_errstr(struct ctdb_context *);
124
125 /* a ctdb call function */
126 typedef int (*ctdb_fn_t)(struct ctdb_call_info *);
127
128 /*
129   setup a ctdb call function
130 */
131 int ctdb_set_call(struct ctdb_db_context *ctdb_db, ctdb_fn_t fn, uint32_t id);
132
133
134
135 /*
136   make a ctdb call. The associated ctdb call function will be called on the DMASTER
137   for the given record
138 */
139 int ctdb_call(struct ctdb_db_context *ctdb_db, struct ctdb_call *call);
140
141 /*
142   initiate an ordered ctdb cluster shutdown
143   this function will never return
144 */
145 void ctdb_shutdown(struct ctdb_context *ctdb);
146
147 /* return pnn of this node */
148 uint32_t ctdb_get_pnn(struct ctdb_context *ctdb);
149
150 /*
151   return the number of nodes
152 */
153 uint32_t ctdb_get_num_nodes(struct ctdb_context *ctdb);
154
155 /* setup a handler for ctdb messages */
156 typedef void (*ctdb_msg_fn_t)(struct ctdb_context *, uint64_t srvid,
157                                   TDB_DATA data, void *);
158 int ctdb_client_set_message_handler(struct ctdb_context *ctdb, uint64_t srvid,
159                              ctdb_msg_fn_t handler,
160                              void *private_data);
161 int ctdb_client_remove_message_handler(struct ctdb_context *ctdb,
162                                        uint64_t srvid, void *private_data);
163
164
165 int ctdb_call(struct ctdb_db_context *ctdb_db, struct ctdb_call *call);
166 struct ctdb_client_call_state *ctdb_call_send(struct ctdb_db_context *ctdb_db, struct ctdb_call *call);
167 int ctdb_call_recv(struct ctdb_client_call_state *state, struct ctdb_call *call);
168
169 /* send a ctdb message */
170 int ctdb_client_send_message(struct ctdb_context *ctdb, uint32_t pnn,
171                       uint64_t srvid, TDB_DATA data);
172
173
174 /*
175    Fetch a ctdb record from a remote node
176  . Underneath this will force the
177    dmaster for the record to be moved to the local node.
178 */
179 struct ctdb_record_handle *ctdb_fetch_lock(struct ctdb_db_context *ctdb_db, TALLOC_CTX *mem_ctx,
180                                            TDB_DATA key, TDB_DATA *data);
181
182 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);
183
184 int ctdb_record_store(struct ctdb_record_handle *h, TDB_DATA data);
185
186 int ctdb_fetch(struct ctdb_db_context *ctdb_db, TALLOC_CTX *mem_ctx,
187                TDB_DATA key, TDB_DATA *data);
188
189 int ctdb_register_message_handler(struct ctdb_context *ctdb,
190                                   TALLOC_CTX *mem_ctx,
191                                   uint64_t srvid,
192                                   ctdb_msg_fn_t handler,
193                                   void *private_data);
194
195 struct ctdb_db_context *find_ctdb_db(struct ctdb_context *ctdb, uint32_t id);
196
197
198 struct ctdb_context *ctdb_cmdline_client(struct tevent_context *ev,
199                                          struct timeval req_timeout);
200
201 struct ctdb_statistics;
202 int ctdb_ctrl_statistics(struct ctdb_context *ctdb, uint32_t destnode, struct ctdb_statistics *status);
203
204 int ctdb_ctrl_shutdown(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
205
206 struct ctdb_vnn_map;
207 int ctdb_ctrl_getvnnmap(struct ctdb_context *ctdb,
208                 struct timeval timeout, uint32_t destnode,
209                 TALLOC_CTX *mem_ctx, struct ctdb_vnn_map **vnnmap);
210 int ctdb_ctrl_setvnnmap(struct ctdb_context *ctdb,
211                 struct timeval timeout, uint32_t destnode,
212                 TALLOC_CTX *mem_ctx, struct ctdb_vnn_map *vnnmap);
213
214 /* table that contains a list of all dbids on a node
215  */
216 struct ctdb_dbid_map {
217         uint32_t num;
218         struct ctdb_dbid {
219                 uint32_t dbid;
220 #define CTDB_DB_FLAGS_PERSISTENT        0x01
221 #define CTDB_DB_FLAGS_READONLY          0x02
222 #define CTDB_DB_FLAGS_STICKY            0x04
223                 uint8_t flags;
224         } dbs[1];
225 };
226 int ctdb_ctrl_getdbmap(struct ctdb_context *ctdb,
227         struct timeval timeout, uint32_t destnode,
228         TALLOC_CTX *mem_ctx, struct ctdb_dbid_map **dbmap);
229
230
231 struct ctdb_node_map;
232
233 int ctdb_ctrl_getnodemap(struct ctdb_context *ctdb,
234                     struct timeval timeout, uint32_t destnode,
235                     TALLOC_CTX *mem_ctx, struct ctdb_node_map **nodemap);
236
237 int ctdb_ctrl_getnodemapv4(struct ctdb_context *ctdb,
238                     struct timeval timeout, uint32_t destnode,
239                     TALLOC_CTX *mem_ctx, struct ctdb_node_map **nodemap);
240
241 int ctdb_ctrl_reload_nodes_file(struct ctdb_context *ctdb,
242                     struct timeval timeout, uint32_t destnode);
243
244 struct ctdb_key_list {
245         uint32_t dbid;
246         uint32_t num;
247         TDB_DATA *keys;
248         struct ctdb_ltdb_header *headers;
249         TDB_DATA *data;
250 };
251
252 int ctdb_ctrl_pulldb(
253        struct ctdb_context *ctdb, uint32_t destnode, uint32_t dbid,
254        uint32_t lmaster, TALLOC_CTX *mem_ctx,
255        struct timeval timeout, TDB_DATA *outdata);
256
257 struct ctdb_client_control_state *ctdb_ctrl_pulldb_send(
258        struct ctdb_context *ctdb, uint32_t destnode, uint32_t dbid,
259        uint32_t lmaster, TALLOC_CTX *mem_ctx, struct timeval timeout);
260
261 int ctdb_ctrl_pulldb_recv(
262        struct ctdb_context *ctdb,
263        TALLOC_CTX *mem_ctx, struct ctdb_client_control_state *state,
264        TDB_DATA *outdata);
265
266 int ctdb_ctrl_pushdb(
267        struct ctdb_context *ctdb, uint32_t destnode, uint32_t dbid,
268        TALLOC_CTX *mem_ctx,
269        struct timeval timeout, TDB_DATA indata);
270
271 struct ctdb_client_control_state *ctdb_ctrl_pushdb_send(
272        struct ctdb_context *ctdb, uint32_t destnode, uint32_t dbid,
273        TALLOC_CTX *mem_ctx, struct timeval timeout,
274        TDB_DATA indata);
275
276 int ctdb_ctrl_pushdb_recv(
277        struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx,
278        struct ctdb_client_control_state *state);
279
280
281 int ctdb_ctrl_copydb(struct ctdb_context *ctdb,
282         struct timeval timeout, uint32_t sourcenode,
283         uint32_t destnode, uint32_t dbid, uint32_t lmaster,
284         TALLOC_CTX *mem_ctx);
285
286 int ctdb_ctrl_getdbpath(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t dbid, TALLOC_CTX *mem_ctx, const char **path);
287 int ctdb_ctrl_getdbname(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t dbid, TALLOC_CTX *mem_ctx, const char **name);
288 int ctdb_ctrl_getdbhealth(struct ctdb_context *ctdb,
289                           struct timeval timeout,
290                           uint32_t destnode,
291                           uint32_t dbid, TALLOC_CTX *mem_ctx,
292                           const char **reason);
293 int ctdb_ctrl_createdb(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, TALLOC_CTX *mem_ctx, const char *name, bool persistent);
294
295 int ctdb_ctrl_process_exists(struct ctdb_context *ctdb, uint32_t destnode, pid_t pid);
296
297 int ctdb_ctrl_ping(struct ctdb_context *ctdb, uint32_t destnode);
298
299 int ctdb_ctrl_get_config(struct ctdb_context *ctdb);
300
301 int ctdb_ctrl_get_debuglevel(struct ctdb_context *ctdb, uint32_t destnode, int32_t *level);
302 int ctdb_ctrl_set_debuglevel(struct ctdb_context *ctdb, uint32_t destnode, int32_t level);
303
304 /*
305   change dmaster for all keys in the database to the new value
306  */
307 int ctdb_ctrl_setdmaster(struct ctdb_context *ctdb,
308         struct timeval timeout, uint32_t destnode,
309         TALLOC_CTX *mem_ctx, uint32_t dbid, uint32_t dmaster);
310
311 /*
312   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)
313  */
314 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);
315
316 #define CTDB_RECOVERY_NORMAL            0
317 #define CTDB_RECOVERY_ACTIVE            1
318
319 /*
320   get the recovery mode of a remote node
321  */
322 int ctdb_ctrl_getrecmode(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode, uint32_t *recmode);
323
324 struct ctdb_client_control_state *ctdb_ctrl_getrecmode_send(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode);
325
326 int ctdb_ctrl_getrecmode_recv(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct ctdb_client_control_state *state, uint32_t *recmode);
327
328
329 /*
330   set the recovery mode of a remote node
331  */
332 int ctdb_ctrl_setrecmode(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t recmode);
333 /*
334   get the monitoring mode of a remote node
335  */
336 int ctdb_ctrl_getmonmode(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t *monmode);
337
338 /*
339   set the monitoring mode of a remote node to active
340  */
341 int ctdb_ctrl_enable_monmode(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
342
343 /*
344   set the monitoring mode of a remote node to disabled
345  */
346 int ctdb_ctrl_disable_monmode(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
347
348
349 /*
350   get the recovery master of a remote node
351  */
352 int ctdb_ctrl_getrecmaster(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode, uint32_t *recmaster);
353
354 struct ctdb_client_control_state *ctdb_ctrl_getrecmaster_send(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode);
355
356 int ctdb_ctrl_getrecmaster_recv(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct ctdb_client_control_state *state, uint32_t *recmaster);
357
358
359
360 /*
361   set the recovery master of a remote node
362  */
363 int ctdb_ctrl_setrecmaster(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t recmaster);
364
365 uint32_t *ctdb_get_connected_nodes(struct ctdb_context *ctdb,
366                                    struct timeval timeout,
367                                    TALLOC_CTX *mem_ctx,
368                                    uint32_t *num_nodes);
369
370 int ctdb_statistics_reset(struct ctdb_context *ctdb, uint32_t destnode);
371
372 int ctdb_set_logfile(struct ctdb_context *ctdb, const char *logfile, bool use_syslog);
373
374 typedef int (*ctdb_traverse_func)(struct ctdb_context *, TDB_DATA, TDB_DATA, void *);
375 int ctdb_traverse(struct ctdb_db_context *ctdb_db, ctdb_traverse_func fn, void *private_data);
376
377 struct ctdb_dump_db_context {
378         FILE *f;
379         bool printemptyrecords;
380         bool printdatasize;
381         bool printlmaster;
382         bool printhash;
383         bool printrecordflags;
384 };
385
386 int ctdb_dumpdb_record(struct ctdb_context *ctdb, TDB_DATA key, TDB_DATA data, void *p);
387 int ctdb_dump_db(struct ctdb_db_context *ctdb_db,
388                  struct ctdb_dump_db_context *ctx);
389
390 /*
391   get the pid of a ctdb daemon
392  */
393 int ctdb_ctrl_getpid(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t *pid);
394
395 int ctdb_ctrl_freeze(struct ctdb_context *ctdb, struct timeval timeout,
396                         uint32_t destnode);
397 int ctdb_ctrl_freeze_priority(struct ctdb_context *ctdb, struct timeval timeout,
398                               uint32_t destnode, uint32_t priority);
399
400 struct ctdb_client_control_state *
401 ctdb_ctrl_freeze_send(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx,
402                       struct timeval timeout, uint32_t destnode,
403                       uint32_t priority);
404
405 int ctdb_ctrl_freeze_recv(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx,
406                         struct ctdb_client_control_state *state);
407
408 int ctdb_ctrl_thaw_priority(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t priority);
409 int ctdb_ctrl_thaw(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
410
411 int ctdb_ctrl_getpnn(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
412
413 int ctdb_ctrl_get_tunable(struct ctdb_context *ctdb,
414                           struct timeval timeout,
415                           uint32_t destnode,
416                           const char *name, uint32_t *value);
417
418 int ctdb_ctrl_set_tunable(struct ctdb_context *ctdb,
419                           struct timeval timeout,
420                           uint32_t destnode,
421                           const char *name, uint32_t value);
422
423 int ctdb_ctrl_list_tunables(struct ctdb_context *ctdb,
424                             struct timeval timeout,
425                             uint32_t destnode,
426                             TALLOC_CTX *mem_ctx,
427                             const char ***list, uint32_t *count);
428
429 int ctdb_ctrl_modflags(struct ctdb_context *ctdb,
430                        struct timeval timeout,
431                        uint32_t destnode,
432                        uint32_t set, uint32_t clear);
433
434 enum ctdb_server_id_type {
435         SERVER_TYPE_SAMBA=1,
436         SERVER_TYPE_NFSD=2,
437         SERVER_TYPE_ISCSID=3
438 };
439
440 struct ctdb_server_id {
441         enum ctdb_server_id_type type;
442         uint32_t pnn;
443         uint32_t server_id;
444 };
445
446 struct ctdb_server_id_list {
447         uint32_t num;
448         struct ctdb_server_id server_ids[1];
449 };
450
451
452 int ctdb_ctrl_register_server_id(struct ctdb_context *ctdb,
453                 struct timeval timeout,
454                 struct ctdb_server_id *id);
455 int ctdb_ctrl_unregister_server_id(struct ctdb_context *ctdb,
456                 struct timeval timeout,
457                 struct ctdb_server_id *id);
458 int ctdb_ctrl_check_server_id(struct ctdb_context *ctdb,
459                 struct timeval timeout, uint32_t destnode,
460                 struct ctdb_server_id *id, uint32_t *status);
461 int ctdb_ctrl_get_server_id_list(struct ctdb_context *ctdb,
462                 TALLOC_CTX *mem_ctx,
463                 struct timeval timeout, uint32_t destnode,
464                 struct ctdb_server_id_list **svid_list);
465
466 struct ctdb_uptime {
467         struct timeval current_time;
468         struct timeval ctdbd_start_time;
469         struct timeval last_recovery_started;
470         struct timeval last_recovery_finished;
471 };
472
473 /*
474   struct for tcp_client control
475   this is an ipv4 only version of this structure used by samba
476   samba will later be migrated over to use the
477   ctdb_control_tcp_addr structure instead
478  */
479 struct ctdb_control_tcp {
480         struct sockaddr_in src; // samba uses this
481         struct sockaddr_in dest;// samba uses this
482 };
483 /* new style structure */
484 struct ctdb_control_tcp_addr {
485         ctdb_sock_addr src;
486         ctdb_sock_addr dest;
487 };
488
489 int ctdb_socket_connect(struct ctdb_context *ctdb);
490
491 /*
492   get the uptime of a remote node
493  */
494 int ctdb_ctrl_uptime(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode, struct ctdb_uptime **uptime);
495
496 struct ctdb_client_control_state *ctdb_ctrl_uptime_send(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode);
497
498 int ctdb_ctrl_uptime_recv(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct ctdb_client_control_state *state, struct ctdb_uptime **uptime);
499
500 int ctdb_ctrl_end_recovery(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
501
502 int ctdb_ctrl_getreclock(struct ctdb_context *ctdb,
503         struct timeval timeout, uint32_t destnode,
504         TALLOC_CTX *mem_ctx, const char **reclock);
505 int ctdb_ctrl_setreclock(struct ctdb_context *ctdb,
506         struct timeval timeout, uint32_t destnode,
507         const char *reclock);
508
509
510 uint32_t *list_of_connected_nodes(struct ctdb_context *ctdb,
511                                 struct ctdb_node_map *node_map,
512                                 TALLOC_CTX *mem_ctx,
513                                 bool include_self);
514 uint32_t *list_of_active_nodes(struct ctdb_context *ctdb,
515                                 struct ctdb_node_map *node_map,
516                                 TALLOC_CTX *mem_ctx,
517                                 bool include_self);
518 uint32_t *list_of_vnnmap_nodes(struct ctdb_context *ctdb,
519                                 struct ctdb_vnn_map *vnn_map,
520                                 TALLOC_CTX *mem_ctx,
521                                 bool include_self);
522 uint32_t *list_of_active_nodes_except_pnn(struct ctdb_context *ctdb,
523                                 struct ctdb_node_map *node_map,
524                                 TALLOC_CTX *mem_ctx,
525                                 uint32_t pnn);
526
527 int ctdb_read_pnn_lock(int fd, int32_t pnn);
528
529 /*
530   get capabilities of a remote node
531  */
532 int ctdb_ctrl_getcapabilities(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t *capabilities);
533
534 struct ctdb_client_control_state *ctdb_ctrl_getcapabilities_send(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode);
535
536 int ctdb_ctrl_getcapabilities_recv(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct ctdb_client_control_state *state, uint32_t *capabilities);
537
538
539 int32_t ctdb_ctrl_transaction_active(struct ctdb_context *ctdb,
540                                      uint32_t destnode,
541                                      uint32_t db_id);
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 */