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
23 an installed ctdb remote call
25 struct ctdb_registered_call {
26 struct ctdb_registered_call *next, *prev;
32 this address structure might need to be generalised later for some
41 state associated with one node
44 struct ctdb_context *ctdb;
45 struct ctdb_address address;
46 const char *name; /* for debug messages */
47 void *private; /* private to transport */
52 transport specific methods
55 int (*start)(struct ctdb_context *); /* start protocol processing */
56 int (*add_node)(struct ctdb_node *); /* setup a new node */
57 int (*queue_pkt)(struct ctdb_node *, uint8_t *data, uint32_t length);
61 transport calls up to the ctdb layer
64 /* recv_pkt is called when a packet comes in */
65 void (*recv_pkt)(struct ctdb_context *, uint8_t *data, uint32_t length);
67 /* node_dead is called when an attempt to send to a node fails */
68 void (*node_dead)(struct ctdb_node *);
70 /* node_connected is called when a connection to a node is established */
71 void (*node_connected)(struct ctdb_node *);
74 /* main state of the ctdb daemon */
76 struct event_context *ev;
77 struct ctdb_address address;
79 uint32_t vnn; /* our own vnn */
81 uint32_t num_connected;
83 struct idr_context *idr;
84 struct ctdb_node **nodes; /* array of nodes in the cluster - indexed by vnn */
85 struct ctdb_registered_call *calls; /* list of registered calls */
87 struct tdb_context *ltdb;
88 const struct ctdb_methods *methods; /* transport methods */
89 const struct ctdb_upcalls *upcalls; /* transport upcalls */
90 void *private; /* private to transport */
93 #define CTDB_NO_MEMORY(ctdb, p) do { if (!(p)) { \
94 ctdb_set_error(ctdb, "Out of memory at %s:%d", __FILE__, __LINE__); \
95 return -1; }} while (0)
97 #define CTDB_NO_MEMORY_NULL(ctdb, p) do { if (!(p)) { \
98 ctdb_set_error(ctdb, "Out of memory at %s:%d", __FILE__, __LINE__); \
99 return NULL; }} while (0)
101 /* arbitrary maximum timeout for ctdb operations */
102 #define CTDB_REQ_TIMEOUT 10
105 the extended header for records in the ltdb
107 struct ctdb_ltdb_header {
118 enum ctdb_operation {
121 CTDB_REPLY_REDIRECT = 2,
122 CTDB_REQ_DMASTER = 3,
123 CTDB_REPLY_DMASTER = 4,
129 struct ctdb_req_header {
137 struct ctdb_req_call {
138 struct ctdb_req_header hdr;
141 uint32_t calldatalen;
142 uint8_t data[0]; /* key[] followed by calldata[] */
145 struct ctdb_reply_call {
146 struct ctdb_req_header hdr;
151 /* internal prototypes */
152 void ctdb_set_error(struct ctdb_context *ctdb, const char *fmt, ...);
153 bool ctdb_same_address(struct ctdb_address *a1, struct ctdb_address *a2);
154 int ctdb_parse_address(struct ctdb_context *ctdb,
155 TALLOC_CTX *mem_ctx, const char *str,
156 struct ctdb_address *address);
157 uint32_t ctdb_hash(TDB_DATA *key);
158 void ctdb_request_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
159 void ctdb_reply_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
161 int ctdb_ltdb_fetch(struct ctdb_context *ctdb,
162 TDB_DATA key, struct ctdb_ltdb_header *header, TDB_DATA *data);
163 int ctdb_ltdb_store(struct ctdb_context *ctdb, TDB_DATA key,
164 struct ctdb_ltdb_header *header, TDB_DATA data);