]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
make recovery daemon values tunable
authorAndrew Tridgell <tridge@samba.org>
Mon, 4 Jun 2007 10:22:44 +0000 (20:22 +1000)
committerAndrew Tridgell <tridge@samba.org>
Mon, 4 Jun 2007 10:22:44 +0000 (20:22 +1000)
(This used to be ctdb commit ec29dbf2f5110428df8b97801443ba7addf61353)

ctdb/common/ctdb.c
ctdb/common/ctdb_recoverd.c
ctdb/common/ctdb_tunables.c
ctdb/include/ctdb_private.h

index 8fafc45369bc703b4f88f346ca30c08f5b2b1dd6..3fc2d7d53da8247673862cfeada29ea299ff9ba9 100644 (file)
@@ -523,14 +523,7 @@ struct ctdb_context *ctdb_init(struct event_context *ev)
        ctdb->recovery_lock_fd = -1;
        ctdb->monitoring_mode  = CTDB_MONITORING_ACTIVE;
 
-       /* set default values for tunables */
-       ctdb->tunable.max_redirect_count = 3;
-       ctdb->tunable.seqnum_frequency   = 1;
-       ctdb->tunable.control_timeout    = 60;
-       ctdb->tunable.traverse_timeout   = 20;
-       ctdb->tunable.monitoring_timeout = 2;
-       ctdb->tunable.monitoring_limit   = 3;
-       ctdb->tunable.max_lacount        = 7;
+       ctdb_tunables_set_defaults(ctdb);
 
        return ctdb;
 }
index 70b980ca0635c75fd35f54626c40b6bacd0b4098..a2d845de63d6a4fc389876f1d6518c1454885efc 100644 (file)
@@ -35,8 +35,8 @@ static void timeout_func(struct event_context *ev, struct timed_event *te,
        timed_out = 1;
 }
 
