* @log: the logging function
* @log_priv: the private argument to the logging function.
*
- * Returns a ctdb context if successful or NULL. Use ctdb_free() to
+ * Returns a ctdb context if successful or NULL. Use ctdb_disconnect() to
* release the returned ctdb_connection when finished.
*
* See Also:
*/
extern int ctdb_log_level;
+ /**
+ * ctdb_disconnect - close down a connection to ctdbd.
+ * @ctdb: the ctdb connectio returned from ctdb_connect.
+ *
+ * The @ctdb arg will be freed by this call, and must not be used again.
+ */
+ void ctdb_disconnect(struct ctdb_connection *ctdb);
+
/***
*
* Asynchronous API
* actual private parameter.
*/
typedef void (*ctdb_callback_t)(struct ctdb_connection *ctdb,
- struct ctdb_request *req, void *private);
+ struct ctdb_request *req, void *private_data);
/**
* struct ctdb_db - connection to a particular open TDB
* This represents a particular open database: you receive it from
* ctdb_attachdb or ctdb_attachdb_recv to manipulate a database.
*
- * You have to free the handle with ctdb_detach_db() when finished with it.
+ * You have to free the handle with ctdb_detachdb() when finished with it.
*/
struct ctdb_db;
typedef void (*ctdb_rrl_callback_t)(struct ctdb_db *ctdb_db,
struct ctdb_lock *lock,
TDB_DATA data,
- void *private);
+ void *private_data);
/**
* ctdb_readrecordlock_async - read and lock a record
* @ctdb: the ctdb_connection from ctdb_connect.
* @srvid: the 64 bit identifier for our messages.
* @handler: the callback when we receive such a message (typesafe)
+ * @handler_data: the argument to handler()
* @callback: the callback when ctdb replies to our message (typesafe)
- * @cbdata: the argument to callback() and handler()
+ * @cbdata: the argument to callback()
*
* Note: our callback will always be called before handler.
*
struct ctdb_request *
ctdb_set_message_handler_send(struct ctdb_connection *ctdb, uint64_t srvid,
ctdb_message_fn_t handler,
+ void *handler_data,
ctdb_callback_t callback,
void *cbdata);
* ctdb_remove_message_handler_send - unregister for messages to a srvid
* @ctdb: the ctdb_connection from ctdb_connect.
* @srvid: the 64 bit identifier for our messages.
+ * @handler: the callback when we receive such a message (typesafe)
+ * @handler_data: the argument to handler()
* @callback: the callback when ctdb replies to our message (typesafe)
* @cbdata: the argument to callback()
*
*/
struct ctdb_request *
ctdb_remove_message_handler_send(struct ctdb_connection *ctdb, uint64_t srvid,
+ ctdb_message_fn_t handler, void *handler_data,
ctdb_callback_t callback, void *cbdata);
/**
* After this returns true, the registered handler will no longer be called.
* If this returns false, the de-registration failed.
*/
- bool ctdb_remove_message_handler_recv(struct ctdb_request *handle);
+ bool ctdb_remove_message_handler_recv(struct ctdb_connection *ctdb,
+ struct ctdb_request *req);
/**
const char *name, bool persistent,
uint32_t tdb_flags);
+ /**
+ * ctdb_detachdb - close a clustered TDB.
+ * @ctdb: the ctdb_connection from ctdb_connect.
+ * @db: the database from ctdb_attachdb/ctdb_attachdb_send
+ *
+ * Closes a clustered tdb.
+ */
+ void ctdb_detachdb(struct ctdb_connection *ctdb, struct ctdb_db *db);
+
/**
* ctdb_readrecordlock - read and lock a record (synchronous)
+ * @ctdb: the ctdb_connection from ctdb_connect.
* @ctdb_db: the database handle from ctdb_attachdb/ctdb_attachdb_recv.
* @key: the key of the record to lock.
* @req: a pointer to the request, if one is needed.
* Do a ctdb_readrecordlock_send and wait for it to complete.
* Returns NULL on failure.
*/
- struct ctdb_lock *ctdb_readrecordlock(struct ctdb_db *ctdb_db, TDB_DATA key,
+ struct ctdb_lock *ctdb_readrecordlock(struct ctdb_connection *ctdb,
+ struct ctdb_db *ctdb_db, TDB_DATA key,
TDB_DATA *data);
* failed.
*/
bool ctdb_set_message_handler(struct ctdb_connection *ctdb, uint64_t srvid,
- ctdb_message_fn_t handler, void *cbdata);
+ ctdb_message_fn_t handler, void *cbdata);
/**
* ctdb_remove_message_handler - deregister for messages (synchronous)
* @ctdb: the ctdb_connection from ctdb_connect.
* @srvid: the 64 bit identifier for our messages.
+ * @handler: the callback when we receive such a message (typesafe)
+ * @handler_data: the argument to handler()
*
* If this returns true, the message handler will no longer be called.
* If this returns false, the deregistration failed.
*/
- bool ctdb_remove_message_handler(struct ctdb_connection *ctdb, uint64_t srvid);
+ bool ctdb_remove_message_handler(struct ctdb_connection *ctdb, uint64_t srvid,
+ ctdb_message_fn_t handler, void *handler_data);
/**
* ctdb_getpnn - read the pnn number of a node (synchronous)
typesafe_cb_preargs(void, (cb), (cbdata), \
struct ctdb_connection *, struct ctdb_request *)
+ #define ctdb_msgcb(cb, cbdata) \
+ typesafe_cb_preargs(void, (cb), (cbdata), \
+ struct ctdb_connection *, uint64_t, TDB_DATA)
+
#define ctdb_connect(addr, log, logpriv) \
ctdb_connect((addr), \
typesafe_cb_postargs(void, (log), (logpriv), \
int, const char *, va_list), \
(logpriv))
+ #define ctdb_set_message_handler(ctdb, srvid, handler, hdata) \
+ ctdb_set_message_handler((ctdb), (srvid), \
+ ctdb_msgcb((handler), (hdata)), (hdata))
+
+ #define ctdb_remove_message_handler(ctdb, srvid, handler, hdata) \
+ ctdb_remove_message_handler((ctdb), (srvid), \
+ ctdb_msgcb((handler), (hdata)), (hdata))
#define ctdb_attachdb_send(ctdb, name, persistent, tdb_flags, cb, cbdata) \
ctdb_attachdb_send((ctdb), (name), (persistent), (tdb_flags), \
struct ctdb_db *, struct ctdb_lock *, \
TDB_DATA), (cbdata))
- #define ctdb_set_message_handler_send(ctdb, srvid, handler, cb, cbdata) \
- ctdb_set_message_handler_send((ctdb), (srvid), (handler), \
- ctdb_sendcb((cb), (cbdata)), (cbdata))
+ #define ctdb_set_message_handler_send(ctdb, srvid, handler, hdata, cb, cbdata) \
+ ctdb_set_message_handler_send((ctdb), (srvid), \
+ ctdb_msgcb((handler), (hdata)), (hdata), \
+ ctdb_sendcb((cb), (cbdata)), (cbdata))
- #define ctdb_remove_message_handler_send(ctdb, srvid, cb, cbdata) \
+ #define ctdb_remove_message_handler_send(ctdb, srvid, handler, hdata, cb, cbdata) \
ctdb_remove_message_handler_send((ctdb), (srvid), \
+ ctdb_msgcb((handler), (hdata)), (hdata), \
ctdb_sendcb((cb), (cbdata)), (cbdata))
#define ctdb_getpnn_send(ctdb, destnode, cb, cbdata) \
*/
#include "includes.h"
- #include "lib/events/events.h"
+ #include "lib/tevent/tevent.h"
#include "system/time.h"
#include "system/filesys.h"
#include "system/network.h"
/* verify we can access the node */
ret = ctdb_ctrl_getpnn(ctdb, TIMELIMIT(), options.pnn);
if (ret == -1) {
- DEBUG(DEBUG_ERR,("Can not ban node. Node is not operational.\n"));
+ DEBUG(DEBUG_ERR,("Can not access node. Node is not operational.\n"));
exit(10);
}
}
}
-/*
- freeze a node
- */
-static int control_freeze(struct ctdb_context *ctdb, int argc, const char **argv)
-{
- int ret;
- uint32_t priority;
-
- if (argc == 1) {
- priority = strtol(argv[0], NULL, 0);
- } else {
- priority = 0;
- }
- DEBUG(DEBUG_ERR,("Freeze by priority %u\n", priority));
-
- ret = ctdb_ctrl_freeze_priority(ctdb, TIMELIMIT(), options.pnn, priority);
- if (ret != 0) {
- DEBUG(DEBUG_ERR, ("Unable to freeze node %u\n", options.pnn));
- }
- return 0;
-}
-
/*
thaw a node
*/
{ "showban", control_showban, true, false, "show ban information"},
{ "shutdown", control_shutdown, true, false, "shutdown ctdbd" },
{ "recover", control_recover, true, false, "force recovery" },
+ { "sync", control_ipreallocate, true, false, "wait until ctdbd has synced all state changes" },
{ "ipreallocate", control_ipreallocate, true, false, "force the recovery daemon to perform a ip reallocation procedure" },
- { "freeze", control_freeze, true, false, "freeze databases", "[priority:1-3]" },
{ "thaw", control_thaw, true, false, "thaw databases", "[priority:1-3]" },
{ "isnotrecmaster", control_isnotrecmaster, false, false, "check if the local node is recmaster or not" },
{ "killtcp", kill_tcp, false, false, "kill a tcp connection.", "<srcip:port> <dstip:port>" },
{ "getdbprio", control_getdbprio, false, false, "Get DB priority", "<dbid>"},
{ "msglisten", control_msglisten, false, false, "Listen on a srvid port for messages", "<msg srvid>"},
{ "msgsend", control_msgsend, false, false, "Send a message to srvid", "<srvid> <message>"},
+ { "sync", control_ipreallocate, true, false, "wait until ctdbd has synced all state changes" },
};
/*