You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ka...@apache.org on 2016/01/25 18:25:48 UTC

[13/50] [abbrv] hadoop git commit: HDFS-9634. webhdfs client side exceptions don't provide enough details. Contributed by Eric Payne.

HDFS-9634. webhdfs client side exceptions don't provide enough details. Contributed by Eric Payne.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/3616c7b8
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/3616c7b8
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/3616c7b8

Branch: refs/heads/YARN-1011
Commit: 3616c7b855962014750a3259a64c6e2a147da884
Parents: 446987e
Author: Kihwal Lee <ki...@apache.org>
Authored: Wed Jan 20 13:18:25 2016 -0600
Committer: Kihwal Lee <ki...@apache.org>
Committed: Thu Jan 21 09:32:57 2016 -0600

----------------------------------------------------------------------
 .../apache/hadoop/hdfs/web/WebHdfsFileSystem.java  | 17 ++++++++++++++++-
 hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt        |  3 +++
 .../hadoop/hdfs/web/TestWebHdfsTimeouts.java       | 14 +++++++-------
 3 files changed, 26 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/3616c7b8/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java
index 1fa95c2..f9c2c6e 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java
@@ -24,6 +24,7 @@ import java.io.EOFException;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
 import java.net.HttpURLConnection;
 import java.net.InetSocketAddress;
 import java.net.MalformedURLException;
@@ -502,6 +503,7 @@ public class WebHdfsFileSystem extends FileSystem
         new ExcludeDatanodesParam("");
 
     private boolean checkRetry;
+    private String redirectHost;
 
     protected AbstractRunner(final HttpOpParam.Op op, boolean redirected) {
       this.op = op;
@@ -553,7 +555,7 @@ public class WebHdfsFileSystem extends FileSystem
      */
     protected HttpURLConnection connect(URL url) throws IOException {
       //redirect hostname and port
-      String redirectHost = null;
+      redirectHost = null;
 
 
       // resolve redirects for a DN operation unless already resolved
@@ -658,6 +660,19 @@ public class WebHdfsFileSystem extends FileSystem
             throw it;
           }
         } catch (IOException ioe) {
+          // Attempt to include the redirected node in the exception. If the
+          // attempt to recreate the exception fails, just use the original.
+          String node = redirectHost;
+          if (node == null) {
+            node = url.getAuthority();
+          }
+          try {
+              ioe = ioe.getClass().getConstructor(String.class)
+                    .newInstance(node + ": " + ioe.getMessage());
+          } catch (NoSuchMethodException | SecurityException 
+                   | InstantiationException | IllegalAccessException
+                   | IllegalArgumentException | InvocationTargetException e) {
+          }
           shouldRetry(ioe, retry);
         }
       }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/3616c7b8/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
index f1e6bdc..f41537e 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
+++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
@@ -2624,6 +2624,9 @@ Release 2.7.3 - UNRELEASED
     HDFS-9569. Log the name of the fsimage being loaded for better
     supportability. (Yongjun Zhang)
 
+    HDFS-9634. webhdfs client side exceptions don't provide enough details
+    (Eric Payne via kihwal)
+
   OPTIMIZATIONS
 
   BUG FIXES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/3616c7b8/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsTimeouts.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsTimeouts.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsTimeouts.java
index bd4d693..3a87d42 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsTimeouts.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsTimeouts.java
@@ -115,7 +115,7 @@ public class TestWebHdfsTimeouts {
       fs.listFiles(new Path("/"), false);
       fail("expected timeout");
     } catch (SocketTimeoutException e) {
-      assertEquals("connect timed out", e.getMessage());
+      assertEquals(fs.getUri().getAuthority() + ": connect timed out", e.getMessage());
     }
   }
 
@@ -128,7 +128,7 @@ public class TestWebHdfsTimeouts {
       fs.listFiles(new Path("/"), false);
       fail("expected timeout");
     } catch (SocketTimeoutException e) {
-      assertEquals("Read timed out", e.getMessage());
+      assertEquals(fs.getUri().getAuthority() + ": Read timed out", e.getMessage());
     }
   }
 
@@ -143,7 +143,7 @@ public class TestWebHdfsTimeouts {
       fs.getDelegationToken("renewer");
       fail("expected timeout");
     } catch (SocketTimeoutException e) {
-      assertEquals("connect timed out", e.getMessage());
+      assertEquals(fs.getUri().getAuthority() + ": connect timed out", e.getMessage());
     }
   }
 
@@ -157,7 +157,7 @@ public class TestWebHdfsTimeouts {
       fs.getDelegationToken("renewer");
       fail("expected timeout");
     } catch (SocketTimeoutException e) {
-      assertEquals("Read timed out", e.getMessage());
+      assertEquals(fs.getUri().getAuthority() + ": Read timed out", e.getMessage());
     }
   }
 
@@ -172,7 +172,7 @@ public class TestWebHdfsTimeouts {
       fs.getFileChecksum(new Path("/file"));
       fail("expected timeout");
     } catch (SocketTimeoutException e) {
-      assertEquals("connect timed out", e.getMessage());
+      assertEquals(fs.getUri().getAuthority() + ": connect timed out", e.getMessage());
     }
   }
 
@@ -187,7 +187,7 @@ public class TestWebHdfsTimeouts {
       fs.getFileChecksum(new Path("/file"));
       fail("expected timeout");
     } catch (SocketTimeoutException e) {
-      assertEquals("Read timed out", e.getMessage());
+      assertEquals(fs.getUri().getAuthority() + ": Read timed out", e.getMessage());
     }
   }
 
@@ -203,7 +203,7 @@ public class TestWebHdfsTimeouts {
       os = fs.create(new Path("/file"));
       fail("expected timeout");
     } catch (SocketTimeoutException e) {
-      assertEquals("connect timed out", e.getMessage());
+      assertEquals(fs.getUri().getAuthority() + ": connect timed out", e.getMessage());
     } finally {
       IOUtils.cleanup(LOG, os);
     }