You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zookeeper.apache.org by ra...@apache.org on 2014/05/10 12:42:44 UTC
svn commit: r1593682 - in /zookeeper/trunk: CHANGES.txt
src/java/main/org/apache/zookeeper/client/StaticHostProvider.java
Author: rakeshr
Date: Sat May 10 10:42:44 2014
New Revision: 1593682
URL: http://svn.apache.org/r1593682
Log:
ZOOKEEPER-1891. StaticHostProviderTest.testUpdateLoadBalancing times out (Michi Mutsuzaki via rakeshr)
Modified:
zookeeper/trunk/CHANGES.txt
zookeeper/trunk/src/java/main/org/apache/zookeeper/client/StaticHostProvider.java
Modified: zookeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/trunk/CHANGES.txt?rev=1593682&r1=1593681&r2=1593682&view=diff
==============================================================================
--- zookeeper/trunk/CHANGES.txt (original)
+++ zookeeper/trunk/CHANGES.txt Sat May 10 10:42:44 2014
@@ -639,6 +639,9 @@ BUGFIXES:
ZOOKEEPER-1926. Unit tests should only use build/test/data for data (Enis
Soztutar via michim)
+ ZOOKEEPER-1891. StaticHostProviderTest.testUpdateLoadBalancing times out
+ (Michi Mutsuzaki via rakeshr)
+
IMPROVEMENTS:
ZOOKEEPER-1170. Fix compiler (eclipse) warnings: unused imports,
Modified: zookeeper/trunk/src/java/main/org/apache/zookeeper/client/StaticHostProvider.java
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/java/main/org/apache/zookeeper/client/StaticHostProvider.java?rev=1593682&r1=1593681&r2=1593682&view=diff
==============================================================================
--- zookeeper/trunk/src/java/main/org/apache/zookeeper/client/StaticHostProvider.java (original)
+++ zookeeper/trunk/src/java/main/org/apache/zookeeper/client/StaticHostProvider.java Sat May 10 10:42:44 2014
@@ -27,6 +27,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Random;
+import org.apache.zookeeper.common.HostNameUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -116,18 +117,10 @@ public final class StaticHostProvider im
InetAddress resolvedAddresses[] = InetAddress.getAllByName((ia!=null) ? ia.getHostAddress():
address.getHostName());
for (InetAddress resolvedAddress : resolvedAddresses) {
- // If hostName is null but the address is not, we can tell that
- // the hostName is an literal IP address. Then we can set the host string as the hostname
- // safely to avoid reverse DNS lookup.
- // As far as i know, the only way to check if the hostName is null is use toString().
- // Both the two implementations of InetAddress are final class, so we can trust the return value of
- // the toString() method.
- if (resolvedAddress.toString().startsWith("/") && resolvedAddress.getAddress() != null) {
- tmpList.add(new InetSocketAddress(InetAddress.getByAddress(address.getHostName(),
- resolvedAddress.getAddress()), address.getPort()));
- } else {
- tmpList.add(new InetSocketAddress(resolvedAddress.getHostAddress(), address.getPort()));
- }
+ tmpList.add(new InetSocketAddress(InetAddress.getByAddress(
+ HostNameUtils.getHostString(address),
+ resolvedAddress.getAddress()),
+ address.getPort()));
}
}
Collections.shuffle(tmpList, sourceOfRandomness);