zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f..@apache.org
Subject svn commit: r1526695 - in /zookeeper/branches/branch-3.4: CHANGES.txt src/java/main/org/apache/zookeeper/client/StaticHostProvider.java src/java/test/org/apache/zookeeper/test/StaticHostProviderTest.java
Date Thu, 26 Sep 2013 21:15:53 GMT
Author: fpj
Date: Thu Sep 26 21:15:53 2013
New Revision: 1526695

URL: http://svn.apache.org/r1526695
Log:
ZOOKEEPER-1603. StaticHostProviderTest testUpdateClientMigrateOrNot hangs (fpj)


Modified:
    zookeeper/branches/branch-3.4/CHANGES.txt
    zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/client/StaticHostProvider.java
    zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/StaticHostProviderTest.java

Modified: zookeeper/branches/branch-3.4/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/CHANGES.txt?rev=1526695&r1=1526694&r2=1526695&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/CHANGES.txt (original)
+++ zookeeper/branches/branch-3.4/CHANGES.txt Thu Sep 26 21:15:53 2013
@@ -114,6 +114,9 @@ BUGFIXES:
 
   ZOOKEEPER-87. Follower does not shut itself down if its too far behind the leader. (German
Blanco via fpj)
 
+  ZOOKEEPER-1603. StaticHostProviderTest testUpdateClientMigrateOrNot hangs (fpj)
+
+
 IMPROVEMENTS:
 
   ZOOKEEPER-1564. Allow JUnit test build with IBM Java

Modified: zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/client/StaticHostProvider.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/client/StaticHostProvider.java?rev=1526695&r1=1526694&r2=1526695&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/client/StaticHostProvider.java
(original)
+++ zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/client/StaticHostProvider.java
Thu Sep 26 21:15:53 2013
@@ -57,8 +57,9 @@ public final class StaticHostProvider im
     public StaticHostProvider(Collection<InetSocketAddress> serverAddresses)
             throws UnknownHostException {
         for (InetSocketAddress address : serverAddresses) {
-            InetAddress resolvedAddresses[] = InetAddress.getAllByName(address
-                    .getHostName());
+            InetAddress ia = address.getAddress();
+            InetAddress resolvedAddresses[] = InetAddress.getAllByName((ia!=null) ? ia.getHostAddress():
+                address.getHostName());
             for (InetAddress resolvedAddress : resolvedAddresses) {
                 this.serverAddresses.add(new InetSocketAddress(resolvedAddress
                         .getHostAddress(), address.getPort()));

Modified: zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/StaticHostProviderTest.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/StaticHostProviderTest.java?rev=1526695&r1=1526694&r2=1526695&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/StaticHostProviderTest.java
(original)
+++ zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/StaticHostProviderTest.java
Thu Sep 26 21:15:53 2013
@@ -21,20 +21,27 @@ package org.apache.zookeeper.test;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotSame;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import org.apache.zookeeper.ZKTestCase;
 import org.apache.zookeeper.client.HostProvider;
 import org.apache.zookeeper.client.StaticHostProvider;
 import org.junit.Test;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.UnknownHostException;
 import java.util.ArrayList;
 
 public class StaticHostProviderTest extends ZKTestCase {
+    private static final Logger LOG = LoggerFactory.getLogger(StaticHostProviderTest.class);
 
     @Test
     public void testNextGoesRound() throws UnknownHostException {
-        HostProvider hostProvider = getHostProvider(2);
+        HostProvider hostProvider = getHostProvider((byte) 2);
         InetSocketAddress first = hostProvider.next(0);
         assertTrue(first instanceof InetSocketAddress);
         hostProvider.next(0);
@@ -43,7 +50,7 @@ public class StaticHostProviderTest exte
 
     @Test
     public void testNextGoesRoundAndSleeps() throws UnknownHostException {
-        int size = 2;
+        byte size = 2;
         HostProvider hostProvider = getHostProvider(size);
         while (size > 0) {
             hostProvider.next(0);
@@ -57,7 +64,7 @@ public class StaticHostProviderTest exte
 
     @Test
     public void testNextDoesNotSleepForZero() throws UnknownHostException {
-        int size = 2;
+        byte size = 2;
         HostProvider hostProvider = getHostProvider(size);
         while (size > 0) {
             hostProvider.next(0);
@@ -72,25 +79,30 @@ public class StaticHostProviderTest exte
     @Test
     public void testTwoConsequitiveCallsToNextReturnDifferentElement()
             throws UnknownHostException {
-        HostProvider hostProvider = getHostProvider(2);
+        HostProvider hostProvider = getHostProvider((byte) 2);
         assertNotSame(hostProvider.next(0), hostProvider.next(0));
     }
 
     @Test
     public void testOnConnectDoesNotReset() throws UnknownHostException {
-        HostProvider hostProvider = getHostProvider(2);
+        HostProvider hostProvider = getHostProvider((byte) 2);
         InetSocketAddress first = hostProvider.next(0);
         hostProvider.onConnected();
         InetSocketAddress second = hostProvider.next(0);
         assertNotSame(first, second);
     }
 
-    private StaticHostProvider getHostProvider(int size)
+    private StaticHostProvider getHostProvider(byte size)
             throws UnknownHostException {
         ArrayList<InetSocketAddress> list = new ArrayList<InetSocketAddress>(
                 size);
         while (size > 0) {
-            list.add(new InetSocketAddress("10.10.10." + size, 1234));
+            try {
+                list.add(new InetSocketAddress(InetAddress.getByAddress(new byte[]{10, 10,
10, size}), 1234 + size));
+            } catch (UnknownHostException e) {
+                LOG.error("Exception while resolving address", e);
+                fail("Failed to resolve address");
+            }
             --size;
         }
         return new StaticHostProvider(list);



Mime
View raw message