qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject svn commit: r1232958 - /qpid/branches/qpid-3603/qpid/cpp/src/qpid/ha/BrokerReplicator.cpp
Date Wed, 18 Jan 2012 17:15:13 GMT
Author: aconway
Date: Wed Jan 18 17:15:13 2012
New Revision: 1232958

URL: http://svn.apache.org/viewvc?rev=1232958&view=rev
Log:
QPID-3603: Fix replication of unbind events.

Old clients can omit certain map values. Previously this caused an error,
now a void value is treated as an empty map.

Modified:
    qpid/branches/qpid-3603/qpid/cpp/src/qpid/ha/BrokerReplicator.cpp

Modified: qpid/branches/qpid-3603/qpid/cpp/src/qpid/ha/BrokerReplicator.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-3603/qpid/cpp/src/qpid/ha/BrokerReplicator.cpp?rev=1232958&r1=1232957&r2=1232958&view=diff
==============================================================================
--- qpid/branches/qpid-3603/qpid/cpp/src/qpid/ha/BrokerReplicator.cpp (original)
+++ qpid/branches/qpid-3603/qpid/cpp/src/qpid/ha/BrokerReplicator.cpp Wed Jan 18 17:15:13
2012
@@ -175,9 +175,10 @@ void sendQuery(const string className, c
     sessionHandler.out->handle(content);
 }
 
-void translate(const Variant& value, framing::FieldTable& outArgs) {
-    if (!value.isVoid())
-        amqp_0_10::translate(value.asMap(), outArgs);
+// Like Variant::asMap but treat void value as an empty map.
+Variant::Map asMapVoid(const Variant& value) {
+    if (!value.isVoid()) return value.asMap();
+    else return Variant::Map();
 }
 
 } // namespace
@@ -253,7 +254,7 @@ void BrokerReplicator::route(Deliverable
                 string type = i->asMap()[SCHEMA_ID].asMap()[CLASS_NAME];
                 Variant::Map& values = i->asMap()[VALUES].asMap();
                 framing::FieldTable args;
-                translate(values[ARGUMENTS].asMap(), args);
+                amqp_0_10::translate(asMapVoid(values[ARGUMENTS]), args);
                 if      (type == QUEUE) doResponseQueue(values);
                 else if (type == EXCHANGE) doResponseExchange(values);
                 else if (type == BINDING) doResponseBind(values);
@@ -268,10 +269,10 @@ void BrokerReplicator::route(Deliverable
 
 void BrokerReplicator::doEventQueueDeclare(Variant::Map& values) {
     string name = values[QNAME].asString();
-    Variant::Map argsMap = values[ARGS].asMap();
+    Variant::Map argsMap = asMapVoid(values[ARGS]);
     if (values[DISP] == CREATED && replicateLevel(argsMap)) {
         framing::FieldTable args;
-        translate(argsMap, args);
+        amqp_0_10::translate(argsMap, args);
         std::pair<boost::shared_ptr<Queue>, bool> result =
             broker.createQueue(
                 name,
@@ -315,11 +316,11 @@ void BrokerReplicator::doEventQueueDelet
 }
 
 void BrokerReplicator::doEventExchangeDeclare(Variant::Map& values) {
-    Variant::Map argsMap(values[ARGS].asMap());
+    Variant::Map argsMap(asMapVoid(values[ARGS]));
     if (values[DISP] == CREATED && replicateLevel(argsMap)) {
         string name = values[EXNAME].asString();
         framing::FieldTable args;
-        translate(argsMap, args);
+        amqp_0_10::translate(argsMap, args);
         if (broker.createExchange(
                 name,
                 values[EXTYPE].asString(),
@@ -363,7 +364,7 @@ void BrokerReplicator::doEventBind(Varia
         queue && replicateLevel(queue->getSettings()))
     {
         framing::FieldTable args;
-        translate(values[ARGS].asMap(), args);
+        amqp_0_10::translate(asMapVoid(values[ARGS]), args);
         string key = values[KEY].asString();
         QPID_LOG(debug, "HA: Backup replicated binding exchange=" << exchange->getName()
                  << " queue=" << queue->getName()
@@ -383,7 +384,7 @@ void BrokerReplicator::doEventUnbind(Var
         queue && replicateLevel(queue->getSettings()))
     {
         framing::FieldTable args;
-        translate(values[ARGS].asMap(), args);
+        amqp_0_10::translate(asMapVoid(values[ARGS]), args);
         string key = values[KEY].asString();
         QPID_LOG(debug, "HA: Backup replicated unbinding exchange=" << exchange->getName()
                  << " queue=" << queue->getName()
@@ -394,10 +395,10 @@ void BrokerReplicator::doEventUnbind(Var
 
 void BrokerReplicator::doResponseQueue(Variant::Map& values) {
     // FIXME aconway 2011-11-22: more flexible ways & defaults to indicate replication
-    Variant::Map argsMap(values[ARGUMENTS].asMap());
+    Variant::Map argsMap(asMapVoid(values[ARGUMENTS]));
     if (!replicateLevel(argsMap)) return;
     framing::FieldTable args;
-    translate(argsMap, args);
+    amqp_0_10::translate(argsMap, args);
     string name(values[NAME].asString());
     std::pair<boost::shared_ptr<Queue>, bool> result =
         broker.createQueue(
@@ -420,10 +421,10 @@ void BrokerReplicator::doResponseQueue(V
 }
 
 void BrokerReplicator::doResponseExchange(Variant::Map& values) {
-    Variant::Map argsMap(values[ARGUMENTS].asMap());
+    Variant::Map argsMap(asMapVoid(values[ARGUMENTS]));
     if (!replicateLevel(argsMap)) return;
     framing::FieldTable args;
-    translate(argsMap, args);
+    amqp_0_10::translate(argsMap, args);
     if (broker.createExchange(
             values[NAME].asString(),
             values[TYPE].asString(),
@@ -472,7 +473,7 @@ void BrokerReplicator::doResponseBind(Va
         queue && replicateLevel(queue->getSettings()))
     {
         framing::FieldTable args;
-        translate(values[ARGUMENTS].asMap(), args);
+        amqp_0_10::translate(asMapVoid(values[ARGUMENTS]), args);
         string key = values[KEY].asString();
         exchange->bind(queue, key, &args);
         QPID_LOG(debug, "HA: Backup catch-up binding: exchange=" << exchange->getName()



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message