hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omal...@apache.org
Subject svn commit: r1076992 - in /hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs: HftpFileSystem.java HsftpFileSystem.java
Date Fri, 04 Mar 2011 03:28:41 GMT
Author: omalley
Date: Fri Mar  4 03:28:41 2011
New Revision: 1076992

URL: http://svn.apache.org/viewvc?rev=1076992&view=rev
Log:
commit 20a207b2cca1a68e148fc20f8f2b7257dc2700bf
Author: Jitendra Nath Pandey <jitendra@yahoo-inc.com>
Date:   Thu Sep 3 10:54:21 2009 -0700

    Merged from jira Hadoop-5363.
    Removed pickOneAddress function.

Modified:
    hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/HftpFileSystem.java
    hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/HsftpFileSystem.java

Modified: hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/HftpFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/HftpFileSystem.java?rev=1076992&r1=1076991&r2=1076992&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/HftpFileSystem.java
(original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/HftpFileSystem.java
Fri Mar  4 03:28:41 2011
@@ -28,7 +28,6 @@ import java.net.InetSocketAddress;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
-import java.net.UnknownHostException;
 
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
@@ -76,7 +75,6 @@ public class HftpFileSystem extends File
 
   protected InetSocketAddress nnAddr;
   protected UserGroupInformation ugi; 
-  protected final Random ran = new Random();
 
   public static final String HFTP_TIMEZONE = "UTC";
   public static final String HFTP_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ssZ";
@@ -107,26 +105,15 @@ public class HftpFileSystem extends File
     nnAddr = NetUtils.createSocketAddr(name.toString());
   }
   
-  /** randomly pick one from all available IP addresses of a given hostname */
-  protected String pickOneAddress(String hostname) throws UnknownHostException {
-    if ("localhost".equals(hostname))
-      return hostname;
-    InetAddress[] addrs = InetAddress.getAllByName(hostname);
-    if (addrs.length > 1)
-      return addrs[ran.nextInt(addrs.length)].getHostAddress();
-    return addrs[0].getHostAddress();
-  }
 
   @Override
   public URI getUri() {
     try {
-      return new URI("hftp", null, pickOneAddress(nnAddr.getHostName()), nnAddr.getPort(),
+      return new URI("hftp", null, nnAddr.getHostName(), nnAddr.getPort(),
                      null, null, null);
     } catch (URISyntaxException e) {
       return null;
-    } catch (UnknownHostException e) {
-      return null;
-    }
+    } 
   }
 
   /**
@@ -137,7 +124,7 @@ public class HftpFileSystem extends File
   protected HttpURLConnection openConnection(String path, String query)
       throws IOException {
     try {
-      final URL url = new URI("http", null, pickOneAddress(nnAddr.getHostName()),
+      final URL url = new URI("http", null, nnAddr.getHostName(),
           nnAddr.getPort(), path, query, null).toURL();
       if (LOG.isTraceEnabled()) {
         LOG.trace("url=" + url);

Modified: hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/HsftpFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/HsftpFileSystem.java?rev=1076992&r1=1076991&r2=1076992&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/HsftpFileSystem.java
(original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/HsftpFileSystem.java
Fri Mar  4 03:28:41 2011
@@ -23,7 +23,6 @@ import java.net.HttpURLConnection;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
-import java.net.UnknownHostException;
 import javax.net.ssl.HostnameVerifier;
 import javax.net.ssl.HttpsURLConnection;
 import javax.net.ssl.SSLSession;
@@ -69,7 +68,7 @@ public class HsftpFileSystem extends Hft
   protected HttpURLConnection openConnection(String path, String query)
       throws IOException {
     try {
-      final URL url = new URI("https", null, pickOneAddress(nnAddr.getHostName()),
+      final URL url = new URI("https", null, nnAddr.getHostName(),
           nnAddr.getPort(), path, query, null).toURL();
       HttpsURLConnection conn = (HttpsURLConnection)url.openConnection();
       // bypass hostname verification
@@ -83,13 +82,11 @@ public class HsftpFileSystem extends Hft
   @Override
   public URI getUri() {
     try {
-      return new URI("hsftp", null, pickOneAddress(nnAddr.getHostName()), nnAddr.getPort(),
+      return new URI("hsftp", null, nnAddr.getHostName(), nnAddr.getPort(),
                      null, null, null);
     } catch (URISyntaxException e) {
       return null;
-    } catch (UnknownHostException e) {
-      return null;
-    }
+    } 
   }
 
   /**



Mime
View raw message