1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

added reset status control

(This used to be ctdb commit ec342b667a085a5c740fbeec8882070571071862)
This commit is contained in:
Andrew Tridgell 2007-04-28 19:13:36 +02:00
parent 1627a5d749
commit 10910f52eb
5 changed files with 84 additions and 1 deletions

View File

@ -1054,3 +1054,24 @@ uint32_t *ctdb_get_connected_nodes(struct ctdb_context *ctdb, TALLOC_CTX *mem_ct
talloc_free(map);
return nodes;
}
/*
reset remote status
*/
int ctdb_status_reset(struct ctdb_context *ctdb, uint32_t destnode)
{
int ret;
TDB_DATA data;
int32_t res;
ZERO_STRUCT(data);
ret = ctdb_control(ctdb, destnode, 0,
CTDB_CONTROL_STATUS_RESET, data,
NULL, NULL, &res);
if (ret != 0 || res != 0) {
DEBUG(0,(__location__ " ctdb_control for reset status failed\n"));
return -1;
}
return 0;
}

View File

@ -80,6 +80,12 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
return 0;
}
case CTDB_CONTROL_STATUS_RESET: {
CHECK_CONTROL_DATA_SIZE(0);
ZERO_STRUCT(ctdb->status);
return 0;
}
case CTDB_CONTROL_GETVNNMAP: {
uint32_t i, len;
CHECK_CONTROL_DATA_SIZE(0);

View File

@ -256,4 +256,6 @@ int ctdb_set_debuglevel(struct ctdb_context *ctdb, uint32_t destnode, uint32_t l
uint32_t *ctdb_get_connected_nodes(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx,
uint32_t *num_nodes);
int ctdb_status_reset(struct ctdb_context *ctdb, uint32_t destnode);
#endif

View File

@ -251,7 +251,8 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS,
CTDB_CONTROL_GET_DEBUG,
CTDB_CONTROL_SET_DEBUG,
CTDB_CONTROL_GET_DBMAP,
CTDB_CONTROL_GET_NODEMAP};
CTDB_CONTROL_GET_NODEMAP,
CTDB_CONTROL_STATUS_RESET};
enum call_state {CTDB_CALL_WAIT, CTDB_CALL_DONE, CTDB_CALL_ERROR};

View File

@ -36,6 +36,7 @@ static void usage(void)
printf(" ping\n");
printf(" process-exists <vnn:pid> see if a process exists\n");
printf(" status <vnn|all> show ctdb status on a node\n");
printf(" statusreset <vnn|all> reset status on a node\n");
printf(" debug <vnn|all> <level> set ctdb debug level on a node\n");
printf(" debuglevel display ctdb debug levels\n");
printf(" getvnnmap <vnn> display ctdb vnnmap\n");
@ -170,6 +171,56 @@ static int control_status(struct ctdb_context *ctdb, int argc, const char **argv
return 0;
}
/*
reset status on all nodes
*/
static int control_status_reset_all(struct ctdb_context *ctdb)
{
int ret, i;
uint32_t *nodes;
uint32_t num_nodes;
nodes = ctdb_get_connected_nodes(ctdb, ctdb, &num_nodes);
CTDB_NO_MEMORY(ctdb, nodes);
for (i=0;i<num_nodes;i++) {
ret = ctdb_status_reset(ctdb, nodes[i]);
if (ret != 0) {
printf("Unable to reset status on node %u\n", nodes[i]);
return ret;
}
}
talloc_free(nodes);
return 0;
}
/*
reset remote ctdb status
*/
static int control_status_reset(struct ctdb_context *ctdb, int argc, const char **argv)
{
uint32_t vnn;
int ret;
if (argc < 1) {
usage();
}
if (strcmp(argv[0], "all") == 0) {
return control_status_reset_all(ctdb);
}
vnn = strtoul(argv[0], NULL, 0);
ret = ctdb_status_reset(ctdb, vnn);
if (ret != 0) {
printf("Unable to reset status on node %u\n", vnn);
return ret;
}
return 0;
}
/*
display remote ctdb vnn map
*/
@ -441,6 +492,8 @@ int main(int argc, const char *argv[])
ret = control_process_exists(ctdb, extra_argc-1, extra_argv+1);
} else if (strcmp(control, "status") == 0) {
ret = control_status(ctdb, extra_argc-1, extra_argv+1);
} else if (strcmp(control, "statusreset") == 0) {
ret = control_status_reset(ctdb, extra_argc-1, extra_argv+1);
} else if (strcmp(control, "getvnnmap") == 0) {
ret = control_getvnnmap(ctdb, extra_argc-1, extra_argv+1);
} else if (strcmp(control, "getdbmap") == 0) {