add two new controls, CTOP_NODE and CONTINUE_NODE
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Thu, 9 Jul 2009 02:22:46 +0000 (12:22 +1000)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Thu, 9 Jul 2009 02:22:46 +0000 (12:22 +1000)
that are used to stop/continue a node instead of using modflags messages

client/ctdb_client.c
include/ctdb.h
include/ctdb_private.h
server/ctdb_control.c
server/ctdb_recover.c
tools/ctdb.c

index 2c86b3e8441a2a6be49373a2da07a33691fe231b..4ea8d04601a724165edc21fe9599700cbda1dbd8 100644 (file)
@@ -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;
+}
index c410923fa946c0b7caec052c70e2abd6768144d8..ebe40c302c9e96b391ee25319fecb88a112655f5 100644 (file)
@@ -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
index 055becaede604b84679b2eb236c7c83f892bb0e3..25595cffa4646dfce194881a7c5d70e1557cd4c0 100644 (file)
@@ -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
index 8d455435fe9681dd56d3e8f735190ca3a80ed5a6..8faaec7a393d3df943e05be2924996458c6cba9b 100644 (file)
@@ -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;
index 16545e7c43a88b7b3cd44d28e75ea2e66ee3155b..97602b9d3d061b5d1d439e7b4bd9c11b294ac890 100644 (file)
@@ -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;
+}
index e19c20ea9a572f75f1914d7464c2fd544488574c..12fbe488d6e2ea6169838e1553bd492c6b1a4457 100644 (file)
@@ -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 */