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