activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1446814 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/failover: URIPool.cpp URIPool.h
Date Fri, 15 Feb 2013 23:38:49 GMT
Author: tabish
Date: Fri Feb 15 23:38:49 2013
New Revision: 1446814

URL: http://svn.apache.org/r1446814
Log:
Let the URIPool track its priority URI

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/failover/URIPool.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/failover/URIPool.h

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/failover/URIPool.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/failover/URIPool.cpp?rev=1446814&r1=1446813&r2=1446814&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/failover/URIPool.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/failover/URIPool.cpp
Fri Feb 15 23:38:49 2013
@@ -31,19 +31,27 @@ using namespace decaf::lang;
 using namespace decaf::lang::exceptions;
 
 ////////////////////////////////////////////////////////////////////////////////
-URIPool::URIPool() : uriPool(), randomize(false) {
+URIPool::URIPool() : uriPool(), priorityURI(), randomize(false) {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-URIPool::URIPool(const decaf::util::List<URI>& uris) : uriPool(), randomize(false)
{
+URIPool::URIPool(const decaf::util::List<URI>& uris) : uriPool(), priorityURI(),
randomize(false) {
     this->uriPool.copy(uris);
+
+    if (!this->uriPool.isEmpty()) {
+        this->priorityURI = this->uriPool.getFirst();
+    }
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-URIPool::URIPool(const URIPool& uris) : uriPool(), randomize(false) {
+URIPool::URIPool(const URIPool& uris) : uriPool(), priorityURI(), randomize(false) {
     synchronized(&uris.uriPool) {
         this->uriPool.copy(uris.uriPool);
     }
+
+    if (!this->uriPool.isEmpty()) {
+        this->priorityURI = this->uriPool.getFirst();
+    }
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -52,6 +60,10 @@ URIPool& URIPool::operator= (const URIPo
         this->uriPool.copy(uris.uriPool);
     }
 
+    if (!this->uriPool.isEmpty()) {
+        this->priorityURI = this->uriPool.getFirst();
+    }
+
     return *this;
 }
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/failover/URIPool.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/failover/URIPool.h?rev=1446814&r1=1446813&r2=1446814&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/failover/URIPool.h
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/failover/URIPool.h
Fri Feb 15 23:38:49 2013
@@ -32,6 +32,7 @@ namespace failover {
     private:
 
         mutable decaf::util::LinkedList<decaf::net::URI> uriPool;
+        decaf::net::URI priorityURI;
         bool randomize;
 
     public:
@@ -72,6 +73,14 @@ namespace failover {
         bool isEmpty() const;
 
         /**
+         * Returns the URI that is considered to be this Pools Priority URI, this is
+         * always the first URI in the list of URIs that this pool was created with.
+         */
+        const decaf::net::URI& getPriorityURI() const {
+            return this->priorityURI;
+        }
+
+        /**
          * Fetches the next available URI from the pool, if there are no more
          * URIs free when this method is called it throws a NoSuchElementException.
          * Receiving the exception is not an indication that a URI won't be available



Mime
View raw message