qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject svn commit: r1483138 - in /qpid/trunk/qpid/cpp: include/qpid/Address.h src/qpid/Address.cpp src/qpid/ha/BrokerInfo.cpp src/qpid/ha/BrokerInfo.h src/qpid/ha/HaBroker.cpp
Date Thu, 16 May 2013 01:02:38 GMT
Author: aconway
Date: Thu May 16 01:02:37 2013
New Revision: 1483138

URL: http://svn.apache.org/r1483138
Log:
NO-JIRA: HA Use qpid::Address in ha::BrokerInfo rather than host/port.

Modified:
    qpid/trunk/qpid/cpp/include/qpid/Address.h
    qpid/trunk/qpid/cpp/src/qpid/Address.cpp
    qpid/trunk/qpid/cpp/src/qpid/ha/BrokerInfo.cpp
    qpid/trunk/qpid/cpp/src/qpid/ha/BrokerInfo.h
    qpid/trunk/qpid/cpp/src/qpid/ha/HaBroker.cpp

Modified: qpid/trunk/qpid/cpp/include/qpid/Address.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/include/qpid/Address.h?rev=1483138&r1=1483137&r2=1483138&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/include/qpid/Address.h (original)
+++ qpid/trunk/qpid/cpp/include/qpid/Address.h Thu May 16 01:02:37 2013
@@ -29,13 +29,13 @@ namespace client { struct ConnectionSett
 
 
 /**
- * Contains the protocol address of an AMQP broker. 
+ * Contains the protocol address of an AMQP broker.
  */
 struct Address  {
 public:
     static const std::string TCP; // Default TCP protocol tag.
     static const uint16_t AMQP_PORT=5672; // Default AMQP port.
-    
+
     QPID_COMMON_INLINE_EXTERN explicit Address(
         const std::string& protocol_=std::string(),
         const std::string& host_=std::string(),
@@ -49,6 +49,7 @@ public:
 
 QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream& os, const Address&
addr);
 QPID_COMMON_EXTERN bool operator==(const Address& x, const Address& y);
+QPID_COMMON_EXTERN bool operator!=(const Address& x, const Address& y);
 
 } // namespace qpid
 

Modified: qpid/trunk/qpid/cpp/src/qpid/Address.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/Address.cpp?rev=1483138&r1=1483137&r2=1483138&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/Address.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/Address.cpp Thu May 16 01:02:37 2013
@@ -40,5 +40,5 @@ ostream& operator<<(ostream& os, const A
 bool operator==(const Address& x, const Address& y) {
     return y.protocol==x.protocol && y.host==x.host && y.port == x.port;
 }
-
+bool operator!=(const Address& x, const Address& y) { return !(x == y); }
 } // namespace qpid

Modified: qpid/trunk/qpid/cpp/src/qpid/ha/BrokerInfo.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/ha/BrokerInfo.cpp?rev=1483138&r1=1483137&r2=1483138&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/ha/BrokerInfo.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/ha/BrokerInfo.cpp Thu May 16 01:02:37 2013
@@ -34,6 +34,7 @@ namespace ha {
 
 namespace {
 const std::string SYSTEM_ID="system-id";
+const std::string PROTOCOL="protocol";
 const std::string HOST_NAME="host-name";
 const std::string PORT="port";
 const std::string STATUS="status";
@@ -43,11 +44,10 @@ using types::Uuid;
 using types::Variant;
 using framing::FieldTable;
 
-BrokerInfo::BrokerInfo() : port(0), status(JOINING) {}
+BrokerInfo::BrokerInfo() : status(JOINING) {}
 
-BrokerInfo::BrokerInfo(const types::Uuid& id, BrokerStatus s,
-                       const std::string& host, uint16_t port_) :
-    hostName(host), port(port_), systemId(id), status(s)
+BrokerInfo::BrokerInfo(const types::Uuid& id, BrokerStatus s, const Address& a)
+  : address(a), systemId(id), status(s)
 {}
 
 FieldTable BrokerInfo::asFieldTable() const {
@@ -60,8 +60,9 @@ FieldTable BrokerInfo::asFieldTable() co
 Variant::Map BrokerInfo::asMap() const {
     Variant::Map m;
     m[SYSTEM_ID] = systemId;
-    m[HOST_NAME] = hostName;
-    m[PORT] = port;
+    m[PROTOCOL] = address.protocol;
+    m[HOST_NAME] = address.host;
+    m[PORT] = address.port;
     m[STATUS] = status;
     return m;
 }
@@ -79,19 +80,20 @@ const Variant& get(const Variant::Map& m
         QPID_MSG("Missing field '" << k << "' in broker information"));
     return i->second;
 }
+const Address empty;
 }
 
 void BrokerInfo::assign(const Variant::Map& m) {
     systemId = get(m, SYSTEM_ID).asUuid();
-    hostName = get(m, HOST_NAME).asString();
-    port = get(m, PORT).asUint16();
+    address = Address(get(m, PROTOCOL).asString(),
+                      get(m, HOST_NAME).asString(),
+                      get(m, PORT).asUint16());
     status = BrokerStatus(get(m, STATUS).asUint8());
 }
 
 std::ostream& operator<<(std::ostream& o, const BrokerInfo& b) {
     o  << b.getSystemId().str().substr(0,7);
-    if (!b.getHostName().empty())
-        o << "@" << b.getHostName() << ":" << b.getPort();
+    if (b.getAddress() != empty) o << "@" << b.getAddress();
     o << "(" << printable(b.getStatus()) << ")";
     return o;
 }

Modified: qpid/trunk/qpid/cpp/src/qpid/ha/BrokerInfo.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/ha/BrokerInfo.h?rev=1483138&r1=1483137&r2=1483138&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/ha/BrokerInfo.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/ha/BrokerInfo.h Thu May 16 01:02:37 2013
@@ -44,15 +44,13 @@ class BrokerInfo
     typedef std::map<types::Uuid, BrokerInfo> Map;
 
     BrokerInfo();
-    BrokerInfo(const types::Uuid& id, BrokerStatus,
-               const std::string& host=std::string(), uint16_t port=0);
+    BrokerInfo(const types::Uuid& id, BrokerStatus, const Address& = Address());
     BrokerInfo(const framing::FieldTable& ft) { assign(ft); }
     BrokerInfo(const types::Variant::Map& m) { assign(m); }
 
     types::Uuid getSystemId() const { return systemId; }
-    std::string getHostName() const { return hostName; }
     BrokerStatus getStatus() const { return status; }
-    uint16_t getPort() const { return port; }
+    Address getAddress() const { return address; }
 
     void setStatus(BrokerStatus s)  { status = s; }
 
@@ -66,8 +64,7 @@ class BrokerInfo
     bool operator<(const BrokerInfo x) const { return systemId < x.systemId; }
 
   private:
-    std::string hostName;
-    uint16_t port;
+    Address address;
     types::Uuid systemId;
     BrokerStatus status;
 };

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=1483138&r1=1483137&r2=1483138&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/ha/HaBroker.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/ha/HaBroker.cpp Thu May 16 01:02:37 2013
@@ -201,7 +201,7 @@ BrokerStatus HaBroker::getStatus() const
 
 void HaBroker::setAddress(const Address& a) {
     QPID_LOG(info, role->getLogPrefix() << "Set self address to: " << a);
-    BrokerInfo b(membership.getSelf(), membership.getStatus(), a.host, a.port);
+    BrokerInfo b(membership.getSelf(), membership.getStatus(), a);
     membership.add(b);
 }
 



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


Mime
View raw message