From 3b9fdc8e68cb42e6ebfa75f3dc756fd54369f735 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Wed, 14 Nov 2012 16:04:04 +0000 Subject: QPID-4428: HA add UUID tag to avoid using an out of date queue/exchange. Imagine a cluster with primary A and backups B and C. A queue Q is created on A and replicated to B, C. Now A dies and B takes over as primary. Before C can connect to B, a client destroys Q and creates a new queue with the same name. When B connects it sees Q and incorrectly assumes it is the same Q that it has already replicated. Now C has an inconsistent replica of Q. The fix is to tag queues/exchanges with a UUID so a backup can tell if a queue is not the same as the one it has already replicated, even if the names are the same. This all also applies to exchanges. - Minor imrovements to printing UUIDs in a FieldTable. - Fix comparison of void Variants, added operator != git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1409241 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/framing/FieldValue.h | 13 +++++++++++-- qpid/cpp/include/qpid/types/Variant.h | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'qpid/cpp/include') diff --git a/qpid/cpp/include/qpid/framing/FieldValue.h b/qpid/cpp/include/qpid/framing/FieldValue.h index 458de62fdf..e964da495a 100644 --- a/qpid/cpp/include/qpid/framing/FieldValue.h +++ b/qpid/cpp/include/qpid/framing/FieldValue.h @@ -175,11 +175,19 @@ class FixedWidthValue : public FieldValue::Data { return v; } uint8_t* rawOctets() { return octets; } - uint8_t* rawOctets() const { return octets; } + const uint8_t* rawOctets() const { return octets; } void print(std::ostream& o) const { o << "F" << width << ":"; }; }; +class UuidData : public FixedWidthValue<16> { + public: + UuidData(); + UuidData(const unsigned char* bytes); + bool convertsToString() const; + std::string getString() const; +}; + template inline T FieldValue::getIntegerValue() const { @@ -356,7 +364,7 @@ class Var16Value : public FieldValue { class Var32Value : public FieldValue { public: QPID_COMMON_EXTERN Var32Value(const std::string& v, uint8_t code); -}; + }; class Struct32Value : public FieldValue { public: @@ -453,6 +461,7 @@ class ListValue : public FieldValue { class UuidValue : public FieldValue { public: + QPID_COMMON_EXTERN UuidValue(); QPID_COMMON_EXTERN UuidValue(const unsigned char*); }; diff --git a/qpid/cpp/include/qpid/types/Variant.h b/qpid/cpp/include/qpid/types/Variant.h index 3493559777..e6bfd6bc0a 100644 --- a/qpid/cpp/include/qpid/types/Variant.h +++ b/qpid/cpp/include/qpid/types/Variant.h @@ -177,6 +177,7 @@ QPID_TYPES_EXTERN std::ostream& operator<<(std::ostream& out, const Variant& val QPID_TYPES_EXTERN std::ostream& operator<<(std::ostream& out, const Variant::Map& map); QPID_TYPES_EXTERN std::ostream& operator<<(std::ostream& out, const Variant::List& list); QPID_TYPES_EXTERN bool operator==(const Variant& a, const Variant& b); +QPID_TYPES_EXTERN bool operator!=(const Variant& a, const Variant& b); #endif }} // namespace qpid::types -- cgit v1.2.1