activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1478095 - /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Failover/FailoverTransport.cs
Date Wed, 01 May 2013 17:05:44 GMT
Author: tabish
Date: Wed May  1 17:05:43 2013
New Revision: 1478095

URL: http://svn.apache.org/r1478095
Log:
Small update to priority support to prevent some unnecessary connection bouncing.  

Modified:
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Failover/FailoverTransport.cs

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Failover/FailoverTransport.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Failover/FailoverTransport.cs?rev=1478095&r1=1478094&r2=1478095&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Failover/FailoverTransport.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Failover/FailoverTransport.cs
Wed May  1 17:05:43 2013
@@ -1045,7 +1045,7 @@ namespace Apache.NMS.ActiveMQ.Transport.
                     {
 	                    if (doRebalance)
 						{
-	                        if (connectList[0].Equals(connectedTransportURI))
+	                        if (CompareUris(connectList[0], connectedTransportURI))
 							{
 	                            // already connected to first in the list, no need to rebalance
 	                            doRebalance = false;
@@ -1620,48 +1620,52 @@ namespace Apache.NMS.ActiveMQ.Transport.
 			return builder.ToString();
 		}
 
-	    private bool Contains(Uri newURI) 
+		private bool CompareUris(Uri first, Uri second) 
 		{
-	        bool result = false;
-	        foreach (Uri uri in uris) 
+            if (first.Port == second.Port)
 			{
-	            if (newURI.Port == uri.Port)
+                IPHostEntry firstAddr = null;
+                IPHostEntry secondAddr = null;
+                try 
 				{
-	                IPHostEntry newAddr = null;
-	                IPHostEntry addr = null;
-	                try 
+            		firstAddr = Dns.GetHostEntry(first.Host);
+            		secondAddr = Dns.GetHostEntry(second.Host);
+                } 
+				catch(Exception e)
+				{
+                    if (firstAddr == null) 
 					{
-                		newAddr = Dns.GetHostEntry(newURI.Host);
-                		addr = Dns.GetHostEntry(uri.Host);
-	                } 
-					catch(Exception e)
+						Tracer.WarnFormat("Failed to Lookup IPHostEntry for URI[{0}] : {1}", first, e);
+                    } 
+					else 
 					{
+						Tracer.WarnFormat("Failed to Lookup IPHostEntry for URI[{0}] : {1}", second, e);
+                    }
 
-	                    if (newAddr == null) 
-						{
-							Tracer.WarnFormat("Failed to Lookup IPHostEntry for URI[{0}] : {1}", newURI, e);
-	                    } 
-						else 
-						{
-							Tracer.WarnFormat("Failed to Lookup IPHostEntry for URI[{0}] : {1}", uri, e);
-	                    }
+					if(String.Equals(first.Host, second.Host, StringComparison.CurrentCultureIgnoreCase))
+					{
+						return true;
+                    }
+                }
 
-						if(String.Equals(newURI.Host, uri.Host, StringComparison.CurrentCultureIgnoreCase))
-						{
-	                        result = true;
-	                        break;
-	                    }
-						else 
-						{
-	                        continue;
-	                    }
-	                }
+                if (firstAddr.Equals(secondAddr)) 
+				{
+					return true;
+                }
+            }
 
-	                if (addr.Equals(newAddr)) 
-					{
-	                    result = true;
-	                    break;
-	                }
+			return false;
+		}
+
+	    private bool Contains(Uri newURI) 
+		{
+	        bool result = false;
+	        foreach (Uri uri in uris) 
+			{
+	            if (CompareUris(newURI, uri))
+				{
+					result = true;
+					break;
 	            }
 	        }
 



Mime
View raw message