Rev 309: merge shutdown control from ronnie in http://samba.org/~tridge/ctdb

tridge at samba.org tridge at samba.org
Thu May 17 00:48:45 GMT 2007


------------------------------------------------------------
revno: 309
revision-id: tridge at samba.org-20070517004843-ti0e0t7536ss7639
parent: tridge at samba.org-20070516081026-l0m82yuabzu91dlr
parent: sahlberg at ronnie-20070517004531-ttyt43eorz178m4p
committer: Andrew Tridgell <tridge at samba.org>
branch nick: tridge
timestamp: Thu 2007-05-17 10:48:43 +1000
message:
  merge shutdown control from ronnie
modified:
  common/ctdb_client.c           ctdb_client.c-20070411010216-3kd8v37k61steeya-1
  common/ctdb_control.c          ctdb_control.c-20070426122724-j6gkpiofhbwdin63-1
  include/ctdb.h                 ctdb.h-20061117234101-o3qt14umlg9en8z0-11
  include/ctdb_private.h         ctdb_private.h-20061117234101-o3qt14umlg9en8z0-13
  tools/ctdb_control.c           ctdb_control.c-20070426122705-9ehj1l5lu2gn9kuj-1
    ------------------------------------------------------------
    revno: 197.1.115
    merged: sahlberg at ronnie-20070517004531-ttyt43eorz178m4p
    parent: sahlberg at ronnie-20070516084451-3p2fffgok3kqbt12
    committer: Ronnie Sahlberg <sahlberg at ronnie>
    branch nick: ctdb
    timestamp: Thu 2007-05-17 10:45:31 +1000
    message:
      add a control to shutdown/kill a node
    ------------------------------------------------------------
    revno: 197.1.114
    merged: sahlberg at ronnie-20070516084451-3p2fffgok3kqbt12
    parent: sahlberg at ronnie-20070516044543-ognbrw9p5bez3q4a
    parent: tridge at samba.org-20070516081026-l0m82yuabzu91dlr
    committer: Ronnie Sahlberg <sahlberg at ronnie>
    branch nick: ctdb
    timestamp: Wed 2007-05-16 18:44:51 +1000
    message:
      merge from tridge
    ------------------------------------------------------------
    revno: 197.1.113
    merged: sahlberg at ronnie-20070516044543-ognbrw9p5bez3q4a
    parent: sahlberg at ronnie-20070516023430-nle4lyaap7006te6
    committer: Ronnie Sahlberg <sahlberg at ronnie>
    branch nick: ctdb
    timestamp: Wed 2007-05-16 14:45:43 +1000
    message:
      remove a prototype we no longer need
=== modified file 'common/ctdb_client.c'
--- a/common/ctdb_client.c	2007-05-16 08:10:26 +0000
+++ b/common/ctdb_client.c	2007-05-17 00:45:31 +0000
@@ -840,6 +840,27 @@
 }
 
 /*
+  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
  */
 int ctdb_ctrl_getvnnmap(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, TALLOC_CTX *mem_ctx, struct ctdb_vnn_map **vnnmap)

=== modified file 'common/ctdb_control.c'
--- a/common/ctdb_control.c	2007-05-16 02:34:30 +0000
+++ b/common/ctdb_control.c	2007-05-17 00:45:31 +0000
@@ -240,6 +240,9 @@
 		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;

=== modified file 'include/ctdb.h'
--- a/include/ctdb.h	2007-05-16 01:12:28 +0000
+++ b/include/ctdb.h	2007-05-17 00:45:31 +0000
@@ -203,6 +203,8 @@
 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, 
@@ -277,11 +279,6 @@
 int ctdb_ctrl_cleardb(struct ctdb_context *ctdb, uint32_t destnode, TALLOC_CTX *mem_ctx, uint32_t dbid);
 
 /*
-  bump the rsn number for al records
- */
-int ctdb_ctrl_bumprsn(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, TALLOC_CTX *mem_ctx, uint32_t dbid);
-
-/*
   write a record on a specific db (this implicitely updates dmaster of the record to locally be the vnn of the node where the control is executed on)
  */
 int ctdb_ctrl_write_record(struct ctdb_context *ctdb, uint32_t destnode, TALLOC_CTX *mem_ctx, uint32_t dbid, TDB_DATA key, TDB_DATA data);

=== modified file 'include/ctdb_private.h'
--- a/include/ctdb_private.h	2007-05-16 08:10:26 +0000
+++ b/include/ctdb_private.h	2007-05-17 00:45:31 +0000
@@ -353,6 +353,7 @@
 		    CTDB_CONTROL_FREEZE,
 		    CTDB_CONTROL_THAW,
 		    CTDB_CONTROL_GET_VNN,
+		    CTDB_CONTROL_SHUTDOWN,
 };
 
 

=== modified file 'tools/ctdb_control.c'
--- a/tools/ctdb_control.c	2007-05-12 11:25:26 +0000
+++ b/tools/ctdb_control.c	2007-05-17 00:45:31 +0000
@@ -57,6 +57,7 @@
 		"  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"
 	);
@@ -344,6 +345,30 @@
 }
 
 /*
+  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
  */
 static int control_getrecmode(struct ctdb_context *ctdb, int argc, const char **argv)
@@ -973,6 +998,7 @@
 		{ "attach", control_attach },
 		{ "dumpmemory", control_dumpmemory },
 		{ "getpid", control_getpid },
+		{ "shutdown", control_shutdown },
 		{ "freeze", control_freeze },
 		{ "thaw", control_thaw },
 	};



More information about the samba-cvs mailing list