return 0;
}
+/*
+ shutdown a remote ctdb node
+ */
+int ctdb_ctrl_shutdown(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode)
+{
+ int ret;
+ TDB_DATA data;
+ int32_t res;
+
+ ZERO_STRUCT(data);
+ ret = ctdb_control(ctdb, destnode, 0,
+ CTDB_CONTROL_SHUTDOWN, CTDB_CTRL_FLAG_NOREPLY, data,
+ ctdb, &data, &res, &timeout, NULL);
+ if (ret != 0) {
+ DEBUG(0,(__location__ " ctdb_control for shutdown failed\n"));
+ return -1;
+ }
+
+ return 0;
+}
+
/*
get vnn map from a remote node
*/
CHECK_CONTROL_DATA_SIZE(sizeof(uint32_t));
return ctdb_control_set_recmode(ctdb, indata, errormsg);
+ case CTDB_CONTROL_SHUTDOWN:
+ exit(10);
+
default:
DEBUG(0,(__location__ " Unknown CTDB control opcode %u\n", opcode));
return -1;
struct ctdb_status;
int ctdb_ctrl_status(struct ctdb_context *ctdb, uint32_t destnode, struct ctdb_status *status);
+int ctdb_ctrl_shutdown(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
+
struct ctdb_vnn_map;
int ctdb_ctrl_getvnnmap(struct ctdb_context *ctdb,
struct timeval timeout, uint32_t destnode,
" setrecmaster <vnn> <master_vnn> set recovery master\n"
" attach <dbname> attach a database\n"
" getpid <vnn> get the pid of a ctdb daemon\n"
+ " shutdown <vnn> shutdown a remote ctdb\n"
" freeze <vnn|all> freeze a node\n"
" thaw <vnn|all> thaw a node\n"
);
return 0;
}
+/*
+ shutdown a daemon
+ */
+static int control_shutdown(struct ctdb_context *ctdb, int argc, const char **argv)
+{
+ uint32_t vnn;
+ int ret;
+
+
+ if (argc < 1) {
+ usage();
+ }
+
+ vnn = strtoul(argv[0], NULL, 0);
+
+ ret = ctdb_ctrl_shutdown(ctdb, timeval_current_ofs(1, 0), vnn);
+ if (ret != 0) {
+ printf("Unable to shutdown node %u\n", vnn);
+ return ret;
+ }
+
+ return 0;
+}
+
/*
display recovery mode of a remote node
*/
{ "attach", control_attach },
{ "dumpmemory", control_dumpmemory },
{ "getpid", control_getpid },
+ { "shutdown", control_shutdown },
{ "freeze", control_freeze },
{ "thaw", control_thaw },
};