From b11b8fcf37badfdc43ffc3deb758b9a2431e19a6 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Mon, 10 Dec 2012 22:43:16 +0000 Subject: QPID-4498: HA module should only initialize if requested This commit provides better control over loading the HA module. In particular it is not loaded if no ha options are set. This will prevent clashes with the old cluster plugin in configurations where the HA module is not explicitly used. HA documentation has been updated to state that HA and old cluster cannot be used together. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1419850 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/ha/HaPlugin.cpp | 4 +++- cpp/src/qpid/ha/Settings.h | 4 +++- cpp/src/tests/ha_tests.py | 12 ++++++++---- 3 files changed, 14 insertions(+), 6 deletions(-) (limited to 'cpp/src') diff --git a/cpp/src/qpid/ha/HaPlugin.cpp b/cpp/src/qpid/ha/HaPlugin.cpp index 3d77a4cbd1..cba9c0bb26 100644 --- a/cpp/src/qpid/ha/HaPlugin.cpp +++ b/cpp/src/qpid/ha/HaPlugin.cpp @@ -33,6 +33,8 @@ struct Options : public qpid::Options { addOptions() ("ha-cluster", optValue(settings.cluster, "yes|no"), "Join a HA active/passive cluster.") + ("ha-queue-replication", optValue(settings.queueReplication, "yes|no"), + "Enable replication of specific queues without joining a cluster") ("ha-brokers-url", optValue(settings.brokerUrl,"URL"), "URL with address of each broker in the cluster.") ("ha-public-url", optValue(settings.clientUrl,"URL"), @@ -68,7 +70,7 @@ struct HaPlugin : public Plugin { void earlyInitialize(Plugin::Target& target) { broker::Broker* broker = dynamic_cast(&target); - if (broker) { + if (broker && (settings.cluster || settings.queueReplication)) { if (!broker->getManagementAgent()) { QPID_LOG(info, "HA plugin disabled because management is disabled"); if (settings.cluster) diff --git a/cpp/src/qpid/ha/Settings.h b/cpp/src/qpid/ha/Settings.h index 1be068063a..d3dcb96dad 100644 --- a/cpp/src/qpid/ha/Settings.h +++ b/cpp/src/qpid/ha/Settings.h @@ -35,11 +35,13 @@ namespace ha { class Settings { public: - Settings() : cluster(false), replicateDefault(NONE), backupTimeout(5), + Settings() : cluster(false), queueReplication(false), + replicateDefault(NONE), backupTimeout(5), flowMessages(100), flowBytes(0) {} bool cluster; // True if we are a cluster member. + bool queueReplication; // True if enabled. std::string clientUrl; std::string brokerUrl; Enum replicateDefault; diff --git a/cpp/src/tests/ha_tests.py b/cpp/src/tests/ha_tests.py index bc5566ae63..968ffa8b4a 100755 --- a/cpp/src/tests/ha_tests.py +++ b/cpp/src/tests/ha_tests.py @@ -279,11 +279,13 @@ class ReplicationTests(HaBrokerTest): """Test replication of individual queues outside of cluster mode""" l = LogLevel(ERROR) # Hide expected WARNING log messages from failover. try: - primary = HaBroker(self, name="primary", ha_cluster=False) + primary = HaBroker(self, name="primary", ha_cluster=False, + args=["--ha-queue-replication=yes"]); pc = primary.connect() ps = pc.session().sender("q;{create:always}") pr = pc.session().receiver("q;{create:always}") - backup = HaBroker(self, name="backup", ha_cluster=False) + backup = HaBroker(self, name="backup", ha_cluster=False, + args=["--ha-queue-replication=yes"]) br = backup.connect().session().receiver("q;{create:always}") # Set up replication with qpid-ha @@ -304,7 +306,8 @@ class ReplicationTests(HaBrokerTest): finally: l.restore() def test_queue_replica_failover(self): - """Test individual queue replication from a cluster to a standalone backup broker, verify it fails over.""" + """Test individual queue replication from a cluster to a standalone + backup broker, verify it fails over.""" l = LogLevel(ERROR) # Hide expected WARNING log messages from failover. try: cluster = HaCluster(self, 2) @@ -312,7 +315,8 @@ class ReplicationTests(HaBrokerTest): pc = cluster.connect(0) ps = pc.session().sender("q;{create:always}") pr = pc.session().receiver("q;{create:always}") - backup = HaBroker(self, name="backup", ha_cluster=False) + backup = HaBroker(self, name="backup", ha_cluster=False, + args=["--ha-queue-replication=yes"]) br = backup.connect().session().receiver("q;{create:always}") backup.replicate(cluster.url, "q") ps.send("a") -- cgit v1.2.1