Return-Path: X-Original-To: apmail-activemq-commits-archive@www.apache.org Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D18ECFF1E for ; Wed, 1 May 2013 20:59:04 +0000 (UTC) Received: (qmail 95007 invoked by uid 500); 1 May 2013 20:59:04 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 94965 invoked by uid 500); 1 May 2013 20:59:04 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 94957 invoked by uid 99); 1 May 2013 20:59:04 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 May 2013 20:59:04 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 May 2013 20:59:03 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 6B03A2388993; Wed, 1 May 2013 20:58:43 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1478185 - /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Failover/FailoverTransport.cs Date: Wed, 01 May 2013 20:58:43 -0000 To: commits@activemq.apache.org From: tabish@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130501205843.6B03A2388993@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: tabish Date: Wed May 1 20:58:43 2013 New Revision: 1478185 URL: http://svn.apache.org/r1478185 Log: https://issues.apache.org/jira/browse/AMQNET-403 Some final improvements to the priority backup code. 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=1478185&r1=1478184&r2=1478185&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 20:58:43 2013 @@ -135,8 +135,6 @@ namespace Apache.NMS.ActiveMQ.Transport. { result = parent.DoConnect(); buildBackup = false; - parent.connectedToPriority = - parent.IsPriority(parent.connectedTransportURI); } } if (buildBackup) @@ -466,6 +464,7 @@ namespace Apache.NMS.ActiveMQ.Transport. initialized = false; failedConnectTransportURI = ConnectedTransportURI; ConnectedTransportURI = null; + connectedToPriority = false; connected = false; if(this.Interrupted != null) @@ -1045,7 +1044,7 @@ namespace Apache.NMS.ActiveMQ.Transport. { if (doRebalance) { - if (CompareUris(connectList[0], connectedTransportURI)) + if (connectedToPriority || CompareUris(connectList[0], connectedTransportURI)) { // already connected to first in the list, no need to rebalance doRebalance = false; @@ -1166,6 +1165,7 @@ namespace Apache.NMS.ActiveMQ.Transport. reconnectDelay = initialReconnectDelay; connectedTransportURI = uri; connectedTransport.Value = transport; + connectedToPriority = IsPriority(connectedTransportURI); Monitor.PulseAll(reconnectMutex); connectFailures = 0; @@ -1496,16 +1496,18 @@ namespace Apache.NMS.ActiveMQ.Transport. internal bool IsPriority(Uri uri) { - if (priorityList.Count > 0) + if (priorityBackup) { - return priorityList.Contains(uri); - } + if (priorityList.Count > 0) + { + return priorityList.Contains(uri); + } - if (this.uris.Count > 0) - { - return uris[0].Equals(uri); + if (this.uris.Count > 0) + { + return uris[0].Equals(uri); + } } - return false; } @@ -1622,6 +1624,7 @@ namespace Apache.NMS.ActiveMQ.Transport. private bool CompareUris(Uri first, Uri second) { + bool result = false; if (first.Port == second.Port) { IPHostEntry firstAddr = null; @@ -1630,7 +1633,12 @@ namespace Apache.NMS.ActiveMQ.Transport. { firstAddr = Dns.GetHostEntry(first.Host); secondAddr = Dns.GetHostEntry(second.Host); - } + + if (firstAddr.Equals(secondAddr)) + { + result = true; + } + } catch(Exception e) { if (firstAddr == null) @@ -1644,17 +1652,13 @@ namespace Apache.NMS.ActiveMQ.Transport. if(String.Equals(first.Host, second.Host, StringComparison.CurrentCultureIgnoreCase)) { - return true; + result = true; } } - if (firstAddr.Equals(secondAddr)) - { - return true; - } } - return false; + return result; } private bool Contains(Uri newURI)