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