2010-05-20 09:48:30 +04:00
/*
ctdb database library : old client interface
2006-11-18 02:41:20 +03:00
Copyright ( C ) Andrew Tridgell 2006
2007-05-31 07:50:53 +04:00
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
2007-07-10 09:29:31 +04:00
the Free Software Foundation ; either version 3 of the License , or
2007-05-31 07:50:53 +04:00
( at your option ) any later version .
2010-05-20 09:48:30 +04:00
2007-05-31 07:50:53 +04:00
This program is distributed in the hope that it will be useful ,
2006-11-18 02:41:20 +03:00
but WITHOUT ANY WARRANTY ; without even the implied warranty of
2007-05-31 07:50:53 +04:00
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
2010-05-20 09:48:30 +04:00
2007-05-31 07:50:53 +04:00
You should have received a copy of the GNU General Public License
2007-07-10 09:29:31 +04:00
along with this program ; if not , see < http : //www.gnu.org/licenses/>.
2006-11-18 02:41:20 +03:00
*/
2010-05-20 09:48:30 +04:00
# ifndef _CTDB_CLIENT_H
# define _CTDB_CLIENT_H
2015-04-08 07:38:26 +03:00
# include "common/srvid.h"
2012-10-09 13:39:58 +04:00
# include "ctdb_protocol.h"
2009-12-11 16:19:55 +03:00
2015-10-27 09:34:06 +03:00
enum control_state {
CTDB_CONTROL_WAIT ,
CTDB_CONTROL_DONE ,
CTDB_CONTROL_ERROR ,
CTDB_CONTROL_TIMEOUT
} ;
2007-08-23 13:27:09 +04:00
2007-08-24 04:42:06 +04:00
struct ctdb_client_control_state {
struct ctdb_context * ctdb ;
uint32_t reqid ;
2007-08-23 13:27:09 +04:00
int32_t status ;
TDB_DATA outdata ;
2007-08-24 04:42:06 +04:00
enum control_state state ;
2007-08-23 13:27:09 +04:00
char * errormsg ;
2015-10-29 08:42:05 +03:00
struct ctdb_req_control_old * c ;
2007-08-24 04:42:06 +04:00
/* if we have a callback registered for the completion (or failure) of
this control
if a callback is used , it MUST talloc_free the cb_data passed to it
*/
struct {
void ( * fn ) ( struct ctdb_client_control_state * ) ;
2007-09-26 08:25:32 +04:00
void * private_data ;
2010-05-20 09:48:30 +04:00
} async ;
2007-08-23 13:27:09 +04:00
} ;
2010-08-18 03:46:31 +04:00
struct tevent_context ;
2015-10-27 09:34:06 +03:00
struct ctdb_db_context ;
2006-11-18 02:41:20 +03:00
/*
2015-10-27 09:34:06 +03:00
allocate a packet for use in client < - > daemon communication
*/
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 ) ;
2011-08-08 18:35:56 +04:00
2015-10-27 09:34:06 +03:00
# define ctdbd_allocate_pkt(ctdb, mem_ctx, operation, length, type) \
( type * ) _ctdbd_allocate_pkt ( ctdb , mem_ctx , operation , length , \
sizeof ( type ) , # type )
2007-04-03 13:41:00 +04:00
2015-10-27 09:34:06 +03:00
int ctdb_call_local ( struct ctdb_db_context * ctdb_db , struct ctdb_call * call ,
struct ctdb_ltdb_header * header , TALLOC_CTX * mem_ctx ,
TDB_DATA * data , bool updatetdb ) ;
2006-11-18 02:41:20 +03:00
2015-10-27 09:34:06 +03:00
void ctdb_request_message ( struct ctdb_context * ctdb ,
struct ctdb_req_header * hdr ) ;
2006-11-18 02:41:20 +03:00
2015-10-27 09:34:06 +03:00
void ctdb_client_read_cb ( uint8_t * data , size_t cnt , void * args ) ;
2006-11-18 02:41:20 +03:00
2015-10-27 09:34:06 +03:00
int ctdb_socket_connect ( struct ctdb_context * ctdb ) ;
2006-11-18 02:41:20 +03:00
/*
make a ctdb call . The associated ctdb call function will be called on the DMASTER
for the given record
*/
2015-10-27 09:34:06 +03:00
struct ctdb_client_call_state * ctdb_call_send ( struct ctdb_db_context * ctdb_db ,
struct ctdb_call * call ) ;
int ctdb_call_recv ( struct ctdb_client_call_state * state ,
struct ctdb_call * call ) ;
2007-04-03 13:41:00 +04:00
int ctdb_call ( struct ctdb_db_context * ctdb_db , struct ctdb_call * call ) ;
2006-11-27 13:38:13 +03:00
2007-02-09 01:42:04 +03:00
/* setup a handler for ctdb messages */
2010-06-02 04:00:58 +04:00
typedef void ( * ctdb_msg_fn_t ) ( struct ctdb_context * , uint64_t srvid ,
2015-10-27 09:34:06 +03:00
TDB_DATA data , void * ) ;
2010-06-02 03:51:47 +04:00
int ctdb_client_set_message_handler ( struct ctdb_context * ctdb , uint64_t srvid ,
2015-04-08 07:38:26 +03:00
srvid_handler_fn handler ,
void * private_data ) ;
2010-06-02 04:05:58 +04:00
int ctdb_client_remove_message_handler ( struct ctdb_context * ctdb ,
uint64_t srvid , void * private_data ) ;
2007-04-09 05:51:27 +04:00
2007-02-09 01:42:04 +03:00
/* send a ctdb message */
2010-06-02 03:45:21 +04:00
int ctdb_client_send_message ( struct ctdb_context * ctdb , uint32_t pnn ,
2015-10-27 09:34:06 +03:00
uint64_t srvid , TDB_DATA data ) ;
2007-04-04 15:15:56 +04:00
2015-10-27 09:34:06 +03:00
struct ctdb_client_control_state * ctdb_control_send ( struct ctdb_context * ctdb ,
uint32_t destnode ,
uint64_t srvid ,
uint32_t opcode ,
uint32_t flags ,
TDB_DATA data ,
TALLOC_CTX * mem_ctx ,
struct timeval * timeout ,
char * * errormsg ) ;
int ctdb_control_recv ( struct ctdb_context * ctdb ,
struct ctdb_client_control_state * state ,
TALLOC_CTX * mem_ctx , TDB_DATA * outdata ,
int32_t * status , char * * errormsg ) ;
int ctdb_control ( struct ctdb_context * ctdb , uint32_t destnode , uint64_t srvid ,
uint32_t opcode , uint32_t flags , TDB_DATA data ,
TALLOC_CTX * mem_ctx , TDB_DATA * outdata , int32_t * status ,
struct timeval * timeout , char * * errormsg ) ;
2007-04-17 05:34:45 +04:00
2015-10-27 09:34:06 +03:00
int ctdb_ctrl_getvnnmap ( struct ctdb_context * ctdb , struct timeval timeout ,
uint32_t destnode , TALLOC_CTX * mem_ctx ,
struct ctdb_vnn_map * * vnnmap ) ;
2007-04-29 12:34:11 +04:00
2007-04-29 16:51:56 +04:00
/*
get the recovery mode of a remote node
*/
2015-10-27 09:34:06 +03:00
struct ctdb_client_control_state * ctdb_ctrl_getrecmode_send (
struct ctdb_context * ctdb ,
TALLOC_CTX * mem_ctx ,
struct timeval timeout ,
uint32_t destnode ) ;
int ctdb_ctrl_getrecmode_recv ( struct ctdb_context * ctdb , TALLOC_CTX * mem_ctx ,
struct ctdb_client_control_state * state ,
uint32_t * recmode ) ;
int ctdb_ctrl_getrecmode ( struct ctdb_context * ctdb , TALLOC_CTX * mem_ctx ,
struct timeval timeout , uint32_t destnode ,
uint32_t * recmode ) ;
2007-08-23 07:00:10 +04:00
2007-04-29 16:51:56 +04:00
/*
set the recovery mode of a remote node
*/
2015-10-27 09:34:06 +03:00
int ctdb_ctrl_setrecmode ( struct ctdb_context * ctdb , struct timeval timeout ,
uint32_t destnode , uint32_t recmode ) ;
2007-04-29 16:51:56 +04:00
2008-03-25 00:27:38 +03:00
/*
2015-10-27 09:34:06 +03:00
get the recovery master of a remote node
2008-03-25 00:27:38 +03:00
*/
2015-10-27 09:34:06 +03:00
struct ctdb_client_control_state * ctdb_ctrl_getrecmaster_send (
struct ctdb_context * ctdb ,
TALLOC_CTX * mem_ctx ,
struct timeval timeout ,
uint32_t destnode ) ;
int ctdb_ctrl_getrecmaster_recv ( struct ctdb_context * ctdb ,
TALLOC_CTX * mem_ctx ,
struct ctdb_client_control_state * state ,
uint32_t * recmaster ) ;
int ctdb_ctrl_getrecmaster ( struct ctdb_context * ctdb , TALLOC_CTX * mem_ctx ,
struct timeval timeout , uint32_t destnode ,
uint32_t * recmaster ) ;
2008-03-25 00:27:38 +03:00
/*
2015-10-27 09:34:06 +03:00
set the recovery master of a remote node
2008-03-25 00:27:38 +03:00
*/
2015-10-27 09:34:06 +03:00
int ctdb_ctrl_setrecmaster ( struct ctdb_context * ctdb , struct timeval timeout ,
uint32_t destnode , uint32_t recmaster ) ;
2008-03-25 00:27:38 +03:00
2015-10-27 09:34:06 +03:00
int ctdb_ctrl_getnodemap ( struct ctdb_context * ctdb , struct timeval timeout ,
uint32_t destnode , TALLOC_CTX * mem_ctx ,
2015-10-29 09:22:48 +03:00
struct ctdb_node_map_old * * nodemap ) ;
2007-08-23 13:27:09 +04:00
2015-10-27 09:34:06 +03:00
int ctdb_ctrl_get_runstate ( struct ctdb_context * ctdb , struct timeval timeout ,
uint32_t destnode , uint32_t * runstate ) ;
int ctdb_ctrl_get_debuglevel ( struct ctdb_context * ctdb , uint32_t destnode ,
int32_t * level ) ;
2007-04-28 21:13:36 +04:00
2015-10-27 09:34:06 +03:00
int ctdb_ctrl_freeze ( struct ctdb_context * ctdb , struct timeval timeout ,
uint32_t destnode ) ;
2007-08-27 04:31:22 +04:00
2015-10-27 09:34:06 +03:00
int ctdb_ctrl_getpnn ( struct ctdb_context * ctdb , struct timeval timeout ,
uint32_t destnode ) ;
2007-08-27 04:31:22 +04:00
2015-10-27 09:34:06 +03:00
int ctdb_ctrl_get_public_ips_flags ( struct ctdb_context * ctdb ,
struct timeval timeout , uint32_t destnode ,
TALLOC_CTX * mem_ctx , uint32_t flags ,
2015-10-28 09:16:24 +03:00
struct ctdb_public_ip_list_old * * ips ) ;
2015-10-27 09:34:06 +03:00
int ctdb_ctrl_get_public_ips ( struct ctdb_context * ctdb ,
struct timeval timeout , uint32_t destnode ,
TALLOC_CTX * mem_ctx ,
2015-10-28 09:16:24 +03:00
struct ctdb_public_ip_list_old * * ips ) ;
2015-10-27 09:34:06 +03:00
int ctdb_ctrl_get_ifaces ( struct ctdb_context * ctdb ,
struct timeval timeout , uint32_t destnode ,
TALLOC_CTX * mem_ctx ,
2015-10-28 11:43:48 +03:00
struct ctdb_iface_list_old * * ifaces ) ;
2015-10-27 09:34:06 +03:00
2010-05-20 09:48:30 +04:00
int ctdb_ctrl_modflags ( struct ctdb_context * ctdb ,
struct timeval timeout ,
uint32_t destnode ,
2007-06-07 09:18:55 +04:00
uint32_t set , uint32_t clear ) ;
2007-06-04 13:53:19 +04:00
2015-10-27 09:34:06 +03:00
int ctdb_ctrl_get_all_tunables ( struct ctdb_context * ctdb ,
struct timeval timeout , uint32_t destnode ,
2015-10-28 10:51:22 +03:00
struct ctdb_tunable_list * tunables ) ;
2015-10-27 09:34:06 +03:00
/*
set some flags
*/
void ctdb_set_flags ( struct ctdb_context * ctdb , unsigned flags ) ;
const char * ctdb_get_socketname ( struct ctdb_context * ctdb ) ;
/* return pnn of this node */
uint32_t ctdb_get_pnn ( struct ctdb_context * ctdb ) ;
2007-08-15 03:03:58 +04:00
2015-10-27 09:34:06 +03:00
typedef void ( * client_async_callback ) ( struct ctdb_context * ctdb ,
uint32_t node_pnn , int32_t res ,
TDB_DATA outdata , void * callback_data ) ;
struct client_async_data {
enum ctdb_controls opcode ;
bool dont_log_errors ;
uint32_t count ;
uint32_t fail_count ;
client_async_callback callback ;
client_async_callback fail_callback ;
void * callback_data ;
} ;
2008-01-17 03:33:23 +03:00
2015-10-27 09:34:06 +03:00
void ctdb_client_async_add ( struct client_async_data * data ,
struct ctdb_client_control_state * state ) ;
int ctdb_client_async_wait ( struct ctdb_context * ctdb ,
struct client_async_data * data ) ;
int ctdb_client_async_control ( struct ctdb_context * ctdb ,
enum ctdb_controls opcode , uint32_t * nodes ,
uint64_t srvid , struct timeval timeout ,
bool dont_log_errors , TDB_DATA data ,
client_async_callback client_callback ,
client_async_callback fail_callback ,
void * callback_data ) ;
2008-01-17 03:33:23 +03:00
2015-10-27 09:34:06 +03:00
uint32_t * list_of_vnnmap_nodes ( struct ctdb_context * ctdb ,
struct ctdb_vnn_map * vnn_map ,
TALLOC_CTX * mem_ctx , bool include_self ) ;
2008-01-17 03:33:23 +03:00
2015-10-27 09:34:06 +03:00
uint32_t * list_of_active_nodes ( struct ctdb_context * ctdb ,
2015-10-29 09:22:48 +03:00
struct ctdb_node_map_old * node_map ,
2015-10-27 09:34:06 +03:00
TALLOC_CTX * mem_ctx , bool include_self ) ;
uint32_t * list_of_connected_nodes ( struct ctdb_context * ctdb ,
2015-10-29 09:22:48 +03:00
struct ctdb_node_map_old * node_map ,
2015-10-27 09:34:06 +03:00
TALLOC_CTX * mem_ctx , bool include_self ) ;
2008-01-29 05:59:28 +03:00
2015-10-27 09:34:06 +03:00
/*
get capabilities of a remote node
*/
struct ctdb_client_control_state * ctdb_ctrl_getcapabilities_send (
struct ctdb_context * ctdb ,
TALLOC_CTX * mem_ctx ,
struct timeval timeout ,
uint32_t destnode ) ;
int ctdb_ctrl_getcapabilities_recv ( struct ctdb_context * ctdb ,
TALLOC_CTX * mem_ctx ,
struct ctdb_client_control_state * state ,
uint32_t * capabilities ) ;
int ctdb_ctrl_getcapabilities ( struct ctdb_context * ctdb ,
struct timeval timeout , uint32_t destnode ,
uint32_t * capabilities ) ;
2008-02-29 02:03:39 +03:00
2014-07-31 09:06:19 +04:00
struct ctdb_node_capabilities {
bool retrieved ;
uint32_t capabilities ;
} ;
/* Retrieve capabilities for all connected nodes. The length of the
* returned array can be calculated using talloc_array_length ( ) . */
2015-10-27 09:34:06 +03:00
struct ctdb_node_capabilities * ctdb_get_capabilities (
struct ctdb_context * ctdb ,
TALLOC_CTX * mem_ctx ,
struct timeval timeout ,
2015-10-29 09:22:48 +03:00
struct ctdb_node_map_old * nodemap ) ;
2014-07-31 09:06:19 +04:00
/* Get capabilities for specified node, NULL if not found */
2015-10-27 09:34:06 +03:00
uint32_t * ctdb_get_node_capabilities ( struct ctdb_node_capabilities * caps ,
uint32_t pnn ) ;
2014-07-31 09:06:19 +04:00
/* True if the given node has all of the required capabilities */
bool ctdb_node_has_capabilities ( struct ctdb_node_capabilities * caps ,
2015-10-27 09:34:06 +03:00
uint32_t pnn , uint32_t capabilities_required ) ;
2008-11-19 06:43:46 +03:00
2008-09-09 07:44:46 +04:00
int ctdb_ctrl_recd_ping ( struct ctdb_context * ctdb ) ;
2015-10-27 09:34:06 +03:00
int ctdb_ctrl_report_recd_lock_latency ( struct ctdb_context * ctdb ,
struct timeval timeout , double latency ) ;
2011-09-01 05:08:18 +04:00
2015-10-27 09:34:06 +03:00
int ctdb_ctrl_set_ban ( struct ctdb_context * ctdb , struct timeval timeout ,
2015-10-28 10:18:33 +03:00
uint32_t destnode , struct ctdb_ban_state * bantime ) ;
2015-10-27 09:34:06 +03:00
struct ctdb_client_control_state * ctdb_ctrl_updaterecord_send (
struct ctdb_context * ctdb ,
TALLOC_CTX * mem_ctx ,
struct timeval timeout ,
uint32_t destnode ,
struct ctdb_db_context * ctdb_db ,
TDB_DATA key ,
struct ctdb_ltdb_header * header ,
TDB_DATA data ) ;
int ctdb_ctrl_updaterecord_recv ( struct ctdb_context * ctdb ,
struct ctdb_client_control_state * state ) ;
int ctdb_ctrl_updaterecord ( struct ctdb_context * ctdb , TALLOC_CTX * mem_ctx ,
struct timeval timeout , uint32_t destnode ,
struct ctdb_db_context * ctdb_db , TDB_DATA key ,
struct ctdb_ltdb_header * header , TDB_DATA data ) ;
2010-05-20 09:48:30 +04:00
# endif /* _CTDB_CLIENT_H */