add a control to read the current reclock file from a node
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Thu, 25 Jun 2009 02:17:19 +0000 (12:17 +1000)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Thu, 25 Jun 2009 02:17:19 +0000 (12:17 +1000)
client/ctdb_client.c
include/ctdb_private.h
server/ctdb_control.c
tools/ctdb.c

index 9d7ef84ba6bf52587de11a1694de13d23ec32cef..095e528d1279312414e67b6df760fb9dbef332ab 100644 (file)
@@ -3651,3 +3651,26 @@ int ctdb_ctrl_report_recd_lock_latency(struct ctdb_context *ctdb, struct timeval
 
        return 0;
 }
+
+/*
+  get the name of the reclock file
+ */
+int ctdb_ctrl_getreclock(struct ctdb_context *ctdb, struct timeval timeout,
+                        uint32_t destnode, TALLOC_CTX *mem_ctx,
+                        const char **name)
+{
+       int ret;
+       int32_t res;
+       TDB_DATA data;
+
+       ret = ctdb_control(ctdb, destnode, 0, 
+                          CTDB_CONTROL_GET_RECLOCK_FILE, 0, tdb_null, 
+                          mem_ctx, &data, &res, &timeout, NULL);
+       if (ret != 0 || res != 0) {
+               return -1;
+       }
+
+       *name = discard_const(data.dptr);
+
+       return 0;
+}
index 98dab0785dbab185b2b74f24d0d0e17f07e5918f..0502d9e35d4e82d96fef7e07e4665f5be06e392e 100644 (file)
@@ -567,6 +567,7 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS          = 0,
                    CTDB_CONTROL_GET_EVENT_SCRIPT_STATUS = 96,
                    CTDB_CONTROL_TRAVERSE_KILL           = 97,
                    CTDB_CONTROL_RECD_RECLOCK_LATENCY    = 98,
+                   CTDB_CONTROL_GET_RECLOCK_FILE        = 99,
 };     
 
 /*
index 72e60c526b9b662e298f0b233c9a6b95aa2b487a..141622025b4d077f17996d87ab0aae267508b1da 100644 (file)
@@ -445,6 +445,13 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
                CHECK_CONTROL_DATA_SIZE(sizeof(double));
                ctdb_reclock_latency(ctdb, "recd reclock", &ctdb->statistics.reclock.recd, *((double *)indata.dptr));
                return 0;
+       case CTDB_CONTROL_GET_RECLOCK_FILE:
+               CHECK_CONTROL_DATA_SIZE(0);
+               if (ctdb->recovery_lock_file != NULL) {
+                       outdata->dptr  = discard_const(ctdb->recovery_lock_file);
+                       outdata->dsize = strlen(ctdb->recovery_lock_file) + 1;
+               }
+               return 0;
        default:
                DEBUG(DEBUG_CRIT,(__location__ " Unknown CTDB control opcode %u\n", opcode));
                return -1;
index 589533b6d006bfd60b9cc6627dee4963260fed14..6c8a941d73ca03f5ac6b46dc2361cd5b8ae5d5ed 100644 (file)
@@ -2248,6 +2248,27 @@ static int control_getdebug(struct ctdb_context *ctdb, int argc, const char **ar
        return 0;
 }
 
+/*
+  display reclock file of a node
+ */
+static int control_getreclock(struct ctdb_context *ctdb, int argc, const char **argv)
+{
+       int ret;
+       const char *reclock;
+
+       ret = ctdb_ctrl_getreclock(ctdb, TIMELIMIT(), options.pnn, ctdb, &reclock);
+       if (ret != 0) {
+               DEBUG(DEBUG_ERR, ("Unable to get reclock file from node %u\n", options.pnn));
+               return ret;
+       } else {
+               if (reclock == NULL) {
+                       printf("No reclock file used.\n");
+               } else {
+                       printf("Reclock file:%s\n", reclock);
+               }
+       }
+       return 0;
+}
 
 /*
   set debug level on a node or all nodes
@@ -2991,6 +3012,7 @@ static const struct {
        { "scriptstatus",        control_scriptstatus,  false,  false, "show the status of the monitoring scripts"},
        { "natgwlist",        control_natgwlist,        false,  false, "show the nodes belonging to this natgw configuration"},
        { "xpnn",             control_xpnn,             true,   true,  "find the pnn of the local node without talking to the daemon (unreliable)" },
+       { "getreclock",       control_getreclock,       false,  false, "Show the reclock file of a node"},
 };
 
 /*