mirror of
https://github.com/samba-team/samba.git
synced 2025-01-24 02:04:21 +03:00
add controls to enable/disable the monitoring of dead nodes
(This used to be ctdb commit 79d29c39bb81feb069db3fc6d3d392c1e75a4d13)
This commit is contained in:
parent
7c6bc59ae4
commit
e989a1bac8
@ -1722,3 +1722,50 @@ int ctdb_ctrl_thaw(struct ctdb_context *ctdb, struct timeval timeout, uint32_t d
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
set the monitoring mode of a remote node
|
||||
*/
|
||||
int ctdb_ctrl_setmonmode(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t monmode)
|
||||
{
|
||||
int ret;
|
||||
TDB_DATA data, outdata;
|
||||
int32_t res;
|
||||
|
||||
data.dsize = sizeof(uint32_t);
|
||||
data.dptr = (unsigned char *)&monmode;
|
||||
|
||||
ret = ctdb_control(ctdb, destnode, 0,
|
||||
CTDB_CONTROL_SET_MONMODE, 0, data,
|
||||
ctdb, &outdata, &res, &timeout, NULL);
|
||||
if (ret != 0 || res != 0) {
|
||||
DEBUG(0,(__location__ " ctdb_control for setmonmode failed\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
get the monitoring mode of a remote node
|
||||
*/
|
||||
int ctdb_ctrl_getmonmode(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t *monmode)
|
||||
{
|
||||
int ret;
|
||||
TDB_DATA data, outdata;
|
||||
int32_t res;
|
||||
|
||||
ZERO_STRUCT(data);
|
||||
ret = ctdb_control(ctdb, destnode, 0,
|
||||
CTDB_CONTROL_GET_MONMODE, 0, data,
|
||||
ctdb, &outdata, &res, &timeout, NULL);
|
||||
if (ret != 0) {
|
||||
DEBUG(0,(__location__ " ctdb_control for getrecmode failed\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
*monmode = res;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -241,6 +241,14 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
|
||||
CHECK_CONTROL_DATA_SIZE(sizeof(uint32_t));
|
||||
return ctdb_control_set_recmode(ctdb, indata, errormsg);
|
||||
|
||||
case CTDB_CONTROL_SET_MONMODE:
|
||||
CHECK_CONTROL_DATA_SIZE(sizeof(uint32_t));
|
||||
ctdb->monitoring_mode = *(uint32_t *)indata.dptr;
|
||||
return 0;
|
||||
|
||||
case CTDB_CONTROL_GET_MONMODE:
|
||||
return ctdb->monitoring_mode;
|
||||
|
||||
case CTDB_CONTROL_SHUTDOWN:
|
||||
exit(10);
|
||||
|
||||
|
@ -34,6 +34,13 @@ static void ctdb_check_for_dead_nodes(struct event_context *ev, struct timed_eve
|
||||
struct ctdb_context *ctdb = talloc_get_type(private_data, struct ctdb_context);
|
||||
int i;
|
||||
|
||||
if (ctdb->monitoring_mode==CTDB_MONITORING_DISABLED) {
|
||||
event_add_timed(ctdb->ev, ctdb,
|
||||
timeval_current_ofs(CTDB_MONITORING_TIMEOUT, 0),
|
||||
ctdb_check_for_dead_nodes, ctdb);
|
||||
return;
|
||||
}
|
||||
|
||||
/* send a keepalive to all other nodes, unless */
|
||||
for (i=0;i<ctdb->num_nodes;i++) {
|
||||
struct ctdb_node *node = ctdb->nodes[i];
|
||||
|
@ -299,6 +299,14 @@ int ctdb_ctrl_getrecmode(struct ctdb_context *ctdb, struct timeval timeout, uint
|
||||
set the recovery mode of a remote node
|
||||
*/
|
||||
int ctdb_ctrl_setrecmode(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t recmode);
|
||||
/*
|
||||
get the monitoring mode of a remote node
|
||||
*/
|
||||
int ctdb_ctrl_getmonmode(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t *monmode);
|
||||
/*
|
||||
set the monitoringmode of a remote node
|
||||
*/
|
||||
int ctdb_ctrl_setmonmode(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t monmode);
|
||||
|
||||
/*
|
||||
get the recovery master of a remote node
|
||||
|
@ -234,10 +234,14 @@ struct ctdb_write_record {
|
||||
|
||||
enum ctdb_freeze_mode {CTDB_FREEZE_NONE, CTDB_FREEZE_PENDING, CTDB_FREEZE_FROZEN};
|
||||
|
||||
#define CTDB_MONITORING_ACTIVE 0
|
||||
#define CTDB_MONITORING_DISABLED 1
|
||||
|
||||
/* main state of the ctdb daemon */
|
||||
struct ctdb_context {
|
||||
struct event_context *ev;
|
||||
uint32_t recovery_mode;
|
||||
uint32_t monitoring_mode;
|
||||
enum ctdb_freeze_mode freeze_mode;
|
||||
struct ctdb_freeze_handle *freeze_handle;
|
||||
struct ctdb_address address;
|
||||
@ -367,6 +371,8 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS,
|
||||
CTDB_CONTROL_THAW,
|
||||
CTDB_CONTROL_GET_VNN,
|
||||
CTDB_CONTROL_SHUTDOWN,
|
||||
CTDB_CONTROL_GET_MONMODE,
|
||||
CTDB_CONTROL_SET_MONMODE,
|
||||
};
|
||||
|
||||
|
||||
|
@ -55,6 +55,8 @@ static void usage(void)
|
||||
" setrecmode <vnn> <mode> set recovery mode\n"
|
||||
" getrecmaster <vnn> get recovery master\n"
|
||||
" setrecmaster <vnn> <master_vnn> set recovery master\n"
|
||||
" getmonmode <vnn> get monitoring mode\n"
|
||||
" setmonmode <vnn> <mode> set monitoring mode\n"
|
||||
" attach <dbname> attach a database\n"
|
||||
" getpid <vnn> get the pid of a ctdb daemon\n"
|
||||
" shutdown <vnn> shutdown a remote ctdb\n"
|
||||
@ -420,6 +422,56 @@ static int control_setrecmode(struct ctdb_context *ctdb, int argc, const char **
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
display monitoring mode of a remote node
|
||||
*/
|
||||
static int control_getmonmode(struct ctdb_context *ctdb, int argc, const char **argv)
|
||||
{
|
||||
uint32_t vnn, monmode;
|
||||
int ret;
|
||||
|
||||
|
||||
if (argc < 1) {
|
||||
usage();
|
||||
}
|
||||
|
||||
vnn = strtoul(argv[0], NULL, 0);
|
||||
|
||||
ret = ctdb_ctrl_getmonmode(ctdb, timeval_current_ofs(timelimit, 0), vnn, &monmode);
|
||||
if (ret != 0) {
|
||||
printf("Unable to get monmode from node %u\n", vnn);
|
||||
return ret;
|
||||
}
|
||||
printf("Monitoring mode:%s (%d)\n",monmode==CTDB_MONITORING_ACTIVE?"ACTIVE":"DISABLED",monmode);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
set the monitoring mode of a remote node
|
||||
*/
|
||||
static int control_setmonmode(struct ctdb_context *ctdb, int argc, const char **argv)
|
||||
{
|
||||
uint32_t vnn, monmode;
|
||||
int ret;
|
||||
|
||||
|
||||
if (argc < 2) {
|
||||
usage();
|
||||
}
|
||||
|
||||
vnn = strtoul(argv[0], NULL, 0);
|
||||
monmode = strtoul(argv[1], NULL, 0);
|
||||
|
||||
ret = ctdb_ctrl_setmonmode(ctdb, timeval_current_ofs(timelimit, 0), vnn, monmode);
|
||||
if (ret != 0) {
|
||||
printf("Unable to set monmode on node %u\n", vnn);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
display recovery master of a remote node
|
||||
*/
|
||||
@ -994,6 +1046,8 @@ int main(int argc, const char *argv[])
|
||||
{ "setrecmode", control_setrecmode },
|
||||
{ "getrecmaster", control_getrecmaster },
|
||||
{ "setrecmaster", control_setrecmaster },
|
||||
{ "getmonmode", control_getmonmode },
|
||||
{ "setmonmode", control_setmonmode },
|
||||
{ "ping", control_ping },
|
||||
{ "debug", control_debug },
|
||||
{ "debuglevel", control_debuglevel },
|
||||
|
Loading…
x
Reference in New Issue
Block a user