r20896: make the maximum lacount configurable in smb.conf
[Samba/ekacnet.git] / source4 / cluster / ctdb / include / ctdb.h
blobf2f4bcef84da83e82106002bcf4683cafdeaec6c
1 /*
2 ctdb database library
4 Copyright (C) Andrew Tridgell 2006
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
11 This library 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 GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #ifndef _CTDB_H
22 #define _CTDB_H
25 structure passed to a ctdb call function
27 struct ctdb_call {
28 TDB_DATA key; /* record key */
29 TDB_DATA record_data; /* current data in the record */
30 TDB_DATA *new_data; /* optionally updated record data */
31 TDB_DATA *call_data; /* optionally passed from caller */
32 TDB_DATA *reply_data; /* optionally returned by function */
35 #define CTDB_ERR_INVALID 1
36 #define CTDB_ERR_NOMEM 2
39 ctdb flags
41 #define CTDB_FLAG_SELF_CONNECT (1<<0)
44 struct event_context;
47 initialise ctdb subsystem
49 struct ctdb_context *ctdb_init(struct event_context *ev);
52 choose the transport
54 int ctdb_set_transport(struct ctdb_context *ctdb, const char *transport);
57 set some flags
59 void ctdb_set_flags(struct ctdb_context *ctdb, unsigned flags);
62 set max acess count before a dmaster migration
64 void ctdb_set_max_lacount(struct ctdb_context *ctdb, unsigned count);
67 tell ctdb what address to listen on, in transport specific format
69 int ctdb_set_address(struct ctdb_context *ctdb, const char *address);
72 tell ctdb what nodes are available. This takes a filename, which will contain
73 1 node address per line, in a transport specific format
75 int ctdb_set_nlist(struct ctdb_context *ctdb, const char *nlist);
78 start the ctdb protocol
80 int ctdb_start(struct ctdb_context *ctdb);
83 error string for last ctdb error
85 const char *ctdb_errstr(struct ctdb_context *);
87 /* a ctdb call function */
88 typedef int (*ctdb_fn_t)(struct ctdb_call *);
91 setup a ctdb call function
93 int ctdb_set_call(struct ctdb_context *ctdb, ctdb_fn_t fn, int id);
96 attach to a ctdb database
98 int ctdb_attach(struct ctdb_context *ctdb, const char *name, int tdb_flags,
99 int open_flags, mode_t mode);
103 make a ctdb call. The associated ctdb call function will be called on the DMASTER
104 for the given record
106 int ctdb_call(struct ctdb_context *ctdb, TDB_DATA key, int call_id,
107 TDB_DATA *call_data, TDB_DATA *reply_data);
110 wait for all nodes to be connected - useful for test code
112 void ctdb_connect_wait(struct ctdb_context *ctdb);
115 wait until we're the only node left
117 void ctdb_wait_loop(struct ctdb_context *ctdb);
119 /* return vnn of this node */
120 uint32_t ctdb_get_vnn(struct ctdb_context *ctdb);
122 #endif