You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-dev@hadoop.apache.org by Beckham007 <ch...@gmail.com> on 2011/10/13 02:50:43 UTC

Problem in NetUtils

Hi,
Today, I use org.apache.hadoop.net.NetUtils Class to change IP address and hostname.
 normalizeHostName
but I think the normalizeHostName didn't works well. The Character.digit(name.charAt(0), 16) != -1
couldn't tell whether it's a IP address or a hostname.

public static String normalizeHostName(String name) {
    if (Character.digit(name.charAt(0), 16) != -1) { // it is an IP
      return name;
    } else {
      try {
        InetAddress ipAddress = InetAddress.getByName(name);
        return ipAddress.getHostAddress();
      } catch (UnknownHostException e) {
        return name;
      }
    }
  }
The version of hadoop is 0.21.0
http://svn.apache.org/repos/asf/hadoop/common/tags/release-0.21.0/common/src/java/org/apache/hadoop/net/NetUtils.java 
zhendong

Re: Problem in NetUtils

Posted by Uma Maheswara Rao G 72686 <ma...@huawei.com>.
Please check the issue for more details.
https://issues.apache.org/jira/browse/HADOOP-6682
 issue : NetUtils:normalizeHostName does not process hostnames starting with [a-f] correctly

Kihwal already mentioned the fixed versions.

is this the issue you are facing?

Regards,
Uma

----- Original Message -----
From: Kihwal Lee <ki...@yahoo-inc.com>
Date: Thursday, October 13, 2011 9:03 am
Subject: Re: Problem in NetUtils
To: "hdfs-dev@hadoop.apache.org" <hd...@hadoop.apache.org>

> 0.21 is not actively maintained.
> The bug was fixed in other active branches (0.20-security, 0.22, 
> 0.23, etc.) and trunk.
> 
> Kihwal
> 
> On 10/12/11 7:50 PM, "Beckham007" <ch...@gmail.com> wrote:
> 
> Hi,
> Today, I use org.apache.hadoop.net.NetUtils Class to change IP 
> address and hostname.
> normalizeHostName
> but I think the normalizeHostName didn't works well. The 
> Character.digit(name.charAt(0), 16) != -1
> couldn't tell whether it's a IP address or a hostname.
> 
> public static String normalizeHostName(String name) {
>    if (Character.digit(name.charAt(0), 16) != -1) { // it is an IP
>      return name;
>    } else {
>      try {
>        InetAddress ipAddress = InetAddress.getByName(name);
>        return ipAddress.getHostAddress();
>      } catch (UnknownHostException e) {
>        return name;
>      }
>    }
>  }
> The version of hadoop is 0.21.0
> http://svn.apache.org/repos/asf/hadoop/common/tags/release-
> 0.21.0/common/src/java/org/apache/hadoop/net/NetUtils.javazhendong
> 
> 

Re: Problem in NetUtils

Posted by Kihwal Lee <ki...@yahoo-inc.com>.
0.21 is not actively maintained.
The bug was fixed in other active branches (0.20-security, 0.22, 0.23, etc.) and trunk.

Kihwal

On 10/12/11 7:50 PM, "Beckham007" <ch...@gmail.com> wrote:

Hi,
Today, I use org.apache.hadoop.net.NetUtils Class to change IP address and hostname.
 normalizeHostName
but I think the normalizeHostName didn't works well. The Character.digit(name.charAt(0), 16) != -1
couldn't tell whether it's a IP address or a hostname.

public static String normalizeHostName(String name) {
    if (Character.digit(name.charAt(0), 16) != -1) { // it is an IP
      return name;
    } else {
      try {
        InetAddress ipAddress = InetAddress.getByName(name);
        return ipAddress.getHostAddress();
      } catch (UnknownHostException e) {
        return name;
      }
    }
  }
The version of hadoop is 0.21.0
http://svn.apache.org/repos/asf/hadoop/common/tags/release-0.21.0/common/src/java/org/apache/hadoop/net/NetUtils.java
zhendong