Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#ifndef _CTDB_PRIVATE_H
+#define _CTDB_PRIVATE_H
+
+#include "ctdb.h"
/*
an installed ctdb remote call
int (*start)(struct ctdb_context *); /* start protocol processing */
int (*add_node)(struct ctdb_node *); /* setup a new node */
int (*queue_pkt)(struct ctdb_node *, uint8_t *data, uint32_t length);
+ void *(*allocate_pkt)(struct ctdb_context *, size_t );
};
/*
struct ctdb_node **nodes; /* array of nodes in the cluster - indexed by vnn */
struct ctdb_registered_call *calls; /* list of registered calls */
char *err_msg;
- struct tdb_context *ltdb;
+ struct tdb_wrap *ltdb;
const struct ctdb_methods *methods; /* transport methods */
const struct ctdb_upcalls *upcalls; /* transport upcalls */
void *private; /* private to transport */
+ unsigned max_lacount;
};
#define CTDB_NO_MEMORY(ctdb, p) do { if (!(p)) { \
ctdb_set_error(ctdb, "Out of memory at %s:%d", __FILE__, __LINE__); \
return NULL; }} while (0)
+#define CTDB_NO_MEMORY_FATAL(ctdb, p) do { if (!(p)) { \
+ ctdb_fatal(ctdb, "Out of memory in " __location__ ); \
+ }} while (0)
+
/* arbitrary maximum timeout for ctdb operations */
#define CTDB_REQ_TIMEOUT 10
/* max number of redirects before we ask the lmaster */
#define CTDB_MAX_REDIRECT 2
+/* number of consecutive calls from the same node before we give them
+ the record */
+#define CTDB_DEFAULT_MAX_LACOUNT 7
+
/*
the extended header for records in the ltdb
*/
uint32_t callid;
uint32_t keylen;
uint32_t calldatalen;
- uint8_t data[0]; /* key[] followed by calldata[] */
+ uint8_t data[1]; /* key[] followed by calldata[] */
};
struct ctdb_reply_call {
struct ctdb_req_header hdr;
+ uint32_t status;
uint32_t datalen;
- uint8_t data[0];
+ uint8_t data[1];
};
struct ctdb_reply_error {
struct ctdb_req_header hdr;
uint32_t status;
uint32_t msglen;
- uint8_t msg[0];
+ uint8_t msg[1];
};
struct ctdb_reply_redirect {
uint32_t dmaster;
};
+struct ctdb_req_dmaster {
+ struct ctdb_req_header hdr;
+ uint32_t dmaster;
+ uint32_t keylen;
+ uint32_t datalen;
+ uint8_t data[1];
+};
+
+struct ctdb_reply_dmaster {
+ struct ctdb_req_header hdr;
+ uint32_t datalen;
+ uint8_t data[1];
+};
+
/* internal prototypes */
-void ctdb_set_error(struct ctdb_context *ctdb, const char *fmt, ...);
+void ctdb_set_error(struct ctdb_context *ctdb, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
+void ctdb_fatal(struct ctdb_context *ctdb, const char *msg);
bool ctdb_same_address(struct ctdb_address *a1, struct ctdb_address *a2);
int ctdb_parse_address(struct ctdb_context *ctdb,
TALLOC_CTX *mem_ctx, const char *str,
struct ctdb_address *address);
-uint32_t ctdb_hash(TDB_DATA *key);
+uint32_t ctdb_hash(const TDB_DATA *key);
void ctdb_request_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
+void ctdb_request_dmaster(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
+void ctdb_reply_dmaster(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
void ctdb_reply_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
void ctdb_reply_error(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
+void ctdb_reply_redirect(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
-uint32_t ctdb_lmaster(struct ctdb_context *ctdb, TDB_DATA key);
+uint32_t ctdb_lmaster(struct ctdb_context *ctdb, const TDB_DATA *key);
int ctdb_ltdb_fetch(struct ctdb_context *ctdb,
TDB_DATA key, struct ctdb_ltdb_header *header, TDB_DATA *data);
int ctdb_ltdb_store(struct ctdb_context *ctdb, TDB_DATA key,
struct ctdb_ltdb_header *header, TDB_DATA data);
+#endif