eventscript: use -ENOEXEC for disabled status value
[sahlberg/ctdb.git] / include / ctdb.h
1 /* 
2    ctdb database library
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_H
21 #define _CTDB_H
22
23 #define CTDB_IMMEDIATE_MIGRATION        0x00000001
24 struct ctdb_call {
25         int call_id;
26         TDB_DATA key;
27         TDB_DATA call_data;
28         TDB_DATA reply_data;
29         uint32_t status;
30         uint32_t flags;
31 };
32
33 /*
34   structure passed to a ctdb call backend function
35 */
36 struct ctdb_call_info {
37         TDB_DATA key;          /* record key */
38         TDB_DATA record_data;  /* current data in the record */
39         TDB_DATA *new_data;    /* optionally updated record data */
40         TDB_DATA *call_data;   /* optionally passed from caller */
41         TDB_DATA *reply_data;  /* optionally returned by function */
42         uint32_t status;       /* optional reply status - defaults to zero */
43 };
44
45 #define CTDB_ERR_INVALID 1
46 #define CTDB_ERR_NOMEM 2
47
48 /*
49   ctdb flags
50 */
51 #define CTDB_FLAG_TORTURE      (1<<1)
52
53 /* 
54    a message handler ID meaning "give me all messages"
55  */
56 #define CTDB_SRVID_ALL (~(uint64_t)0)
57
58 /*
59   srvid type : RECOVERY
60 */
61 #define CTDB_SRVID_RECOVERY     0xF100000000000000LL
62
63 /* 
64    a message handler ID meaning that the cluster has been reconfigured
65  */
66 #define CTDB_SRVID_RECONFIGURE 0xF200000000000000LL
67
68 /* 
69    a message handler ID meaning that an IP address has been released
70  */
71 #define CTDB_SRVID_RELEASE_IP 0xF300000000000000LL
72
73 /* 
74    a message ID to set the node flags in the recovery daemon
75  */
76 #define CTDB_SRVID_SET_NODE_FLAGS 0xF400000000000000LL
77
78 /*
79   a message to tell the recovery daemon to fetch a set of records
80  */
81 #define CTDB_SRVID_VACUUM_FETCH 0xF700000000000000LL
82
83 /*
84   a message to tell the recovery daemon to write a talloc memdump
85   to the log
86  */
87 #define CTDB_SRVID_MEM_DUMP 0xF800000000000000LL
88
89 /* 
90    a message ID to get the recovery daemon to push the node flags out
91  */
92 #define CTDB_SRVID_PUSH_NODE_FLAGS 0xF900000000000000LL
93
94 /* 
95    a message ID to get the recovery daemon to reload the nodes file
96  */
97 #define CTDB_SRVID_RELOAD_NODES 0xFA00000000000000LL
98
99 /* 
100    a message ID to get the recovery daemon to perform a takeover run
101  */
102 #define CTDB_SRVID_TAKEOVER_RUN 0xFB00000000000000LL
103
104 /* A message id to ask the recovery daemon to temporarily disable the
105    public ip checks
106 */
107 #define CTDB_SRVID_DISABLE_IP_CHECK  0xFC00000000000000LL
108
109 /* A dummy port used for sending back ipreallocate resposnes to the main
110    daemon
111 */
112 #define CTDB_SRVID_TAKEOVER_RUN_RESPONSE  0xFD00000000000000LL
113
114 /* A port reserved for samba (top 32 bits)
115  */
116 #define CTDB_SRVID_SAMBA_NOTIFY  0xFE00000000000000LL
117
118 /* used on the domain socket, send a pdu to the local daemon */
119 #define CTDB_CURRENT_NODE     0xF0000001
120 /* send a broadcast to all nodes in the cluster, active or not */
121 #define CTDB_BROADCAST_ALL    0xF0000002
122 /* send a broadcast to all nodes in the current vnn map */
123 #define CTDB_BROADCAST_VNNMAP 0xF0000003
124 /* send a broadcast to all connected nodes */
125 #define CTDB_BROADCAST_CONNECTED 0xF0000004
126
127 /* the key used for transaction locking on persistent databases */
128 #define CTDB_TRANSACTION_LOCK_KEY "__transaction_lock__"
129
130 enum control_state {CTDB_CONTROL_WAIT, CTDB_CONTROL_DONE, CTDB_CONTROL_ERROR, CTDB_CONTROL_TIMEOUT};
131
132 struct ctdb_client_control_state {
133         struct ctdb_context *ctdb;
134         uint32_t reqid;
135         int32_t status;
136         TDB_DATA outdata;
137         enum control_state state;
138         char *errormsg;
139         struct ctdb_req_control *c;
140
141         /* if we have a callback registered for the completion (or failure) of
142            this control
143            if a callback is used, it MUST talloc_free the cb_data passed to it
144         */
145         struct {
146                 void (*fn)(struct ctdb_client_control_state *);
147                 void *private_data;
148         } async;        
149 };
150
151 struct ctdb_client_notify_register {
152         uint64_t srvid;
153         uint32_t len;
154         uint8_t notify_data[1];
155 };
156
157 struct ctdb_client_notify_deregister {
158         uint64_t srvid;
159 };
160
161 struct event_context;
162
163 /*
164   initialise ctdb subsystem
165 */
166 struct ctdb_context *ctdb_init(struct event_context *ev);
167
168 /*
169   choose the transport
170 */
171 int ctdb_set_transport(struct ctdb_context *ctdb, const char *transport);
172
173 /*
174   set the directory for the local databases
175 */
176 int ctdb_set_tdb_dir(struct ctdb_context *ctdb, const char *dir);
177 int ctdb_set_tdb_dir_persistent(struct ctdb_context *ctdb, const char *dir);
178
179 /*
180   set some flags
181 */
182 void ctdb_set_flags(struct ctdb_context *ctdb, unsigned flags);
183
184 /*
185   set max acess count before a dmaster migration
186 */
187 void ctdb_set_max_lacount(struct ctdb_context *ctdb, unsigned count);
188
189 /*
190   tell ctdb what address to listen on, in transport specific format
191 */
192 int ctdb_set_address(struct ctdb_context *ctdb, const char *address);
193
194 int ctdb_set_socketname(struct ctdb_context *ctdb, const char *socketname);
195
196 /*
197   tell ctdb what nodes are available. This takes a filename, which will contain
198   1 node address per line, in a transport specific format
199 */
200 int ctdb_set_nlist(struct ctdb_context *ctdb, const char *nlist);
201
202 /*
203   Check that a specific ip address exists in the node list and returns
204   the id for the node or -1
205 */
206 int ctdb_ip_to_nodeid(struct ctdb_context *ctdb, const char *nodeip);
207
208 /*
209   start the ctdb protocol
210 */
211 int ctdb_start(struct ctdb_context *ctdb);
212 int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork, bool use_syslog);
213
214 /*
215   attach to a ctdb database
216 */
217 struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb, const char *name, bool persistent, uint32_t tdb_flags);
218
219 /*
220   find an attached ctdb_db handle given a name
221  */
222 struct ctdb_db_context *ctdb_db_handle(struct ctdb_context *ctdb, const char *name);
223
224 /*
225   error string for last ctdb error
226 */
227 const char *ctdb_errstr(struct ctdb_context *);
228
229 /* a ctdb call function */
230 typedef int (*ctdb_fn_t)(struct ctdb_call_info *);
231
232 /*
233   setup a ctdb call function
234 */
235 int ctdb_set_call(struct ctdb_db_context *ctdb_db, ctdb_fn_t fn, uint32_t id);
236
237
238
239 /*
240   make a ctdb call. The associated ctdb call function will be called on the DMASTER
241   for the given record
242 */
243 int ctdb_call(struct ctdb_db_context *ctdb_db, struct ctdb_call *call);
244
245 /*
246   initiate an ordered ctdb cluster shutdown
247   this function will never return
248 */
249 void ctdb_shutdown(struct ctdb_context *ctdb);
250
251 /* return pnn of this node */
252 uint32_t ctdb_get_pnn(struct ctdb_context *ctdb);
253
254 /*
255   return the number of nodes
256 */
257 uint32_t ctdb_get_num_nodes(struct ctdb_context *ctdb);
258
259 /* setup a handler for ctdb messages */
260 typedef void (*ctdb_message_fn_t)(struct ctdb_context *, uint64_t srvid, 
261                                   TDB_DATA data, void *);
262 int ctdb_set_message_handler(struct ctdb_context *ctdb, uint64_t srvid, 
263                              ctdb_message_fn_t handler,
264                              void *private_data);
265
266
267 int ctdb_call(struct ctdb_db_context *ctdb_db, struct ctdb_call *call);
268 struct ctdb_client_call_state *ctdb_call_send(struct ctdb_db_context *ctdb_db, struct ctdb_call *call);
269 int ctdb_call_recv(struct ctdb_client_call_state *state, struct ctdb_call *call);
270
271 /* send a ctdb message */
272 int ctdb_send_message(struct ctdb_context *ctdb, uint32_t pnn,
273                       uint64_t srvid, TDB_DATA data);
274
275
276 /* 
277    Fetch a ctdb record from a remote node
278  . Underneath this will force the
279    dmaster for the record to be moved to the local node. 
280 */
281 struct ctdb_record_handle *ctdb_fetch_lock(struct ctdb_db_context *ctdb_db, TALLOC_CTX *mem_ctx, 
282                                            TDB_DATA key, TDB_DATA *data);
283
284 int ctdb_record_store(struct ctdb_record_handle *h, TDB_DATA data);
285
286 int ctdb_fetch(struct ctdb_db_context *ctdb_db, TALLOC_CTX *mem_ctx, 
287                TDB_DATA key, TDB_DATA *data);
288
289 int ctdb_register_message_handler(struct ctdb_context *ctdb, 
290                                   TALLOC_CTX *mem_ctx,
291                                   uint64_t srvid,
292                                   ctdb_message_fn_t handler,
293                                   void *private_data);
294
295 struct ctdb_db_context *find_ctdb_db(struct ctdb_context *ctdb, uint32_t id);
296
297
298 struct ctdb_context *ctdb_cmdline_client(struct event_context *ev);
299
300 struct ctdb_statistics;
301 int ctdb_ctrl_statistics(struct ctdb_context *ctdb, uint32_t destnode, struct ctdb_statistics *status);
302
303 int ctdb_ctrl_shutdown(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
304
305 struct ctdb_vnn_map;
306 int ctdb_ctrl_getvnnmap(struct ctdb_context *ctdb, 
307                 struct timeval timeout, uint32_t destnode, 
308                 TALLOC_CTX *mem_ctx, struct ctdb_vnn_map **vnnmap);
309 int ctdb_ctrl_setvnnmap(struct ctdb_context *ctdb,
310                 struct timeval timeout, uint32_t destnode, 
311                 TALLOC_CTX *mem_ctx, struct ctdb_vnn_map *vnnmap);
312
313 /* table that contains a list of all dbids on a node
314  */
315 struct ctdb_dbid_map {
316         uint32_t num;
317         struct ctdb_dbid {
318                 uint32_t dbid;
319                 bool persistent;
320         } dbs[1];
321 };
322 int ctdb_ctrl_getdbmap(struct ctdb_context *ctdb, 
323         struct timeval timeout, uint32_t destnode, 
324         TALLOC_CTX *mem_ctx, struct ctdb_dbid_map **dbmap);
325
326
327 struct ctdb_node_map;
328
329 int ctdb_ctrl_getnodemap(struct ctdb_context *ctdb, 
330                     struct timeval timeout, uint32_t destnode, 
331                     TALLOC_CTX *mem_ctx, struct ctdb_node_map **nodemap);
332
333 int ctdb_ctrl_getnodemapv4(struct ctdb_context *ctdb, 
334                     struct timeval timeout, uint32_t destnode, 
335                     TALLOC_CTX *mem_ctx, struct ctdb_node_map **nodemap);
336
337 int ctdb_ctrl_reload_nodes_file(struct ctdb_context *ctdb, 
338                     struct timeval timeout, uint32_t destnode);
339
340 struct ctdb_key_list {
341         uint32_t dbid;
342         uint32_t num;
343         TDB_DATA *keys;
344         struct ctdb_ltdb_header *headers;
345         TDB_DATA *data;
346 };
347
348 int ctdb_ctrl_pulldb(
349        struct ctdb_context *ctdb, uint32_t destnode, uint32_t dbid,
350        uint32_t lmaster, TALLOC_CTX *mem_ctx,
351        struct timeval timeout, TDB_DATA *outdata);
352
353 struct ctdb_client_control_state *ctdb_ctrl_pulldb_send(
354        struct ctdb_context *ctdb, uint32_t destnode, uint32_t dbid,
355        uint32_t lmaster, TALLOC_CTX *mem_ctx, struct timeval timeout);
356
357 int ctdb_ctrl_pulldb_recv(
358        struct ctdb_context *ctdb,
359        TALLOC_CTX *mem_ctx, struct ctdb_client_control_state *state,
360        TDB_DATA *outdata);
361
362 int ctdb_ctrl_pushdb(
363        struct ctdb_context *ctdb, uint32_t destnode, uint32_t dbid,
364        TALLOC_CTX *mem_ctx,
365        struct timeval timeout, TDB_DATA indata);
366
367 struct ctdb_client_control_state *ctdb_ctrl_pushdb_send(
368        struct ctdb_context *ctdb, uint32_t destnode, uint32_t dbid,
369        TALLOC_CTX *mem_ctx, struct timeval timeout,
370        TDB_DATA indata);
371
372 int ctdb_ctrl_pushdb_recv(
373        struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx,
374        struct ctdb_client_control_state *state);
375
376
377 int ctdb_ctrl_copydb(struct ctdb_context *ctdb, 
378         struct timeval timeout, uint32_t sourcenode, 
379         uint32_t destnode, uint32_t dbid, uint32_t lmaster, 
380         TALLOC_CTX *mem_ctx);
381
382 int ctdb_ctrl_getdbpath(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t dbid, TALLOC_CTX *mem_ctx, const char **path);
383 int ctdb_ctrl_getdbname(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t dbid, TALLOC_CTX *mem_ctx, const char **name);
384 int ctdb_ctrl_createdb(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, TALLOC_CTX *mem_ctx, const char *name, bool persistent);
385
386 int ctdb_ctrl_process_exists(struct ctdb_context *ctdb, uint32_t destnode, pid_t pid);
387
388 int ctdb_ctrl_ping(struct ctdb_context *ctdb, uint32_t destnode);
389
390 int ctdb_ctrl_get_config(struct ctdb_context *ctdb);
391
392 int ctdb_ctrl_get_debuglevel(struct ctdb_context *ctdb, uint32_t destnode, int32_t *level);
393 int ctdb_ctrl_set_debuglevel(struct ctdb_context *ctdb, uint32_t destnode, int32_t level);
394
395 /*
396   change dmaster for all keys in the database to the new value
397  */
398 int ctdb_ctrl_setdmaster(struct ctdb_context *ctdb, 
399         struct timeval timeout, uint32_t destnode, 
400         TALLOC_CTX *mem_ctx, uint32_t dbid, uint32_t dmaster);
401
402 /*
403   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)
404  */
405 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);
406
407 #define CTDB_RECOVERY_NORMAL            0
408 #define CTDB_RECOVERY_ACTIVE            1
409
410 /*
411   get the recovery mode of a remote node
412  */
413 int ctdb_ctrl_getrecmode(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode, uint32_t *recmode);
414
415 struct ctdb_client_control_state *ctdb_ctrl_getrecmode_send(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode);
416
417 int ctdb_ctrl_getrecmode_recv(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct ctdb_client_control_state *state, uint32_t *recmode);
418
419
420 /*
421   set the recovery mode of a remote node
422  */
423 int ctdb_ctrl_setrecmode(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t recmode);
424 /*
425   get the monitoring mode of a remote node
426  */
427 int ctdb_ctrl_getmonmode(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t *monmode);
428
429 /*
430   set the monitoring mode of a remote node to active
431  */
432 int ctdb_ctrl_enable_monmode(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
433
434 /*
435   set the monitoring mode of a remote node to disabled
436  */
437 int ctdb_ctrl_disable_monmode(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
438
439
440 /*
441   get the recovery master of a remote node
442  */
443 int ctdb_ctrl_getrecmaster(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode, uint32_t *recmaster);
444
445 struct ctdb_client_control_state *ctdb_ctrl_getrecmaster_send(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode);
446
447 int ctdb_ctrl_getrecmaster_recv(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct ctdb_client_control_state *state, uint32_t *recmaster);
448
449
450
451 /*
452   set the recovery master of a remote node
453  */
454 int ctdb_ctrl_setrecmaster(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t recmaster);
455
456 uint32_t *ctdb_get_connected_nodes(struct ctdb_context *ctdb, 
457                                    struct timeval timeout, 
458                                    TALLOC_CTX *mem_ctx,
459                                    uint32_t *num_nodes);
460
461 int ctdb_statistics_reset(struct ctdb_context *ctdb, uint32_t destnode);
462
463 int ctdb_set_logfile(struct ctdb_context *ctdb, const char *logfile, bool use_syslog);
464
465 typedef int (*ctdb_traverse_func)(struct ctdb_context *, TDB_DATA, TDB_DATA, void *);
466 int ctdb_traverse(struct ctdb_db_context *ctdb_db, ctdb_traverse_func fn, void *private_data);
467
468 int ctdb_dump_db(struct ctdb_db_context *ctdb_db, FILE *f);
469
470 /*
471   get the pid of a ctdb daemon
472  */
473 int ctdb_ctrl_getpid(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t *pid);
474
475 int ctdb_ctrl_freeze(struct ctdb_context *ctdb, struct timeval timeout, 
476                         uint32_t destnode);
477 int ctdb_ctrl_freeze_priority(struct ctdb_context *ctdb, struct timeval timeout, 
478                               uint32_t destnode, uint32_t priority);
479
480 struct ctdb_client_control_state *
481 ctdb_ctrl_freeze_send(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, 
482                       struct timeval timeout, uint32_t destnode,
483                       uint32_t priority);
484
485 int ctdb_ctrl_freeze_recv(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, 
486                         struct ctdb_client_control_state *state);
487
488 int ctdb_ctrl_thaw_priority(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t priority);
489 int ctdb_ctrl_thaw(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
490
491 int ctdb_ctrl_getpnn(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
492
493 int ctdb_ctrl_get_tunable(struct ctdb_context *ctdb, 
494                           struct timeval timeout, 
495                           uint32_t destnode,
496                           const char *name, uint32_t *value);
497
498 int ctdb_ctrl_set_tunable(struct ctdb_context *ctdb, 
499                           struct timeval timeout, 
500                           uint32_t destnode,
501                           const char *name, uint32_t value);
502
503 int ctdb_ctrl_list_tunables(struct ctdb_context *ctdb, 
504                             struct timeval timeout, 
505                             uint32_t destnode,
506                             TALLOC_CTX *mem_ctx,
507                             const char ***list, uint32_t *count);
508
509 int ctdb_ctrl_modflags(struct ctdb_context *ctdb, 
510                        struct timeval timeout, 
511                        uint32_t destnode, 
512                        uint32_t set, uint32_t clear);
513
514 enum ctdb_server_id_type { SERVER_TYPE_SAMBA=1 };
515
516 struct ctdb_server_id {
517         enum ctdb_server_id_type type;
518         uint32_t pnn;
519         uint32_t server_id;
520 };
521
522 struct ctdb_server_id_list {
523         uint32_t num;
524         struct ctdb_server_id server_ids[1];
525 };
526
527
528 int ctdb_ctrl_register_server_id(struct ctdb_context *ctdb,
529                 struct timeval timeout,
530                 struct ctdb_server_id *id);
531 int ctdb_ctrl_unregister_server_id(struct ctdb_context *ctdb, 
532                 struct timeval timeout, 
533                 struct ctdb_server_id *id);
534 int ctdb_ctrl_check_server_id(struct ctdb_context *ctdb,
535                 struct timeval timeout, uint32_t destnode, 
536                 struct ctdb_server_id *id, uint32_t *status);
537 int ctdb_ctrl_get_server_id_list(struct ctdb_context *ctdb,
538                 TALLOC_CTX *mem_ctx,
539                 struct timeval timeout, uint32_t destnode, 
540                 struct ctdb_server_id_list **svid_list);
541
542 struct ctdb_uptime {
543         struct timeval current_time;
544         struct timeval ctdbd_start_time;
545         struct timeval last_recovery_started;
546         struct timeval last_recovery_finished;
547 };
548
549 /*
550   definitions for different socket structures
551  */
552 typedef struct sockaddr_in ctdb_addr_in;
553 typedef struct sockaddr_in6 ctdb_addr_in6;
554 typedef union {
555         struct sockaddr sa;
556         ctdb_addr_in    ip;
557         ctdb_addr_in6   ip6;
558 } ctdb_sock_addr;
559
560 /*
561   struct for tcp_client control
562   this is an ipv4 only version of this structure used by samba
563   samba will later be migrated over to use the 
564   ctdb_control_tcp_addr structure instead
565  */
566 struct ctdb_control_tcp {
567         struct sockaddr_in src; // samba uses this
568         struct sockaddr_in dest;// samba uses this
569 };
570 /* new style structure */
571 struct ctdb_control_tcp_addr {
572         ctdb_sock_addr src;
573         ctdb_sock_addr dest;
574 };
575
576 int ctdb_socket_connect(struct ctdb_context *ctdb);
577
578 /*
579   get the uptime of a remote node
580  */
581 int ctdb_ctrl_uptime(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode, struct ctdb_uptime **uptime);
582
583 struct ctdb_client_control_state *ctdb_ctrl_uptime_send(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode);
584
585 int ctdb_ctrl_uptime_recv(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct ctdb_client_control_state *state, struct ctdb_uptime **uptime);
586
587 int ctdb_ctrl_end_recovery(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
588
589 int ctdb_ctrl_getreclock(struct ctdb_context *ctdb, 
590         struct timeval timeout, uint32_t destnode, 
591         TALLOC_CTX *mem_ctx, const char **reclock);
592 int ctdb_ctrl_setreclock(struct ctdb_context *ctdb, 
593         struct timeval timeout, uint32_t destnode, 
594         const char *reclock);
595
596
597 uint32_t *list_of_connected_nodes(struct ctdb_context *ctdb,
598                                 struct ctdb_node_map *node_map,
599                                 TALLOC_CTX *mem_ctx,
600                                 bool include_self);
601 uint32_t *list_of_active_nodes(struct ctdb_context *ctdb,
602                                 struct ctdb_node_map *node_map,
603                                 TALLOC_CTX *mem_ctx,
604                                 bool include_self);
605 uint32_t *list_of_vnnmap_nodes(struct ctdb_context *ctdb,
606                                 struct ctdb_vnn_map *vnn_map,
607                                 TALLOC_CTX *mem_ctx,
608                                 bool include_self);
609 uint32_t *list_of_active_nodes_except_pnn(struct ctdb_context *ctdb,
610                                 struct ctdb_node_map *node_map,
611                                 TALLOC_CTX *mem_ctx,
612                                 uint32_t pnn);
613
614 int ctdb_read_pnn_lock(int fd, int32_t pnn);
615
616 /*
617   get capabilities of a remote node
618  */
619 int ctdb_ctrl_getcapabilities(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t *capabilities);
620
621 struct ctdb_client_control_state *ctdb_ctrl_getcapabilities_send(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode);
622
623 int ctdb_ctrl_getcapabilities_recv(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct ctdb_client_control_state *state, uint32_t *capabilities);
624
625
626 int32_t ctdb_ctrl_transaction_active(struct ctdb_context *ctdb,
627                                      uint32_t destnode,
628                                      uint32_t db_id);
629
630 struct ctdb_marshall_buffer *ctdb_marshall_add(TALLOC_CTX *mem_ctx, 
631                                                struct ctdb_marshall_buffer *m,
632                                                uint64_t db_id,
633                                                uint32_t reqid,
634                                                TDB_DATA key,
635                                                struct ctdb_ltdb_header *header,
636                                                TDB_DATA data);
637 TDB_DATA ctdb_marshall_finish(struct ctdb_marshall_buffer *m);
638
639 struct ctdb_transaction_handle *ctdb_transaction_start(struct ctdb_db_context *ctdb_db,
640                                                        TALLOC_CTX *mem_ctx);
641 int ctdb_transaction_fetch(struct ctdb_transaction_handle *h, 
642                            TALLOC_CTX *mem_ctx, 
643                            TDB_DATA key, TDB_DATA *data);
644 int ctdb_transaction_store(struct ctdb_transaction_handle *h, 
645                            TDB_DATA key, TDB_DATA data);
646 int ctdb_transaction_commit(struct ctdb_transaction_handle *h);
647
648 int ctdb_ctrl_recd_ping(struct ctdb_context *ctdb);
649
650 int switch_from_server_to_client(struct ctdb_context *ctdb);
651
652 #define MONITOR_SCRIPT_OK      0
653 #define MONITOR_SCRIPT_TIMEOUT 1
654
655 #define MAX_SCRIPT_NAME 31
656 #define MAX_SCRIPT_OUTPUT 511
657 struct ctdb_monitoring_script_wire {
658         char name[MAX_SCRIPT_NAME+1];
659         struct timeval start;
660         struct timeval finished;
661         int32_t status;
662         char output[MAX_SCRIPT_OUTPUT+1];
663 };
664
665 struct ctdb_monitoring_wire {
666         uint32_t num_scripts;
667         struct ctdb_monitoring_script_wire scripts[1];
668 };
669
670 int ctdb_ctrl_getscriptstatus(struct ctdb_context *ctdb, 
671                     struct timeval timeout, uint32_t destnode, 
672                     TALLOC_CTX *mem_ctx, struct ctdb_monitoring_wire **script_status);
673
674
675 struct debug_levels {
676         int32_t level;
677         const char *description;
678 };
679 extern struct debug_levels debug_levels[];
680
681 const char *get_debug_by_level(int32_t level);
682 int32_t get_debug_by_desc(const char *desc);
683
684 int ctdb_ctrl_stop_node(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
685 int ctdb_ctrl_continue_node(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
686
687 int ctdb_ctrl_setnatgwstate(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t natgwstate);
688 int ctdb_ctrl_setlmasterrole(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t lmasterrole);
689 int ctdb_ctrl_setrecmasterrole(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t recmasterrole);
690
691 int ctdb_ctrl_enablescript(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, const char *script);
692 int ctdb_ctrl_disablescript(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, const char *script);
693
694 struct ctdb_ban_time {
695         uint32_t pnn;
696         uint32_t time;
697 };
698
699 int ctdb_ctrl_set_ban(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, struct ctdb_ban_time *bantime);
700 int ctdb_ctrl_get_ban(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, TALLOC_CTX *mem_ctx, struct ctdb_ban_time **bantime);
701
702 struct ctdb_db_priority {
703         uint32_t db_id;
704         uint32_t priority;
705 };
706
707 int ctdb_ctrl_set_db_priority(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, struct ctdb_db_priority *db_prio);
708 int ctdb_ctrl_get_db_priority(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t db_id, uint32_t *priority);
709
710 #endif