summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRonnie Sahlberg <ronniesahlberg@gmail.com>2009-07-09 12:22:46 +1000
committerRonnie Sahlberg <ronniesahlberg@gmail.com>2009-07-09 12:22:46 +1000
commit88f3c40d9cecdfc592a9d0bd2c181fdea0c5acdf (patch)
tree67c4f1a1734147c2724c11f365a2efd57b095a8c
parent66c8d4fb3dbd68f3db4ef542bddf1062da2373e7 (diff)
add two new controls, CTOP_NODE and CONTINUE_NODE
that are used to stop/continue a node instead of using modflags messages (This used to be ctdb commit 54b4a02053a0f98f8c424e7f658890254023d39a)
-rw-r--r--ctdb/client/ctdb_client.c34
-rw-r--r--ctdb/include/ctdb.h2
-rw-r--r--ctdb/include/ctdb_private.h9
-rw-r--r--ctdb/server/ctdb_control.c8
-rw-r--r--ctdb/server/ctdb_recover.c16
-rw-r--r--ctdb/tools/ctdb.c11
6 files changed, 72 insertions, 8 deletions
diff --git a/ctdb/client/ctdb_client.c b/ctdb/client/ctdb_client.c
index 2c86b3e844..4ea8d04601 100644
--- a/ctdb/client/ctdb_client.c
+++ b/ctdb/client/ctdb_client.c
@@ -3707,3 +3707,37 @@ int ctdb_ctrl_setreclock(struct ctdb_context *ctdb, struct timeval timeout, uint
return 0;
}
+
+/*
+ stop a node
+ */
+int ctdb_ctrl_stop_node(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode)
+{
+ int ret;
+
+ ret = ctdb_control(ctdb, destnode, 0, CTDB_CONTROL_STOP_NODE, 0, tdb_null,
+ ctdb, NULL, NULL, &timeout, NULL);
+ if (ret != 0) {
+ DEBUG(DEBUG_ERR,("Failed to stop node\n"));
+ return -1;
+ }
+
+ return 0;
+}
+
+/*
+ continue a node
+ */
+int ctdb_ctrl_continue_node(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode)
+{
+ int ret;
+
+ ret = ctdb_control(ctdb, destnode, 0, CTDB_CONTROL_CONTINUE_NODE, 0, tdb_null,
+ ctdb, NULL, NULL, &timeout, NULL);
+ if (ret != 0) {
+ DEBUG(DEBUG_ERR,("Failed to continue node\n"));
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/ctdb/include/ctdb.h b/ctdb/include/ctdb.h
index c410923fa9..ebe40c302c 100644
--- a/ctdb/include/ctdb.h
+++ b/ctdb/include/ctdb.h
@@ -658,5 +658,7 @@ extern struct debug_levels debug_levels[];
const char *get_debug_by_level(int32_t level);
int32_t get_debug_by_desc(const char *desc);
+int ctdb_ctrl_stop_node(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
+int ctdb_ctrl_continue_node(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
#endif
diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h
index 055becaede..25595cffa4 100644
--- a/ctdb/include/ctdb_private.h
+++ b/ctdb/include/ctdb_private.h
@@ -199,8 +199,8 @@ struct ctdb_node {
#define NODE_FLAGS_BANNED 0x00000008 /* recovery daemon has banned the node */
#define NODE_FLAGS_DELETED 0x00000010 /* this node has been deleted */
#define NODE_FLAGS_STOPPED 0x00000020 /* this node has been stopped */
-#define NODE_FLAGS_DISABLED (NODE_FLAGS_UNHEALTHY|NODE_FLAGS_PERMANENTLY_DISABLED|NODE_FLAGS_STOPPED)
-#define NODE_FLAGS_INACTIVE (NODE_FLAGS_DELETED|NODE_FLAGS_DISCONNECTED|NODE_FLAGS_BANNED)
+#define NODE_FLAGS_DISABLED (NODE_FLAGS_UNHEALTHY|NODE_FLAGS_PERMANENTLY_DISABLED)
+#define NODE_FLAGS_INACTIVE (NODE_FLAGS_DELETED|NODE_FLAGS_DISCONNECTED|NODE_FLAGS_BANNED|NODE_FLAGS_STOPPED)
uint32_t flags;
/* used by the dead node monitoring */
@@ -571,6 +571,8 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS = 0,
CTDB_CONTROL_RECD_RECLOCK_LATENCY = 98,
CTDB_CONTROL_GET_RECLOCK_FILE = 99,
CTDB_CONTROL_SET_RECLOCK_FILE = 100,
+ CTDB_CONTROL_STOP_NODE = 101,
+ CTDB_CONTROL_CONTINUE_NODE = 102,
};
/*
@@ -1443,4 +1445,7 @@ int32_t ctdb_control_get_event_script_status(struct ctdb_context *ctdb, TDB_DATA
int ctdb_log_event_script_output(struct ctdb_context *ctdb, char *str, uint16_t len);
int ctdb_ctrl_report_recd_lock_latency(struct ctdb_context *ctdb, struct timeval timeout, double latency);
+int32_t ctdb_control_stop_node(struct ctdb_context *ctdb);
+int32_t ctdb_control_continue_node(struct ctdb_context *ctdb);
+
#endif
diff --git a/ctdb/server/ctdb_control.c b/ctdb/server/ctdb_control.c
index 8d455435fe..8faaec7a39 100644
--- a/ctdb/server/ctdb_control.c
+++ b/ctdb/server/ctdb_control.c
@@ -462,6 +462,14 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
ctdb->recovery_lock_file = talloc_strdup(ctdb, discard_const(indata.dptr));
}
return 0;
+ case CTDB_CONTROL_STOP_NODE:
+ CHECK_CONTROL_DATA_SIZE(0);
+ return ctdb_control_stop_node(ctdb);
+
+ case CTDB_CONTROL_CONTINUE_NODE:
+ CHECK_CONTROL_DATA_SIZE(0);
+ return ctdb_control_continue_node(ctdb);
+
default:
DEBUG(DEBUG_CRIT,(__location__ " Unknown CTDB control opcode %u\n", opcode));
return -1;
diff --git a/ctdb/server/ctdb_recover.c b/ctdb/server/ctdb_recover.c
index 16545e7c43..97602b9d3d 100644
--- a/ctdb/server/ctdb_recover.c
+++ b/ctdb/server/ctdb_recover.c
@@ -1155,3 +1155,19 @@ int32_t ctdb_control_set_recmaster(struct ctdb_context *ctdb, uint32_t opcode, T
ctdb->recovery_master = ((uint32_t *)(&indata.dptr[0]))[0];
return 0;
}
+
+int32_t ctdb_control_stop_node(struct ctdb_context *ctdb)
+{
+ DEBUG(DEBUG_ERR,(__location__ " Stopping node\n"));
+ ctdb->nodes[ctdb->pnn]->flags |= NODE_FLAGS_STOPPED;
+
+ return 0;
+}
+
+int32_t ctdb_control_continue_node(struct ctdb_context *ctdb)
+{
+ DEBUG(DEBUG_ERR,(__location__ " Continue node\n"));
+ ctdb->nodes[ctdb->pnn]->flags &= ~NODE_FLAGS_STOPPED;
+
+ return 0;
+}
diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c
index e19c20ea9a..12fbe488d6 100644
--- a/ctdb/tools/ctdb.c
+++ b/ctdb/tools/ctdb.c
@@ -1537,7 +1537,6 @@ static int control_getpid(struct ctdb_context *ctdb, int argc, const char **argv
static void ip_reallocate_handler(struct ctdb_context *ctdb, uint64_t srvid,
TDB_DATA data, void *private_data)
{
- printf("IP Reallocation completed\n");
exit(0);
}
@@ -1663,12 +1662,12 @@ static int control_stop(struct ctdb_context *ctdb, int argc, const char **argv)
struct ctdb_node_map *nodemap=NULL;
do {
- ret = ctdb_ctrl_modflags(ctdb, TIMELIMIT(), options.pnn, NODE_FLAGS_STOPPED, 0);
+ ret = ctdb_ctrl_stop_node(ctdb, TIMELIMIT(), options.pnn);
if (ret != 0) {
DEBUG(DEBUG_ERR, ("Unable to stop node %u\n", options.pnn));
return ret;
}
-
+
sleep(1);
/* read the nodemap and verify the change took effect */
@@ -1697,12 +1696,12 @@ static int control_continue(struct ctdb_context *ctdb, int argc, const char **ar
struct ctdb_node_map *nodemap=NULL;
do {
- ret = ctdb_ctrl_modflags(ctdb, TIMELIMIT(), options.pnn, 0, NODE_FLAGS_STOPPED);
+ ret = ctdb_ctrl_continue_node(ctdb, TIMELIMIT(), options.pnn);
if (ret != 0) {
- DEBUG(DEBUG_ERR, ("Unable to restart node %u\n", options.pnn));
+ DEBUG(DEBUG_ERR, ("Unable to continue node %u\n", options.pnn));
return ret;
}
-
+
sleep(1);
/* read the nodemap and verify the change took effect */