-#define CONTROL_TIMEOUT() timeval_current_ofs(5, 0)
-#define MONITOR_TIMEOUT() timeval_current_ofs(1, 0)
+#define CONTROL_TIMEOUT() timeval_current_ofs(ctdb->tunable.recover_timeout, 0)
+#define MONITOR_TIMEOUT() timeval_current_ofs(ctdb->tunable.monitor_frequency, 0)
 
 static int set_recovery_mode(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap, uint32_t rec_mode)
 {
@@ -50,7 +50,7 @@ static int set_recovery_mode(struct ctdb_context *ctdb, struct ctdb_node_map *no
                }
 
                if (rec_mode == CTDB_RECOVERY_ACTIVE) {
-                       ret = ctdb_ctrl_freeze(ctdb, timeval_current_ofs(5, 0), nodemap->nodes[j].vnn);
+                       ret = ctdb_ctrl_freeze(ctdb, CONTROL_TIMEOUT(), nodemap->nodes[j].vnn);
                        if (ret != 0) {
                                DEBUG(0, (__location__ " Unable to freeze node %u\n", nodemap->nodes[j].vnn));
                                return -1;
@@ -64,7 +64,7 @@ static int set_recovery_mode(struct ctdb_context *ctdb, struct ctdb_node_map *no
                }
 
                if (rec_mode == CTDB_RECOVERY_NORMAL) {
-                       ret = ctdb_ctrl_thaw(ctdb, timeval_current_ofs(5, 0), nodemap->nodes[j].vnn);
+                       ret = ctdb_ctrl_thaw(ctdb, CONTROL_TIMEOUT(), nodemap->nodes[j].vnn);
                        if (ret != 0) {
                                DEBUG(0, (__location__ " Unable to thaw node %u\n", nodemap->nodes[j].vnn));
                                return -1;
@@ -652,14 +652,16 @@ static void force_election(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, uint3
 
        /* wait for a few seconds to collect all responses */
        timed_out = 0;
-       event_add_timed(ctdb->ev, mem_ctx, timeval_current_ofs(3, 0), 
+       event_add_timed(ctdb->ev, mem_ctx, timeval_current_ofs(ctdb->tunable.election_timeout, 0),
                        timeout_func, ctdb);
        while (!timed_out) {
                event_loop_once(ctdb->ev);
        }
 }
 
-
+/*
+  the main monitoring loop
+ */
 void monitor_cluster(struct ctdb_context *ctdb)
 {
        uint32_t vnn, num_active, recmode, recmaster;
@@ -688,6 +690,14 @@ again:
                event_loop_once(ctdb->ev);
        }
 
+       /* get relevant tunables */
+       ctdb_ctrl_get_tunable(ctdb, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE, 
+                             "RecoverTimeout", &ctdb->tunable.recover_timeout);
+       ctdb_ctrl_get_tunable(ctdb, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE, 
+                             "MonitorFrequency", &ctdb->tunable.monitor_frequency);
+       ctdb_ctrl_get_tunable(ctdb, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE, 
+                             "ElectionTimeout", &ctdb->tunable.election_timeout);
+
        vnn = ctdb_ctrl_getvnn(ctdb, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE);
        if (vnn == (uint32_t)-1) {
                DEBUG(0,("Failed to get local vnn - retrying\n"));
index 912d12a4a441e6a4717f2983e71cb3c7b17d12b5..85794432b300c5e43963ea696873dc6dfaf8091a 100644 (file)
 
 static const struct {
        const char *name;
-       size_t offset;
+       uint32_t default_v;
+       size_t offset;  
 } tunable_map[] = {
-       { "MaxRedirectCount",  offsetof(struct ctdb_tunable, max_redirect_count) },
-       { "SeqnumFrequency",   offsetof(struct ctdb_tunable, seqnum_frequency) },
-       { "ControlTimeout",    offsetof(struct ctdb_tunable, control_timeout) },
-       { "TraverseTimeout",   offsetof(struct ctdb_tunable, traverse_timeout) },
-       { "MonitoringTimeout", offsetof(struct ctdb_tunable, monitoring_timeout) },
-       { "MonitoringLimit",   offsetof(struct ctdb_tunable, monitoring_limit) },
-       { "MaxLACount",        offsetof(struct ctdb_tunable, max_lacount) },
+       { "MaxRedirectCount",  3,  offsetof(struct ctdb_tunable, max_redirect_count) },
+       { "SeqnumFrequency",   1,  offsetof(struct ctdb_tunable, seqnum_frequency) },
+       { "ControlTimeout",    60, offsetof(struct ctdb_tunable, control_timeout) },
+       { "TraverseTimeout",   20, offsetof(struct ctdb_tunable, traverse_timeout) },
+       { "MonitoringTimeout", 2,  offsetof(struct ctdb_tunable, monitoring_timeout) },
+       { "MonitoringLimit",   3,  offsetof(struct ctdb_tunable, monitoring_limit) },
+       { "MaxLACount",        7,  offsetof(struct ctdb_tunable, max_lacount) },
+       { "RecoverTimeout",    5,  offsetof(struct ctdb_tunable, recover_timeout) },
+       { "MonitorFrequency",  1,  offsetof(struct ctdb_tunable, monitor_frequency) },
+       { "ElectionTimeout",   3,  offsetof(struct ctdb_tunable, election_timeout) },
 };
 
+/*
+  set all tunables to defaults
+ */
+void ctdb_tunables_set_defaults(struct ctdb_context *ctdb)
+{
+       int i;
+       for (i=0;i<ARRAY_SIZE(tunable_map);i++) {
+               *(uint32_t *)(tunable_map[i].offset + (uint8_t*)&ctdb->tunable) = tunable_map[i].default_v;
+       }
+}
+
 
 /*
   get a tunable
index 75126b211532032146e989ac44821ac73346f485..ac36bed3938686042b20107b4e90c5042e137c9c 100644 (file)
@@ -47,6 +47,9 @@ struct ctdb_tunable {
        uint32_t monitoring_timeout;
        uint32_t monitoring_limit;
        uint32_t max_lacount;
+       uint32_t recover_timeout;
+       uint32_t monitor_frequency;
+       uint32_t election_timeout;
 };
 
 /*
@@ -971,4 +974,6 @@ int32_t ctdb_control_get_tunable(struct ctdb_context *ctdb, TDB_DATA indata,
 int32_t ctdb_control_set_tunable(struct ctdb_context *ctdb, TDB_DATA indata);
 int32_t ctdb_control_list_tunables(struct ctdb_context *ctdb, TDB_DATA *outdata);
 
+void ctdb_tunables_set_defaults(struct ctdb_context *ctdb);
+
 #endif