[
https://issues.apache.org/jira/browse/ZOOKEEPER-1666?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13602372#comment-13602372
]
George Cao commented on ZOOKEEPER-1666:
---------------------------------------
[~sbridges], I am pretty sure that ZOOKEEPER-1652 did not solve the problem. In
*ConnectStringParser.java*, we use
{code:java}InetSocketAddress.createUnresolved(String host, int port);{code} to
initialize an instance of *InetSocketAddress*, and meantime InetAddress
instance included in it is null. Then later in *StaticHostProvider.java*, we
try to resolve the InetAddress by calling
{code:java}InetAddress.getAllByName((ia!=null) ? ia.getHostAddress():
address.getHostName());{code}. As i said, *ia* is always null here, but the
parameter passed to *getAllByName* will be an literal IP address. And the
return value will be an instance of *InetAddress* with the hostName property as
null, and the literal IP address is parsed to the real address. After we got
the *InetAddress* instance, we call this constructor {code:java}public
InetSocketAddress(InetAddress addr, int port){code} to create a new instance,
but still with no specific hostName value set. So if we call
{code:java}InetSocketAddress.getHostName(){code} still trigger a reverse DNS
lookup.
I will attach some test cases to back up.
> Avoid Reverse DNS lookup if the hostname in connection string is literal IP
> address.
> ------------------------------------------------------------------------------------
>
> Key: ZOOKEEPER-1666
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-1666
> Project: ZooKeeper
> Issue Type: Improvement
> Components: java client
> Reporter: George Cao
> Attachments: ZOOKEEPER-1666.patch
>
>
> In our ENV, if the InetSocketAddress.getHostName() is called and the host
> name in the connection string are literal IP address, then the call will
> trigger a reverse DNS lookup which is very slow.
> And in this situation, the host name can simply set as the IP without causing
> any problem.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira