QPID-3603: Make link maintenance interval configurable.

HA code needs faster reconnects than federation.
This is a temporary solution till we have a more robust
and rapid reconnect mechanism in place.

git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/qpid-3603-6@1244106 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/qpid/cpp/src/qpid/broker/Broker.cpp b/qpid/cpp/src/qpid/broker/Broker.cpp
index 2a890a4..221c315 100644
--- a/qpid/cpp/src/qpid/broker/Broker.cpp
+++ b/qpid/cpp/src/qpid/broker/Broker.cpp
@@ -127,7 +127,8 @@
     queueFlowResumeRatio(70),
     queueThresholdEventRatio(80),
     defaultMsgGroup("qpid.no-group"),
-    timestampRcvMsgs(false)     // set the 0.10 timestamp delivery property
+    timestampRcvMsgs(false),     // set the 0.10 timestamp delivery property
+    linkMaintenanceInterval(2)
 {
     int c = sys::SystemInfo::concurrency();
     workerThreads=c+1;
@@ -149,6 +150,8 @@
         ("mgmt-enable,m", optValue(enableMgmt,"yes|no"), "Enable Management")
         ("mgmt-qmf2", optValue(qmf2Support,"yes|no"), "Enable broadcast of management information over QMF v2")
         ("mgmt-qmf1", optValue(qmf1Support,"yes|no"), "Enable broadcast of management information over QMF v1")
+        // FIXME aconway 2012-02-13: consistent treatment of values in SECONDS
+        // allow sub-second intervals.
         ("mgmt-pub-interval", optValue(mgmtPubInterval, "SECONDS"), "Management Publish Interval")
         ("queue-purge-interval", optValue(queueCleanInterval, "SECONDS"),
          "Interval between attempts to purge any expired messages from queues")
@@ -164,7 +167,9 @@
         ("default-flow-resume-threshold", optValue(queueFlowResumeRatio, "PERCENT"), "Percent of queue's maximum capacity at which flow control is de-activated.")
         ("default-event-threshold-ratio", optValue(queueThresholdEventRatio, "%age of limit"), "The ratio of any specified queue limit at which an event will be raised")
         ("default-message-group", optValue(defaultMsgGroup, "GROUP-IDENTIFER"), "Group identifier to assign to messages delivered to a message group queue that do not contain an identifier.")
-        ("enable-timestamp", optValue(timestampRcvMsgs, "yes|no"), "Add current time to each received message.");
+        ("enable-timestamp", optValue(timestampRcvMsgs, "yes|no"), "Add current time to each received message.")
+        ("link-maintenace-interval", optValue(linkMaintenanceInterval, "SECONDS"))
+        ;
 }
 
 const std::string empty;
diff --git a/qpid/cpp/src/qpid/broker/Broker.h b/qpid/cpp/src/qpid/broker/Broker.h
index fbe653b..b6eab89 100644
--- a/qpid/cpp/src/qpid/broker/Broker.h
+++ b/qpid/cpp/src/qpid/broker/Broker.h
@@ -124,6 +124,7 @@
         uint16_t queueThresholdEventRatio;
         std::string defaultMsgGroup;
         bool timestampRcvMsgs;
+        double linkMaintenanceInterval; // FIXME aconway 2012-02-13: consistent parsing of SECONDS values.
 
       private:
         std::string getHome();
diff --git a/qpid/cpp/src/qpid/broker/Link.cpp b/qpid/cpp/src/qpid/broker/Link.cpp
index e896b32..e3b2b1f 100644
--- a/qpid/cpp/src/qpid/broker/Link.cpp
+++ b/qpid/cpp/src/qpid/broker/Link.cpp
@@ -50,10 +50,13 @@
 
 struct LinkTimerTask : public sys::TimerTask {
     LinkTimerTask(Link& l, sys::Timer& t)
-        : TimerTask(/*FIXME*/100*sys::TIME_MSEC, "Link retry timer"), link(l), timer(t) {}
+        : TimerTask(int64_t(l.getBroker()->getOptions().linkMaintenanceInterval*
+                            sys::TIME_SEC),
+                    "Link retry timer"),
+          link(l), timer(t) {}
 
     void fire() {
-        link.maintenanceVisit();  // FIXME aconway 2012-01-31:
+        link.maintenanceVisit();
         setupNextFire();
         timer.add(this);
     }
diff --git a/qpid/cpp/src/tests/ha_tests.py b/qpid/cpp/src/tests/ha_tests.py
index 950a092..97de0d1 100755
--- a/qpid/cpp/src/tests/ha_tests.py
+++ b/qpid/cpp/src/tests/ha_tests.py
@@ -31,8 +31,8 @@
     def __init__(self, test, args=[], broker_url=None, **kwargs):
         assert BrokerTest.ha_lib, "Cannot locate HA plug-in"
         args=["--load-module", BrokerTest.ha_lib,
-              "--log-enable=debug+:ha::", # FIXME aconway 2012-01-31:
-              "--log-enable=debug+:Link",
+              # FIXME aconway 2012-02-13: workaround slow link failover.
+              "--link-maintenace-interval=0.1",
               "--ha-enable=yes"]
         if broker_url: args += [ "--ha-broker-url", broker_url ]
         Broker.__init__(self, test, args, **kwargs)