2006-11-18 02:41:20 +03:00
/*
ctdb database library
Copyright ( C ) Andrew Tridgell 2006
This library is free software ; you can redistribute it and / or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation ; either
version 2 of the License , or ( at your option ) any later version .
This library is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the GNU
Lesser General Public License for more details .
You should have received a copy of the GNU Lesser General Public
License along with this library ; if not , write to the Free Software
Foundation , Inc . , 59 Temple Place , Suite 330 , Boston , MA 02111 - 1307 USA
*/
2007-01-23 03:38:45 +03:00
# ifndef _CTDB_PRIVATE_H
# define _CTDB_PRIVATE_H
# include "ctdb.h"
2006-11-18 02:41:20 +03:00
2007-04-11 05:01:42 +04:00
/* location of daemon socket */
# define CTDB_PATH " / tmp / ctdb.socket"
/* we must align packets to ensure ctdb works on all architectures (eg. sparc) */
# define CTDB_DS_ALIGNMENT 8
2007-04-27 17:16:17 +04:00
# define CTDB_NULL_FUNC 0xF0000001
2007-04-04 15:15:56 +04:00
2007-04-27 17:16:17 +04:00
# define CTDB_CURRENT_NODE 0xF0000001
# define CTDB_BROADCAST_VNN 0xF0000002
2007-04-27 18:42:43 +04:00
2006-11-18 02:41:20 +03:00
/*
an installed ctdb remote call
*/
struct ctdb_registered_call {
struct ctdb_registered_call * next , * prev ;
uint32_t id ;
ctdb_fn_t fn ;
} ;
2006-11-27 13:38:13 +03:00
/*
this address structure might need to be generalised later for some
transports
*/
2006-11-18 03:21:40 +03:00
struct ctdb_address {
const char * address ;
int port ;
} ;
2007-04-18 12:39:02 +04:00
/*
check a vnn is valid
*/
# define ctdb_validate_vnn(ctdb, vnn) (((uint32_t)(vnn)) < (ctdb)->num_nodes)
2007-04-10 13:33:21 +04:00
/* called from the queue code when a packet comes in. Called with data==NULL
on error */
2007-04-11 22:12:15 +04:00
typedef void ( * ctdb_queue_cb_fn_t ) ( uint8_t * data , size_t length ,
void * private_data ) ;
2007-04-10 13:33:21 +04:00
2007-04-26 16:27:49 +04:00
/* used for callbacks in ctdb_control requests */
typedef void ( * ctdb_control_callback_fn_t ) ( struct ctdb_context * ,
uint32_t status , TDB_DATA data ,
void * private_data ) ;
2007-04-10 13:33:21 +04:00
2006-11-18 02:41:20 +03:00
/*
state associated with one node
*/
struct ctdb_node {
struct ctdb_context * ctdb ;
2006-11-18 03:21:40 +03:00
struct ctdb_address address ;
2006-11-28 06:15:46 +03:00
const char * name ; /* for debug messages */
2007-04-11 22:12:15 +04:00
void * private_data ; /* private to transport */
2006-11-28 09:56:10 +03:00
uint32_t vnn ;
2007-04-28 14:40:26 +04:00
# define NODE_FLAGS_CONNECTED 0x00000001
uint32_t flags ;
2006-11-18 02:41:20 +03:00
} ;
2006-11-18 05:45:04 +03:00
/*
2006-11-27 13:38:13 +03:00
transport specific methods
2006-11-18 05:45:04 +03:00
*/
2006-11-27 13:38:13 +03:00
struct ctdb_methods {
int ( * start ) ( struct ctdb_context * ) ; /* start protocol processing */
int ( * add_node ) ( struct ctdb_node * ) ; /* setup a new node */
2006-11-28 03:51:33 +03:00
int ( * queue_pkt ) ( struct ctdb_node * , uint8_t * data , uint32_t length ) ;
2007-04-19 04:37:44 +04:00
void * ( * allocate_pkt ) ( TALLOC_CTX * mem_ctx , size_t ) ;
2006-11-28 03:51:33 +03:00
} ;
/*
transport calls up to the ctdb layer
*/
struct ctdb_upcalls {
2006-11-28 09:56:10 +03:00
/* recv_pkt is called when a packet comes in */
2006-11-28 06:15:46 +03:00
void ( * recv_pkt ) ( struct ctdb_context * , uint8_t * data , uint32_t length ) ;
2006-11-28 09:56:10 +03:00
/* node_dead is called when an attempt to send to a node fails */
2006-11-28 06:15:46 +03:00
void ( * node_dead ) ( struct ctdb_node * ) ;
2006-11-28 09:56:10 +03:00
/* node_connected is called when a connection to a node is established */
void ( * node_connected ) ( struct ctdb_node * ) ;
2006-11-18 05:45:04 +03:00
} ;
2007-04-11 05:58:28 +04:00
/* list of message handlers - needs to be changed to a more efficient data
structure so we can find a message handler given a srvid quickly */
struct ctdb_message_list {
struct ctdb_context * ctdb ;
struct ctdb_message_list * next , * prev ;
2007-04-27 18:31:45 +04:00
uint64_t srvid ;
2007-04-11 05:58:28 +04:00
ctdb_message_fn_t message_handler ;
void * message_private ;
} ;
2007-04-10 00:03:39 +04:00
/* additional data required for the daemon mode */
struct ctdb_daemon_data {
int sd ;
char * name ;
2007-04-10 13:33:21 +04:00
struct ctdb_queue * queue ;
2007-04-10 00:03:39 +04:00
} ;
2007-04-03 13:41:00 +04:00
2007-04-20 14:07:47 +04:00
/*
ctdb status information
*/
struct ctdb_status {
uint32_t client_packets_sent ;
uint32_t client_packets_recv ;
uint32_t node_packets_sent ;
uint32_t node_packets_recv ;
2007-04-20 15:02:53 +04:00
struct {
uint32_t req_call ;
uint32_t reply_call ;
uint32_t reply_redirect ;
uint32_t req_dmaster ;
uint32_t reply_dmaster ;
uint32_t reply_error ;
uint32_t req_message ;
uint32_t req_finished ;
2007-04-26 16:27:49 +04:00
uint32_t req_control ;
uint32_t reply_control ;
2007-04-20 15:02:53 +04:00
} count ;
struct {
uint32_t req_call ;
uint32_t req_message ;
uint32_t req_finished ;
uint32_t req_register ;
uint32_t req_connect_wait ;
uint32_t req_shutdown ;
2007-04-26 16:27:49 +04:00
uint32_t req_control ;
2007-04-20 15:02:53 +04:00
} client ;
2007-04-20 14:07:47 +04:00
uint32_t total_calls ;
uint32_t pending_calls ;
uint32_t lockwait_calls ;
uint32_t pending_lockwait_calls ;
2007-04-28 19:13:30 +04:00
uint32_t __last_uint32 ; /* hack for control_status_all */
2007-04-22 20:57:22 +04:00
uint32_t max_redirect_count ;
2007-04-20 14:07:47 +04:00
double max_call_latency ;
double max_lockwait_latency ;
} ;
2007-04-27 12:43:52 +04:00
/* table that contains the mapping between a hash value and lmaster
*/
struct ctdb_vnn_map {
uint32_t generation ;
uint32_t size ;
uint32_t * map ;
} ;
2006-11-18 02:41:20 +03:00
/* main state of the ctdb daemon */
struct ctdb_context {
struct event_context * ev ;
2006-11-18 03:21:40 +03:00
struct ctdb_address address ;
2006-11-28 09:56:10 +03:00
const char * name ;
2007-04-18 18:36:22 +04:00
const char * db_directory ;
2007-04-26 17:28:13 +04:00
const char * transport ;
2006-11-28 09:56:10 +03:00
uint32_t vnn ; /* our own vnn */
uint32_t num_nodes ;
2006-12-01 01:01:11 +03:00
uint32_t num_connected ;
2007-04-18 05:55:54 +04:00
uint32_t num_finished ;
2006-12-01 07:45:24 +03:00
unsigned flags ;
2006-11-28 12:48:34 +03:00
struct idr_context * idr ;
2007-04-23 12:19:50 +04:00
uint16_t idr_cnt ;
2006-11-28 09:56:10 +03:00
struct ctdb_node * * nodes ; /* array of nodes in the cluster - indexed by vnn */
2006-11-18 02:41:20 +03:00
char * err_msg ;
2006-11-27 13:38:13 +03:00
const struct ctdb_methods * methods ; /* transport methods */
2006-11-28 03:51:33 +03:00
const struct ctdb_upcalls * upcalls ; /* transport upcalls */
2007-04-11 22:12:15 +04:00
void * private_data ; /* private to transport */
2007-01-23 03:38:45 +03:00
unsigned max_lacount ;
2007-04-03 13:41:00 +04:00
struct ctdb_db_context * db_list ;
2007-04-11 05:58:28 +04:00
struct ctdb_message_list * message_list ;
2007-04-10 00:03:39 +04:00
struct ctdb_daemon_data daemon ;
2007-04-20 14:07:47 +04:00
struct ctdb_status status ;
2007-04-27 12:43:52 +04:00
struct ctdb_vnn_map * vnn_map ;
2007-04-28 17:15:21 +04:00
uint32_t num_clients ;
2007-04-03 13:41:00 +04:00
} ;
struct ctdb_db_context {
struct ctdb_db_context * next , * prev ;
struct ctdb_context * ctdb ;
uint32_t db_id ;
const char * db_name ;
2007-04-27 01:10:35 +04:00
const char * db_path ;
2007-04-03 13:41:00 +04:00
struct tdb_wrap * ltdb ;
struct ctdb_registered_call * calls ; /* list of registered calls */
2006-11-18 02:41:20 +03:00
} ;
2007-04-09 05:51:27 +04:00
2006-11-27 13:38:13 +03:00
# define CTDB_NO_MEMORY(ctdb, p) do { if (!(p)) { \
ctdb_set_error ( ctdb , " Out of memory at %s:%d " , __FILE__ , __LINE__ ) ; \
return - 1 ; } } while ( 0 )
2007-04-26 16:27:49 +04:00
# define CTDB_NO_MEMORY_VOID(ctdb, p) do { if (!(p)) { \
ctdb_set_error ( ctdb , " Out of memory at %s:%d " , __FILE__ , __LINE__ ) ; \
} } while ( 0 )
2006-12-01 12:26:21 +03:00
# define CTDB_NO_MEMORY_NULL(ctdb, p) do { if (!(p)) { \
ctdb_set_error ( ctdb , " Out of memory at %s:%d " , __FILE__ , __LINE__ ) ; \
return NULL ; } } while ( 0 )
2006-12-18 08:26:57 +03:00
# define CTDB_NO_MEMORY_FATAL(ctdb, p) do { if (!(p)) { \
ctdb_fatal ( ctdb , " Out of memory in " __location__ ) ; \
} } while ( 0 )
2006-11-28 12:48:34 +03:00
/* arbitrary maximum timeout for ctdb operations */
2007-04-22 16:26:45 +04:00
# define CTDB_REQ_TIMEOUT 0
2006-11-28 12:48:34 +03:00
2006-12-18 06:44:06 +03:00
/* max number of redirects before we ask the lmaster */
# define CTDB_MAX_REDIRECT 2
2006-12-18 08:01:11 +03:00
/* number of consecutive calls from the same node before we give them
the record */
2007-01-23 03:38:45 +03:00
# define CTDB_DEFAULT_MAX_LACOUNT 7
2006-12-18 08:01:11 +03:00
2006-12-18 05:24:02 +03:00
/*
the extended header for records in the ltdb
*/
struct ctdb_ltdb_header {
uint64_t rsn ;
uint32_t dmaster ;
uint32_t laccessor ;
uint32_t lacount ;
} ;
2007-04-26 21:27:07 +04:00
enum ctdb_controls { CTDB_CONTROL_PROCESS_EXISTS ,
CTDB_CONTROL_STATUS ,
CTDB_CONTROL_CONFIG ,
2007-04-27 01:10:35 +04:00
CTDB_CONTROL_PING ,
2007-04-27 14:56:10 +04:00
CTDB_CONTROL_GETDBPATH ,
2007-04-27 16:08:12 +04:00
CTDB_CONTROL_GETVNNMAP ,
2007-04-27 17:14:36 +04:00
CTDB_CONTROL_SETVNNMAP ,
CTDB_CONTROL_GET_DEBUG ,
2007-04-28 14:00:50 +04:00
CTDB_CONTROL_SET_DEBUG ,
2007-04-28 14:40:26 +04:00
CTDB_CONTROL_GET_DBMAP ,
CTDB_CONTROL_GET_NODEMAP } ;
2007-04-26 16:27:49 +04:00
2007-04-09 05:51:27 +04:00
enum call_state { CTDB_CALL_WAIT , CTDB_CALL_DONE , CTDB_CALL_ERROR } ;
/*
state of a in - progress ctdb call
*/
struct ctdb_call_state {
enum call_state state ;
2007-04-23 12:19:50 +04:00
uint32_t reqid ;
2007-04-09 05:51:27 +04:00
struct ctdb_req_call * c ;
struct ctdb_db_context * ctdb_db ;
struct ctdb_node * node ;
const char * errmsg ;
struct ctdb_call call ;
int redirect_count ;
struct ctdb_ltdb_header header ;
2007-04-12 09:46:50 +04:00
struct {
void ( * fn ) ( struct ctdb_call_state * ) ;
2007-04-13 14:38:24 +04:00
void * private_data ;
2007-04-12 09:46:50 +04:00
} async ;
2007-04-09 05:51:27 +04:00
} ;
2006-11-28 12:48:34 +03:00
2007-04-17 06:36:31 +04:00
/* used for fetch_lock */
2007-04-18 05:20:24 +04:00
struct ctdb_fetch_handle {
2007-04-17 06:36:31 +04:00
struct ctdb_db_context * ctdb_db ;
TDB_DATA key ;
TDB_DATA * data ;
2007-04-17 08:52:51 +04:00
struct ctdb_ltdb_header header ;
2007-04-17 06:36:31 +04:00
} ;
2006-11-28 09:56:10 +03:00
/*
operation IDs
*/
enum ctdb_operation {
2007-04-11 08:54:47 +04:00
CTDB_REQ_CALL = 0 ,
CTDB_REPLY_CALL = 1 ,
CTDB_REPLY_REDIRECT = 2 ,
CTDB_REQ_DMASTER = 3 ,
CTDB_REPLY_DMASTER = 4 ,
CTDB_REPLY_ERROR = 5 ,
2007-04-12 09:46:50 +04:00
CTDB_REQ_MESSAGE = 6 ,
2007-04-18 05:55:54 +04:00
CTDB_REQ_FINISHED = 7 ,
2007-04-26 16:27:49 +04:00
CTDB_REQ_CONTROL = 8 ,
CTDB_REPLY_CONTROL = 9 ,
2007-04-12 09:46:50 +04:00
/* only used on the domain socket */
CTDB_REQ_REGISTER = 1000 ,
CTDB_REQ_CONNECT_WAIT = 1001 ,
CTDB_REPLY_CONNECT_WAIT = 1002 ,
2007-04-27 01:10:35 +04:00
CTDB_REQ_SHUTDOWN = 1003
2006-11-28 09:56:10 +03:00
} ;
2007-04-06 08:41:05 +04:00
# define CTDB_MAGIC 0x43544442 /* CTDB */
# define CTDB_VERSION 1
2006-11-28 09:56:10 +03:00
/*
packet structures
*/
struct ctdb_req_header {
2006-12-01 07:45:24 +03:00
uint32_t length ;
2007-04-06 08:41:05 +04:00
uint32_t ctdb_magic ;
uint32_t ctdb_version ;
2007-04-27 19:06:26 +04:00
uint32_t generation ;
2006-11-28 09:56:10 +03:00
uint32_t operation ;
uint32_t destnode ;
uint32_t srcnode ;
uint32_t reqid ;
} ;
struct ctdb_req_call {
struct ctdb_req_header hdr ;
2007-04-04 15:15:56 +04:00
uint32_t flags ;
2007-04-03 13:41:00 +04:00
uint32_t db_id ;
2006-11-28 09:56:10 +03:00
uint32_t callid ;
uint32_t keylen ;
uint32_t calldatalen ;
2007-01-23 03:38:45 +03:00
uint8_t data [ 1 ] ; /* key[] followed by calldata[] */
2006-11-28 09:56:10 +03:00
} ;
struct ctdb_reply_call {
2006-12-01 07:45:24 +03:00
struct ctdb_req_header hdr ;
2007-01-29 14:30:06 +03:00
uint32_t status ;
2006-11-28 09:56:10 +03:00
uint32_t datalen ;
2007-01-23 03:38:45 +03:00
uint8_t data [ 1 ] ;
2006-11-28 09:56:10 +03:00
} ;
2006-11-27 13:38:13 +03:00
2006-12-18 06:27:20 +03:00
struct ctdb_reply_error {
struct ctdb_req_header hdr ;
uint32_t status ;
uint32_t msglen ;
2007-01-23 03:38:45 +03:00
uint8_t msg [ 1 ] ;
2006-12-18 06:27:20 +03:00
} ;
2006-12-18 06:44:06 +03:00
struct ctdb_reply_redirect {
struct ctdb_req_header hdr ;
uint32_t dmaster ;
} ;
2006-12-18 08:01:11 +03:00
struct ctdb_req_dmaster {
struct ctdb_req_header hdr ;
2007-04-03 13:41:00 +04:00
uint32_t db_id ;
2006-12-18 08:01:11 +03:00
uint32_t dmaster ;
uint32_t keylen ;
uint32_t datalen ;
2007-01-23 03:38:45 +03:00
uint8_t data [ 1 ] ;
2006-12-18 08:01:11 +03:00
} ;
struct ctdb_reply_dmaster {
struct ctdb_req_header hdr ;
uint32_t datalen ;
2007-01-23 03:38:45 +03:00
uint8_t data [ 1 ] ;
2006-12-18 08:01:11 +03:00
} ;
2007-04-11 07:43:15 +04:00
struct ctdb_req_register {
2007-04-10 15:05:29 +04:00
struct ctdb_req_header hdr ;
2007-04-27 18:31:45 +04:00
uint64_t srvid ;
2007-04-10 15:05:29 +04:00
} ;
2007-02-09 01:42:04 +03:00
struct ctdb_req_message {
struct ctdb_req_header hdr ;
2007-04-27 18:31:45 +04:00
uint64_t srvid ;
2007-02-09 01:42:04 +03:00
uint32_t datalen ;
uint8_t data [ 1 ] ;
} ;
2007-04-18 05:55:54 +04:00
struct ctdb_req_finished {
struct ctdb_req_header hdr ;
} ;
2007-04-18 06:39:03 +04:00
struct ctdb_req_shutdown {
struct ctdb_req_header hdr ;
} ;
2007-04-11 08:54:47 +04:00
struct ctdb_req_connect_wait {
struct ctdb_req_header hdr ;
} ;
struct ctdb_reply_connect_wait {
struct ctdb_req_header hdr ;
2007-04-11 13:04:09 +04:00
uint32_t vnn ;
2007-04-11 08:54:47 +04:00
uint32_t num_connected ;
} ;
2007-04-23 18:06:48 +04:00
struct ctdb_req_getdbpath {
struct ctdb_req_header hdr ;
uint32_t db_id ;
} ;
struct ctdb_reply_getdbpath {
struct ctdb_req_header hdr ;
uint32_t datalen ;
uint8_t data [ 1 ] ;
} ;
2007-04-26 16:27:49 +04:00
struct ctdb_req_control {
struct ctdb_req_header hdr ;
uint32_t opcode ;
2007-04-27 18:31:45 +04:00
uint64_t srvid ;
2007-04-26 16:27:49 +04:00
uint32_t datalen ;
uint8_t data [ 1 ] ;
} ;
struct ctdb_reply_control {
struct ctdb_req_header hdr ;
int32_t status ;
uint32_t datalen ;
uint8_t data [ 1 ] ;
} ;
2006-11-27 13:38:13 +03:00
/* internal prototypes */
2007-01-23 03:38:45 +03:00
void ctdb_set_error ( struct ctdb_context * ctdb , const char * fmt , . . . ) PRINTF_ATTRIBUTE ( 2 , 3 ) ;
2006-12-18 08:01:11 +03:00
void ctdb_fatal ( struct ctdb_context * ctdb , const char * msg ) ;
2006-11-27 13:38:13 +03:00
bool ctdb_same_address ( struct ctdb_address * a1 , struct ctdb_address * a2 ) ;
2006-11-28 09:56:10 +03:00
int ctdb_parse_address ( struct ctdb_context * ctdb ,
TALLOC_CTX * mem_ctx , const char * str ,
struct ctdb_address * address ) ;
2006-12-18 08:01:11 +03:00
uint32_t ctdb_hash ( const TDB_DATA * key ) ;
2006-12-01 07:45:24 +03:00
void ctdb_request_call ( struct ctdb_context * ctdb , struct ctdb_req_header * hdr ) ;
2006-12-18 08:01:11 +03:00
void ctdb_request_dmaster ( struct ctdb_context * ctdb , struct ctdb_req_header * hdr ) ;
2007-02-09 01:42:04 +03:00
void ctdb_request_message ( struct ctdb_context * ctdb , struct ctdb_req_header * hdr ) ;
2006-12-18 08:01:11 +03:00
void ctdb_reply_dmaster ( struct ctdb_context * ctdb , struct ctdb_req_header * hdr ) ;
2006-12-01 07:45:24 +03:00
void ctdb_reply_call ( struct ctdb_context * ctdb , struct ctdb_req_header * hdr ) ;
2006-12-18 06:27:20 +03:00
void ctdb_reply_error ( struct ctdb_context * ctdb , struct ctdb_req_header * hdr ) ;
2006-12-18 08:01:11 +03:00
void ctdb_reply_redirect ( struct ctdb_context * ctdb , struct ctdb_req_header * hdr ) ;
2006-11-18 02:41:20 +03:00
2006-12-18 08:01:11 +03:00
uint32_t ctdb_lmaster ( struct ctdb_context * ctdb , const TDB_DATA * key ) ;
2007-04-03 13:41:00 +04:00
int ctdb_ltdb_fetch ( struct ctdb_db_context * ctdb_db ,
2007-04-07 04:45:00 +04:00
TDB_DATA key , struct ctdb_ltdb_header * header ,
TALLOC_CTX * mem_ctx , TDB_DATA * data ) ;
2007-04-03 13:41:00 +04:00
int ctdb_ltdb_store ( struct ctdb_db_context * ctdb_db , TDB_DATA key ,
2006-12-18 05:24:02 +03:00
struct ctdb_ltdb_header * header , TDB_DATA data ) ;
2007-02-09 01:42:04 +03:00
void ctdb_queue_packet ( struct ctdb_context * ctdb , struct ctdb_req_header * hdr ) ;
2007-04-19 11:43:27 +04:00
int ctdb_ltdb_lock_requeue ( struct ctdb_db_context * ctdb_db ,
TDB_DATA key , struct ctdb_req_header * hdr ,
void ( * recv_pkt ) ( void * , uint8_t * , uint32_t ) ,
void * recv_context ) ;
2007-04-16 17:52:14 +04:00
int ctdb_ltdb_lock_fetch_requeue ( struct ctdb_db_context * ctdb_db ,
TDB_DATA key , struct ctdb_ltdb_header * header ,
2007-04-19 10:27:56 +04:00
struct ctdb_req_header * hdr , TDB_DATA * data ,
void ( * recv_pkt ) ( void * , uint8_t * , uint32_t ) ,
void * recv_context ) ;
2007-04-16 17:52:14 +04:00
void ctdb_recv_pkt ( struct ctdb_context * ctdb , uint8_t * data , uint32_t length ) ;
2006-12-18 05:24:02 +03:00
2007-04-09 05:51:27 +04:00
struct ctdb_call_state * ctdb_call_local_send ( struct ctdb_db_context * ctdb_db ,
struct ctdb_call * call ,
struct ctdb_ltdb_header * header ,
TDB_DATA * data ) ;
2006-12-18 05:24:02 +03:00
2007-04-10 00:03:39 +04:00
int ctdbd_start ( struct ctdb_context * ctdb ) ;
struct ctdb_call_state * ctdbd_call_send ( struct ctdb_db_context * ctdb_db , struct ctdb_call * call ) ;
int ctdbd_call_recv ( struct ctdb_call_state * state , struct ctdb_call * call ) ;
2007-04-10 13:33:21 +04:00
/*
queue a packet for sending
*/
int ctdb_queue_send ( struct ctdb_queue * queue , uint8_t * data , uint32_t length ) ;
/*
setup the fd used by the queue
*/
int ctdb_queue_set_fd ( struct ctdb_queue * queue , int fd ) ;
/*
setup a packet queue on a socket
*/
struct ctdb_queue * ctdb_queue_setup ( struct ctdb_context * ctdb ,
TALLOC_CTX * mem_ctx , int fd , int alignment ,
ctdb_queue_cb_fn_t callback ,
2007-04-11 22:12:15 +04:00
void * private_data ) ;
2007-04-10 13:33:21 +04:00
2007-04-11 05:01:42 +04:00
/*
allocate a packet for use in client < - > daemon communication
*/
2007-04-28 12:50:32 +04:00
struct ctdb_req_header * _ctdbd_allocate_pkt ( struct ctdb_context * ctdb ,
TALLOC_CTX * mem_ctx ,
enum ctdb_operation operation ,
size_t length , size_t slength ,
const char * type ) ;
# define ctdbd_allocate_pkt(ctdb, mem_ctx, operation, length, type) \
( type * ) _ctdbd_allocate_pkt ( ctdb , mem_ctx , operation , length , sizeof ( type ) , # type )
struct ctdb_req_header * _ctdb_transport_allocate ( struct ctdb_context * ctdb ,
TALLOC_CTX * mem_ctx ,
enum ctdb_operation operation ,
size_t length , size_t slength ,
const char * type ) ;
# define ctdb_transport_allocate(ctdb, mem_ctx, operation, length, type) \
( type * ) _ctdb_transport_allocate ( ctdb , mem_ctx , operation , length , sizeof ( type ) , # type )
2007-04-11 05:01:42 +04:00
/*
lock a record in the ltdb , given a key
*/
int ctdb_ltdb_lock ( struct ctdb_db_context * ctdb_db , TDB_DATA key ) ;
/*
unlock a record in the ltdb , given a key
*/
int ctdb_ltdb_unlock ( struct ctdb_db_context * ctdb_db , TDB_DATA key ) ;
/*
make a ctdb call to the local daemon - async send . Called from client context .
2007-04-10 13:33:21 +04:00
2007-04-11 05:01:42 +04:00
This constructs a ctdb_call request and queues it for processing .
This call never blocks .
*/
struct ctdb_call_state * ctdb_client_call_send ( struct ctdb_db_context * ctdb_db ,
struct ctdb_call * call ) ;
/*
make a recv call to the local ctdb daemon - called from client context
This is called when the program wants to wait for a ctdb_call to complete and get the
results . This call will block unless the call has already completed .
*/
int ctdb_client_call_recv ( struct ctdb_call_state * state , struct ctdb_call * call ) ;
2007-04-10 00:03:39 +04:00
2007-04-27 18:31:45 +04:00
int ctdb_daemon_set_message_handler ( struct ctdb_context * ctdb , uint64_t srvid ,
2007-04-11 07:43:15 +04:00
ctdb_message_fn_t handler ,
2007-04-11 22:12:15 +04:00
void * private_data ) ;
2007-04-11 07:43:15 +04:00
int ctdb_client_send_message ( struct ctdb_context * ctdb , uint32_t vnn ,
2007-04-27 18:31:45 +04:00
uint64_t srvid , TDB_DATA data ) ;
2007-04-11 07:43:15 +04:00
2007-04-11 08:05:01 +04:00
/*
send a ctdb message
*/
int ctdb_daemon_send_message ( struct ctdb_context * ctdb , uint32_t vnn ,
2007-04-27 18:31:45 +04:00
uint64_t srvid , TDB_DATA data ) ;
2007-04-11 08:05:01 +04:00
2007-04-11 08:26:14 +04:00
2007-04-11 08:54:47 +04:00
/*
wait for all nodes to be connected
*/
void ctdb_daemon_connect_wait ( struct ctdb_context * ctdb ) ;
2007-04-12 09:46:50 +04:00
2007-04-16 17:52:14 +04:00
struct lockwait_handle * ctdb_lockwait ( struct ctdb_db_context * ctdb_db ,
TDB_DATA key ,
void ( * callback ) ( void * ) , void * private_data ) ;
2007-04-17 08:52:51 +04:00
struct ctdb_call_state * ctdb_daemon_call_send ( struct ctdb_db_context * ctdb_db ,
struct ctdb_call * call ) ;
int ctdb_daemon_call_recv ( struct ctdb_call_state * state , struct ctdb_call * call ) ;
2007-04-17 10:20:32 +04:00
struct ctdb_call_state * ctdb_daemon_call_send_remote ( struct ctdb_db_context * ctdb_db ,
struct ctdb_call * call ,
struct ctdb_ltdb_header * header ) ;
2007-04-19 03:14:25 +04:00
void ctdb_request_finished ( struct ctdb_context * ctdb , struct ctdb_req_header * hdr ) ;
2007-04-19 05:28:01 +04:00
int ctdb_call_local ( struct ctdb_db_context * ctdb_db , struct ctdb_call * call ,
struct ctdb_ltdb_header * header , TDB_DATA * data ,
uint32_t caller ) ;
2007-04-23 12:19:50 +04:00
# define ctdb_reqid_find(ctdb, reqid, type) (type *)_ctdb_reqid_find(ctdb, reqid, #type, __location__)
2007-04-19 05:28:01 +04:00
2007-04-19 10:27:56 +04:00
void ctdb_recv_raw_pkt ( void * p , uint8_t * data , uint32_t length ) ;
2007-04-20 14:07:47 +04:00
int ctdb_socket_connect ( struct ctdb_context * ctdb ) ;
void ctdb_latency ( double * latency , struct timeval t ) ;
2007-04-23 12:19:50 +04:00
uint32_t ctdb_reqid_new ( struct ctdb_context * ctdb , void * state ) ;
void * _ctdb_reqid_find ( struct ctdb_context * ctdb , uint32_t reqid , const char * type , const char * location ) ;
void ctdb_reqid_remove ( struct ctdb_context * ctdb , uint32_t reqid ) ;
2007-04-26 16:27:49 +04:00
void ctdb_request_control ( struct ctdb_context * ctdb , struct ctdb_req_header * hdr ) ;
void ctdb_reply_control ( struct ctdb_context * ctdb , struct ctdb_req_header * hdr ) ;
int ctdb_daemon_send_control ( struct ctdb_context * ctdb , uint32_t destnode ,
2007-04-27 18:31:45 +04:00
uint64_t srvid , uint32_t opcode , TDB_DATA data ,
2007-04-26 16:27:49 +04:00
ctdb_control_callback_fn_t callback ,
void * private_data ) ;
2007-01-23 03:38:45 +03:00
# endif