qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject svn commit: r1437742 - in /qpid/trunk/qpid/cpp/src/qpid/ha: BrokerReplicator.cpp HaBroker.cpp HaBroker.h QueueReplicator.cpp
Date Wed, 23 Jan 2013 21:23:21 GMT
Author: aconway
Date: Wed Jan 23 21:23:21 2013
New Revision: 1437742

URL: http://svn.apache.org/viewvc?rev=1437742&view=rev
Log:
NO-JIRA: HA refactor, centralize critical error shutdown logic.

Modified:
    qpid/trunk/qpid/cpp/src/qpid/ha/BrokerReplicator.cpp
    qpid/trunk/qpid/cpp/src/qpid/ha/HaBroker.cpp
    qpid/trunk/qpid/cpp/src/qpid/ha/HaBroker.h
    qpid/trunk/qpid/cpp/src/qpid/ha/QueueReplicator.cpp

Modified: qpid/trunk/qpid/cpp/src/qpid/ha/BrokerReplicator.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/ha/BrokerReplicator.cpp?rev=1437742&r1=1437741&r2=1437742&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/ha/BrokerReplicator.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/ha/BrokerReplicator.cpp Wed Jan 23 21:23:21 2013
@@ -439,9 +439,10 @@ void BrokerReplicator::route(Deliverable
             }
         }
     } catch (const std::exception& e) {
-        QPID_LOG(critical, logPrefix << "Configuration replication failed: " <<
e.what()
-                 << ": while handling: " << list);
-        haBroker.shutdown();
+;
+        haBroker.shutdown(
+            QPID_MSG(logPrefix << "Configuration replication failed: "
+                     << e.what() << ": while handling: " << list));
         throw;
     }
 }
@@ -725,9 +726,10 @@ void BrokerReplicator::doResponseHaBroke
                                      << ") does not match primary (" <<  primary
<< ")"));
         haBroker.setMembership(values[MEMBERS].asList());
     } catch (const std::exception& e) {
-        QPID_LOG(critical, logPrefix << "Invalid HA Broker response: " << e.what()
-                 << ": " << values);
-        haBroker.shutdown();
+        haBroker.shutdown(
+            QPID_MSG(logPrefix << "Invalid HA Broker response: " << e.what()
+                     << ": " << values));
+
         throw;
     }
 }

Modified: qpid/trunk/qpid/cpp/src/qpid/ha/HaBroker.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/ha/HaBroker.cpp?rev=1437742&r1=1437741&r2=1437742&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/ha/HaBroker.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/ha/HaBroker.cpp Wed Jan 23 21:23:21 2013
@@ -256,9 +256,10 @@ std::vector<Url> HaBroker::getKnownBroke
     return knownBrokers;
 }
 
-void HaBroker::shutdown() {
-    QPID_LOG(critical, logPrefix << "Critical error, shutting down.");
+void HaBroker::shutdown(const std::string& message) {
+    QPID_LOG(critical, message);
     broker.shutdown();
+    throw Exception(message);
 }
 
 BrokerStatus HaBroker::getStatus() const {
@@ -294,12 +295,11 @@ void HaBroker::setStatus(BrokerStatus ne
     QPID_LOG(info, logPrefix << "Status change: "
              << printable(status) << " -> " << printable(newStatus));
     bool legal = checkTransition(status, newStatus);
+    assert(legal);
     if (!legal) {
-        QPID_LOG(critical, logPrefix << "Illegal state transition: "
-                 << printable(status) << " -> " << printable(newStatus));
-        shutdown();
+        shutdown(QPID_MSG(logPrefix << "Illegal state transition: "
+                 << printable(status) << " -> " << printable(newStatus)));
     }
-    assert(legal);              // FIXME aconway 2012-12-07: fail
     status = newStatus;
     statusChanged(l);
 }

Modified: qpid/trunk/qpid/cpp/src/qpid/ha/HaBroker.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/ha/HaBroker.h?rev=1437742&r1=1437741&r2=1437742&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/ha/HaBroker.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/ha/HaBroker.h Wed Jan 23 21:23:21 2013
@@ -78,8 +78,8 @@ class HaBroker : public management::Mana
     broker::Broker& getBroker() { return broker; }
     const Settings& getSettings() const { return settings; }
 
-    /** Shut down the broker. Caller should log a critical error message. */
-    void shutdown();
+    /** Shut down the broker because of a critical error. */
+    void shutdown(const std::string& message);
 
     BrokerStatus getStatus() const;
     void setStatus(BrokerStatus);

Modified: qpid/trunk/qpid/cpp/src/qpid/ha/QueueReplicator.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/ha/QueueReplicator.cpp?rev=1437742&r1=1437741&r2=1437742&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/ha/QueueReplicator.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/ha/QueueReplicator.cpp Wed Jan 23 21:23:21 2013
@@ -260,9 +260,7 @@ void QueueReplicator::route(Deliverable&
         // Ignore unknown event keys, may be introduced in later versions.
     }
     catch (const std::exception& e) {
-        QPID_LOG(critical, logPrefix << "Replication failed: " << e.what());
-        haBroker.shutdown();
-        throw;
+        haBroker.shutdown(QPID_MSG(logPrefix << "Replication failed: " << e.what()));
     }
 }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message