mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
ctdb-tests: Add monitoring related controls in fake_ctdbd
Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
This commit is contained in:
parent
7303d7ba86
commit
87bf2424eb
@ -99,6 +99,7 @@ struct ctdbd_context {
|
||||
enum debug_level log_level;
|
||||
enum ctdb_runstate runstate;
|
||||
struct ctdb_tunable_list tun_list;
|
||||
int monitoring_mode;
|
||||
};
|
||||
|
||||
/*
|
||||
@ -611,6 +612,8 @@ static struct ctdbd_context *ctdbd_setup(TALLOC_CTX *mem_ctx)
|
||||
|
||||
ctdb_tunable_set_defaults(&ctdb->tun_list);
|
||||
|
||||
ctdb->monitoring_mode = CTDB_MONITORING_ACTIVE;
|
||||
|
||||
return ctdb;
|
||||
|
||||
fail:
|
||||
@ -1271,6 +1274,23 @@ static void control_shutdown(TALLOC_CTX *mem_ctx,
|
||||
state->status = 99;
|
||||
}
|
||||
|
||||
static void control_get_monmode(TALLOC_CTX *mem_ctx,
|
||||
struct tevent_req *req,
|
||||
struct ctdb_req_header *header,
|
||||
struct ctdb_req_control *request)
|
||||
{
|
||||
struct client_state *state = tevent_req_data(
|
||||
req, struct client_state);
|
||||
struct ctdbd_context *ctdb = state->ctdb;
|
||||
struct ctdb_reply_control reply;
|
||||
|
||||
reply.rdata.opcode = request->opcode;
|
||||
reply.status = ctdb->monitoring_mode;
|
||||
reply.errmsg = NULL;
|
||||
|
||||
client_send_control(req, header, &reply);
|
||||
}
|
||||
|
||||
static void control_set_tunable(TALLOC_CTX *mem_ctx,
|
||||
struct tevent_req *req,
|
||||
struct ctdb_req_header *header,
|
||||
@ -1402,6 +1422,42 @@ fail:
|
||||
client_send_control(req, header, &reply);
|
||||
}
|
||||
|
||||
static void control_enable_monitor(TALLOC_CTX *mem_ctx,
|
||||
struct tevent_req *req,
|
||||
struct ctdb_req_header *header,
|
||||
struct ctdb_req_control *request)
|
||||
{
|
||||
struct client_state *state = tevent_req_data(
|
||||
req, struct client_state);
|
||||
struct ctdbd_context *ctdb = state->ctdb;
|
||||
struct ctdb_reply_control reply;
|
||||
|
||||
ctdb->monitoring_mode = CTDB_MONITORING_ACTIVE;
|
||||
|
||||
reply.rdata.opcode = request->opcode;
|
||||
reply.status = 0;
|
||||
reply.errmsg = NULL;
|
||||
client_send_control(req, header, &reply);
|
||||
}
|
||||
|
||||
static void control_disable_monitor(TALLOC_CTX *mem_ctx,
|
||||
struct tevent_req *req,
|
||||
struct ctdb_req_header *header,
|
||||
struct ctdb_req_control *request)
|
||||
{
|
||||
struct client_state *state = tevent_req_data(
|
||||
req, struct client_state);
|
||||
struct ctdbd_context *ctdb = state->ctdb;
|
||||
struct ctdb_reply_control reply;
|
||||
|
||||
ctdb->monitoring_mode = CTDB_MONITORING_DISABLED;
|
||||
|
||||
reply.rdata.opcode = request->opcode;
|
||||
reply.status = 0;
|
||||
reply.errmsg = NULL;
|
||||
client_send_control(req, header, &reply);
|
||||
}
|
||||
|
||||
static void control_reload_nodes_file(TALLOC_CTX *mem_ctx,
|
||||
struct tevent_req *req,
|
||||
struct ctdb_req_header *header,
|
||||
@ -2101,6 +2157,10 @@ static void client_process_control(struct tevent_req *req,
|
||||
control_shutdown(mem_ctx, req, &header, &request);
|
||||
break;
|
||||
|
||||
case CTDB_CONTROL_GET_MONMODE:
|
||||
control_get_monmode(mem_ctx, req, &header, &request);
|
||||
break;
|
||||
|
||||
case CTDB_CONTROL_SET_TUNABLE:
|
||||
control_set_tunable(mem_ctx, req, &header, &request);
|
||||
break;
|
||||
@ -2121,6 +2181,14 @@ static void client_process_control(struct tevent_req *req,
|
||||
control_uptime(mem_ctx, req, &header, &request);
|
||||
break;
|
||||
|
||||
case CTDB_CONTROL_ENABLE_MONITOR:
|
||||
control_enable_monitor(mem_ctx, req, &header, &request);
|
||||
break;
|
||||
|
||||
case CTDB_CONTROL_DISABLE_MONITOR:
|
||||
control_disable_monitor(mem_ctx, req, &header, &request);
|
||||
break;
|
||||
|
||||
case CTDB_CONTROL_RELOAD_NODES_FILE:
|
||||
control_reload_nodes_file(mem_ctx, req, &header, &request);
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user