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