1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-26 21:57:41 +03:00

ctdb-client: Add client API for new database controls

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
This commit is contained in:
Amitay Isaacs 2015-09-09 12:29:54 +10:00 committed by Amitay Isaacs
parent 81ac247c10
commit b04c48d2f5
2 changed files with 172 additions and 0 deletions

View File

@ -674,6 +674,32 @@ int ctdb_ctrl_get_nodes_file(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
int destnode, struct timeval timeout,
struct ctdb_node_map **nodemap);
int ctdb_ctrl_db_freeze(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
struct ctdb_client_context *client,
int destnode, struct timeval timeout, uint32_t db_id);
int ctdb_ctrl_db_thaw(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
struct ctdb_client_context *client,
int destnode, struct timeval timeout, uint32_t db_id);
int ctdb_ctrl_db_transaction_start(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct ctdb_client_context *client,
int destnode, struct timeval timeout,
struct ctdb_transdb *transdb);
int ctdb_ctrl_db_transaction_commit(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct ctdb_client_context *client,
int destnode, struct timeval timeout,
struct ctdb_transdb *transdb);
int ctdb_ctrl_db_transaction_cancel(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct ctdb_client_context *client,
int destnode, struct timeval timeout,
uint32_t db_id);
/* from client/client_db.c */
struct tevent_req *ctdb_attach_send(TALLOC_CTX *mem_ctx,

View File

@ -2970,3 +2970,149 @@ int ctdb_ctrl_get_nodes_file(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
return 0;
}
int ctdb_ctrl_db_freeze(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
struct ctdb_client_context *client,
int destnode, struct timeval timeout, uint32_t db_id)
{
struct ctdb_req_control request;
struct ctdb_reply_control *reply;
int ret;
ctdb_req_control_db_freeze(&request, db_id);
ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
&request, &reply);
if (ret != 0) {
DEBUG(DEBUG_ERR,
("Control DB_FREEZE failed to node %u, ret=%d\n",
destnode, ret));
return ret;
}
ret = ctdb_reply_control_db_freeze(reply);
if (ret != 0) {
DEBUG(DEBUG_ERR,
("Control DB_FREEZE failed, ret=%d\n", ret));
return ret;
}
return 0;
}
int ctdb_ctrl_db_thaw(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
struct ctdb_client_context *client,
int destnode, struct timeval timeout, uint32_t db_id)
{
struct ctdb_req_control request;
struct ctdb_reply_control *reply;
int ret;
ctdb_req_control_db_thaw(&request, db_id);
ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
&request, &reply);
if (ret != 0) {
DEBUG(DEBUG_ERR,
("Control DB_THAW failed to node %u, ret=%d\n",
destnode, ret));
return ret;
}
ret = ctdb_reply_control_db_thaw(reply);
if (ret != 0) {
DEBUG(DEBUG_ERR,
("Control DB_THAW failed, ret=%d\n", ret));
return ret;
}
return 0;
}
int ctdb_ctrl_db_transaction_start(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct ctdb_client_context *client,
int destnode, struct timeval timeout,
struct ctdb_transdb *transdb)
{
struct ctdb_req_control request;
struct ctdb_reply_control *reply;
int ret;
ctdb_req_control_db_transaction_start(&request, transdb);
ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
&request, &reply);
if (ret != 0) {
DEBUG(DEBUG_ERR,
("Control DB_TRANSACTION_START failed to node %u, ret=%d\n",
destnode, ret));
return ret;
}
ret = ctdb_reply_control_db_transaction_start(reply);
if (ret != 0) {
DEBUG(DEBUG_ERR,
("Control DB_TRANSACTION_START failed, ret=%d\n", ret));
return ret;
}
return 0;
}
int ctdb_ctrl_db_transaction_commit(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct ctdb_client_context *client,
int destnode, struct timeval timeout,
struct ctdb_transdb *transdb)
{
struct ctdb_req_control request;
struct ctdb_reply_control *reply;
int ret;
ctdb_req_control_db_transaction_commit(&request, transdb);
ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
&request, &reply);
if (ret != 0) {
DEBUG(DEBUG_ERR,
("Control DB_TRANSACTION_COMMIT failed to node %u, ret=%d\n",
destnode, ret));
return ret;
}
ret = ctdb_reply_control_db_transaction_commit(reply);
if (ret != 0) {
DEBUG(DEBUG_ERR,
("Control DB_TRANSACTION_COMMIT failed, ret=%d\n", ret));
return ret;
}
return 0;
}
int ctdb_ctrl_db_transaction_cancel(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct ctdb_client_context *client,
int destnode, struct timeval timeout,
uint32_t db_id)
{
struct ctdb_req_control request;
struct ctdb_reply_control *reply;
int ret;
ctdb_req_control_db_transaction_cancel(&request, db_id);
ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
&request, &reply);
if (ret != 0) {
DEBUG(DEBUG_ERR,
("Control DB_TRANSACTION_CANCEL failed to node %u, ret=%d\n",
destnode, ret));
return ret;
}
ret = ctdb_reply_control_db_transaction_cancel(reply);
if (ret != 0) {
DEBUG(DEBUG_ERR,
("Control DB_TRANSACTION_CANCEL failed, ret=%d\n", ret));
return ret;
}
return 0;
}