[ 
https://issues.apache.org/jira/browse/KAFKA-1615?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14328168#comment-14328168
 ] 

Jonathan Rafalski commented on KAFKA-1615:
------------------------------------------

hello [~gwenshap], now that I have the source up and running I took a look at 
this, and correct me if I am wrong here but if we want to get the IP and we 
don't have a hostname I will need to use networkinterfaces and iterate through 
to find the first interface with a non loopback IP.

Using that method, once I find the IP the networkinterface class is going to 
return an inetaddress which could be an IPv6 or IPv4 depending on what comes 
back first.

if for whatever reason nothing is found (aka if the only nic went down) the 
hostname will default to "localhost" (though being that we already have checked 
the nic connection to zookeeper i don't think this case will ever happen).  

seems like a very thick process just to generate an Id, so I wanted to check 
before making the change.  What do you think?

> Generating group ID in ZookeeperConsumerConnector shouldn't require local 
> hostname to resolve
> ---------------------------------------------------------------------------------------------
>
>                 Key: KAFKA-1615
>                 URL: https://issues.apache.org/jira/browse/KAFKA-1615
>             Project: Kafka
>          Issue Type: Bug
>    Affects Versions: 0.8.1.1
>            Reporter: Gwen Shapira
>            Assignee: Gwen Shapira
>            Priority: Minor
>              Labels: newbie, usability
>
> ZookeeperConsumerConnector generates group ID by taking the local hostname:
> consumerUuid = "%s-%d-%s".format(
>         InetAddress.getLocalHost.getHostName, System.currentTimeMillis,
>         uuid.getMostSignificantBits().toHexString.substring(0,8))
> If localhost doesn't resolve (something that happens occasionally), this will 
> fail with following error:
> Exception in thread "main" java.net.UnknownHostException: Billc-cent70x64: 
> Billc-cent70x64: Name or service not known
>       at java.net.InetAddress.getLocalHost(InetAddress.java:1473)
>       at 
> kafka.consumer.ZookeeperConsumerConnector.<init>(ZookeeperConsumerConnector.scala:119)
>       at 
> kafka.consumer.ZookeeperConsumerConnector.<init>(ZookeeperConsumerConnector.scala:142)
>       at kafka.consumer.Consumer$.create(ConsumerConnector.scala:89)
>       at kafka.tools.ConsoleConsumer$.main(ConsoleConsumer.scala:149)
>       at kafka.tools.ConsoleConsumer.main(ConsoleConsumer.scala)
> Caused by: java.net.UnknownHostException: Billc-cent70x64: Name or service 
> not known
>       at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
>       at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:901)
>       at 
> java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1293)
>       at java.net.InetAddress.getLocalHost(InetAddress.java:1469)
>       ... 5 more
> Normally requiring a resolving localhost is not a problem, but here is seems 
> a bit frivolous - its just for generating an ID, nothing network related.
> I think we can catch the exception and generate an ID without the hostname.
> This is low priority since the issue can be easily worked around (add the 
> hostname to /etc/hosts) and since this API is going away anyway with the new 
> consumer API.  



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to