Author: kgiusti Date: Thu May 3 14:13:05 2012 New Revision: 1333467 URL: http://svn.apache.org/viewvc?rev=1333467&view=rev Log: QPID-3767: fix federation and cluster failover support
Modified: qpid/branches/qpid-3767/qpid/cpp/src/qpid/broker/Link.cpp qpid/branches/qpid-3767/qpid/cpp/src/qpid/broker/Link.h qpid/branches/qpid-3767/qpid/cpp/src/qpid/broker/LinkRegistry.cpp qpid/branches/qpid-3767/qpid/cpp/src/qpid/broker/LinkRegistry.h Modified: qpid/branches/qpid-3767/qpid/cpp/src/qpid/broker/Link.cpp URL: http://svn.apache.org/viewvc/qpid/branches/qpid-3767/qpid/cpp/src/qpid/broker/Link.cpp?rev=1333467&r1=1333466&r2=1333467&view=diff ============================================================================== --- qpid/branches/qpid-3767/qpid/cpp/src/qpid/broker/Link.cpp (original) +++ qpid/branches/qpid-3767/qpid/cpp/src/qpid/broker/Link.cpp Thu May 3 14:13:05 2012 @@ -269,7 +269,7 @@ void Link::setUrl(const Url& u) { namespace { /** invoked when session used to subscribe to remote's amq.failover exchange detaches */ void sessionDetached(Link *link) { - QPID_LOG(debug, "detached from 'amq.failover' for link: " << link->getName()); + QPID_LOG(notice, "detached from 'amq.failover' for link: " << link->getName()); } } @@ -763,6 +763,14 @@ std::string Link::createName(const std:: return linkName.str(); } + +bool Link::pendingConnection(const std::string& _host, uint16_t _port) const +{ + Mutex::ScopedLock mutex(lock); + return (isConnecting() && _port == port && _host == host); +} + + const std::string Link::exchangeTypeName("qpid.LinkExchange"); }} // namespace qpid::broker Modified: qpid/branches/qpid-3767/qpid/cpp/src/qpid/broker/Link.h URL: http://svn.apache.org/viewvc/qpid/branches/qpid-3767/qpid/cpp/src/qpid/broker/Link.h?rev=1333467&r1=1333466&r2=1333467&view=diff ============================================================================== --- qpid/branches/qpid-3767/qpid/cpp/src/qpid/broker/Link.h (original) +++ qpid/branches/qpid-3767/qpid/cpp/src/qpid/broker/Link.h Thu May 3 14:13:05 2012 @@ -113,6 +113,7 @@ class Link : public PersistableConfig, p void closed(int, std::string); // Called when connection goes away void notifyConnectionForced(const std::string text); void closeConnection(const std::string& reason); + bool pendingConnection(const std::string& host, uint16_t port) const; // is Link trying to connect to this remote? friend class LinkRegistry; // to call established, opened, closed Modified: qpid/branches/qpid-3767/qpid/cpp/src/qpid/broker/LinkRegistry.cpp URL: http://svn.apache.org/viewvc/qpid/branches/qpid-3767/qpid/cpp/src/qpid/broker/LinkRegistry.cpp?rev=1333467&r1=1333466&r2=1333467&view=diff ============================================================================== --- qpid/branches/qpid-3767/qpid/cpp/src/qpid/broker/LinkRegistry.cpp (original) +++ qpid/branches/qpid-3767/qpid/cpp/src/qpid/broker/LinkRegistry.cpp Thu May 3 14:13:05 2012 @@ -68,7 +68,7 @@ LinkRegistry::LinkRegistry (Broker* _bro LinkRegistry::~LinkRegistry() {} -/** find link by current remote address */ +/** find link by the *configured* remote address */ boost::shared_ptr<Link> LinkRegistry::getLink(const std::string& host, uint16_t port, const std::string& transport) @@ -319,18 +319,16 @@ void LinkRegistry::notifyConnection(cons { Mutex::ScopedLock locker(lock); for (LinkMap::iterator l = links.begin(); l != links.end(); ++l) { - if (l->second->isConnecting() && - l->second->getHost() == host && - l->second->getPort() == port) { + if (l->second->pendingConnection(host, port)) { link = l->second; connections[key] = link->getName(); + link->established(c); break; } } } if (link) { - link->established(c); c->setUserId(str(format("%1%@%2%") % link->getUsername() % realm)); } } Modified: qpid/branches/qpid-3767/qpid/cpp/src/qpid/broker/LinkRegistry.h URL: http://svn.apache.org/viewvc/qpid/branches/qpid-3767/qpid/cpp/src/qpid/broker/LinkRegistry.h?rev=1333467&r1=1333466&r2=1333467&view=diff ============================================================================== --- qpid/branches/qpid-3767/qpid/cpp/src/qpid/broker/LinkRegistry.h (original) +++ qpid/branches/qpid-3767/qpid/cpp/src/qpid/broker/LinkRegistry.h Thu May 3 14:13:05 2012 @@ -86,10 +86,12 @@ namespace broker { /** determine if Link exists */ QPID_BROKER_EXTERN boost::shared_ptr<Link> getLink(const std::string& name); + /** host,port,transport will be matched against the configured values, which may + be different from the current values due to failover */ QPID_BROKER_EXTERN boost::shared_ptr<Link> - getLink(const std::string& host, - uint16_t port, - const std::string& transport = std::string()); + getLink(const std::string& configHost, + uint16_t configPort, + const std::string& configTransport = std::string()); QPID_BROKER_EXTERN std::pair<Bridge::shared_ptr, bool> declare(const std::string& name, --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org