hadoop-hdfs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Beckham007 <chengzhendong...@gmail.com>
Subject Problem in NetUtils
Date Thu, 13 Oct 2011 00:50:43 GMT
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
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message