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 ww...@apache.org on 2017/09/20 02:47:42 UTC

hadoop git commit: HDFS-12489. Ozone: OzoneRestClientException swallows exceptions which makes client hard to debug failures. Contributed by Weiwei Yang.

Repository: hadoop
Updated Branches:
  refs/heads/HDFS-7240 68f7cc620 -> 14e184a28


HDFS-12489. Ozone: OzoneRestClientException swallows exceptions which makes client hard to debug failures. Contributed by Weiwei Yang.


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

Branch: refs/heads/HDFS-7240
Commit: 14e184a2839c48ac671dc28773e3e2b81067f66d
Parents: 68f7cc6
Author: Weiwei Yang <ww...@apache.org>
Authored: Wed Sep 20 10:42:58 2017 +0800
Committer: Weiwei Yang <ww...@apache.org>
Committed: Wed Sep 20 10:42:58 2017 +0800

----------------------------------------------------------------------
 .../hadoop/ozone/web/client/OzoneBucket.java    | 12 ++++++------
 .../ozone/web/client/OzoneRestClient.java       | 20 ++++++++++----------
 .../web/client/OzoneRestClientException.java    | 10 ++++++++++
 .../hadoop/ozone/web/client/OzoneVolume.java    | 12 ++++++------
 .../ozone/web/exceptions/OzoneException.java    | 19 ++++++++++++++++++-
 .../apache/hadoop/ozone/web/ozShell/Shell.java  |  1 +
 6 files changed, 51 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/14e184a2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/client/OzoneBucket.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/client/OzoneBucket.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/client/OzoneBucket.java
index a83a720..734a386 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/client/OzoneBucket.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/client/OzoneBucket.java
@@ -190,7 +190,7 @@ public class OzoneBucket {
       }
       executePutKey(putRequest, httpClient);
     } catch (IOException | URISyntaxException ex) {
-      throw new OzoneRestClientException(ex.getMessage());
+      throw new OzoneRestClientException(ex.getMessage(), ex);
     } finally {
       IOUtils.closeStream(is);
       OzoneClientUtils.releaseConnection(putRequest);
@@ -321,7 +321,7 @@ public class OzoneBucket {
       executeGetKey(getRequest, httpClient, outPutFile);
       outPutFile.flush();
     } catch (IOException | URISyntaxException ex) {
-      throw new OzoneRestClientException(ex.getMessage());
+      throw new OzoneRestClientException(ex.getMessage(), ex);
     } finally {
       IOUtils.closeStream(outPutFile);
       OzoneClientUtils.releaseConnection(getRequest);
@@ -355,7 +355,7 @@ public class OzoneBucket {
       executeGetKey(getRequest, httpClient, outPutStream);
       return outPutStream.toString(ENCODING_NAME);
     } catch (IOException | URISyntaxException ex) {
-      throw new OzoneRestClientException(ex.getMessage());
+      throw new OzoneRestClientException(ex.getMessage(), ex);
     } finally {
       IOUtils.closeStream(outPutStream);
       OzoneClientUtils.releaseConnection(getRequest);
@@ -422,7 +422,7 @@ public class OzoneBucket {
           .getClient().getHttpDelete(builder.toString());
       executeDeleteKey(deleteRequest, httpClient);
     } catch (IOException | URISyntaxException ex) {
-      throw new OzoneRestClientException(ex.getMessage());
+      throw new OzoneRestClientException(ex.getMessage(), ex);
     } finally {
       OzoneClientUtils.releaseConnection(deleteRequest);
     }
@@ -500,7 +500,7 @@ public class OzoneBucket {
       return executeListKeys(getRequest, httpClient);
 
     } catch (IOException | URISyntaxException e) {
-      throw new OzoneRestClientException(e.getMessage());
+      throw new OzoneRestClientException(e.getMessage(), e);
     } finally {
       OzoneClientUtils.releaseConnection(getRequest);
     }
@@ -570,7 +570,7 @@ public class OzoneBucket {
       getRequest = client.getHttpGet(builder.toString());
       return executeGetKeyInfo(getRequest, httpClient);
     } catch (IOException | URISyntaxException e) {
-      throw new OzoneRestClientException(e.getMessage());
+      throw new OzoneRestClientException(e.getMessage(), e);
     } finally {
       OzoneClientUtils.releaseConnection(getRequest);
     }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/14e184a2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/client/OzoneRestClient.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/client/OzoneRestClient.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/client/OzoneRestClient.java
index df8b782..c81cefb 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/client/OzoneRestClient.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/client/OzoneRestClient.java
@@ -167,7 +167,7 @@ public class OzoneRestClient implements Closeable {
       executeCreateVolume(httpPost, httpClient);
       return getVolume(volumeName);
     } catch (IOException | URISyntaxException | IllegalArgumentException ex) {
-      throw new OzoneRestClientException(ex.getMessage());
+      throw new OzoneRestClientException(ex.getMessage(), ex);
     } finally {
       OzoneClientUtils.releaseConnection(httpPost);
     }
@@ -194,7 +194,7 @@ public class OzoneRestClient implements Closeable {
       httpGet = getHttpGet(builder.toString());
       return executeInfoVolume(httpGet, httpClient);
     } catch (IOException | URISyntaxException | IllegalArgumentException ex) {
-      throw new OzoneRestClientException(ex.getMessage());
+      throw new OzoneRestClientException(ex.getMessage(), ex);
     } finally {
       OzoneClientUtils.releaseConnection(httpGet);
     }
@@ -245,7 +245,7 @@ public class OzoneRestClient implements Closeable {
       }
       return executeListVolume(httpGet, httpClient);
     } catch (IOException | URISyntaxException ex) {
-      throw new OzoneRestClientException(ex.getMessage());
+      throw new OzoneRestClientException(ex.getMessage(), ex);
     } finally {
       OzoneClientUtils.releaseConnection(httpGet);
     }
@@ -327,7 +327,7 @@ public class OzoneRestClient implements Closeable {
       return executeListVolume(httpGet, httpClient);
 
     } catch (IOException | URISyntaxException ex) {
-      throw new OzoneRestClientException(ex.getMessage());
+      throw new OzoneRestClientException(ex.getMessage(), ex);
     } finally {
       OzoneClientUtils.releaseConnection(httpGet);
     }
@@ -349,7 +349,7 @@ public class OzoneRestClient implements Closeable {
       httpDelete = getHttpDelete(builder.toString());
       executeDeleteVolume(httpDelete, httpClient);
     } catch (IOException | URISyntaxException | IllegalArgumentException ex) {
-      throw new OzoneRestClientException(ex.getMessage());
+      throw new OzoneRestClientException(ex.getMessage(), ex);
     } finally {
       OzoneClientUtils.releaseConnection(httpDelete);
     }
@@ -378,7 +378,7 @@ public class OzoneRestClient implements Closeable {
       executePutVolume(putRequest, httpClient);
 
     } catch (URISyntaxException | IllegalArgumentException | IOException ex) {
-      throw new OzoneRestClientException(ex.getMessage());
+      throw new OzoneRestClientException(ex.getMessage(), ex);
     } finally {
       OzoneClientUtils.releaseConnection(putRequest);
     }
@@ -411,7 +411,7 @@ public class OzoneRestClient implements Closeable {
       executePutVolume(putRequest, httpClient);
 
     } catch (URISyntaxException | IllegalArgumentException | IOException ex) {
-      throw new OzoneRestClientException(ex.getMessage());
+      throw new OzoneRestClientException(ex.getMessage(), ex);
     } finally {
       OzoneClientUtils.releaseConnection(putRequest);
     }
@@ -617,7 +617,7 @@ public class OzoneRestClient implements Closeable {
       putRequest.setHeader(Header.CONTENT_MD5, DigestUtils.md5Hex(fis));
       OzoneBucket.executePutKey(putRequest, httpClient);
     } catch (IOException | URISyntaxException ex) {
-      throw new OzoneRestClientException(ex.getMessage());
+      throw new OzoneRestClientException(ex.getMessage(), ex);
     } finally {
       IOUtils.closeStream(fis);
       OzoneClientUtils.releaseConnection(putRequest);
@@ -659,7 +659,7 @@ public class OzoneRestClient implements Closeable {
       OzoneBucket.executeGetKey(getRequest, httpClient, outPutFile);
       outPutFile.flush();
     } catch (IOException | URISyntaxException ex) {
-      throw new OzoneRestClientException(ex.getMessage());
+      throw new OzoneRestClientException(ex.getMessage(), ex);
     } finally {
       IOUtils.closeStream(outPutFile);
       OzoneClientUtils.releaseConnection(getRequest);
@@ -704,7 +704,7 @@ public class OzoneRestClient implements Closeable {
       getRequest = getHttpGet(builder.toString());
       return OzoneBucket.executeListKeys(getRequest, httpClient);
     } catch (IOException | URISyntaxException e) {
-      throw new OzoneRestClientException(e.getMessage());
+      throw new OzoneRestClientException(e.getMessage(), e);
     } finally {
       OzoneClientUtils.releaseConnection(getRequest);
     }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/14e184a2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/client/OzoneRestClientException.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/client/OzoneRestClientException.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/client/OzoneRestClientException.java
index 5017982..15cfffa 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/client/OzoneRestClientException.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/client/OzoneRestClientException.java
@@ -33,6 +33,16 @@ public class OzoneRestClientException extends OzoneException {
   }
 
   /**
+   * Constructor that allows a shortMessage and an exception.
+   *
+   * @param shortMessage short message
+   * @param ex exception
+   */
+  public OzoneRestClientException(String shortMessage, Exception ex) {
+    super(0, shortMessage, shortMessage, ex);
+  }
+
+  /**
    * Constructor that allows the shortMessage and a longer message.
    *
    * @param shortMessage Short Message

http://git-wip-us.apache.org/repos/asf/hadoop/blob/14e184a2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/client/OzoneVolume.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/client/OzoneVolume.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/client/OzoneVolume.java
index 82a2f09..8f6db95 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/client/OzoneVolume.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/client/OzoneVolume.java
@@ -201,7 +201,7 @@ public class OzoneVolume {
       executeCreateBucket(httpPost, httpClient);
       return getBucket(bucketName);
     } catch (IOException | URISyntaxException | IllegalArgumentException ex) {
-      throw new OzoneRestClientException(ex.getMessage());
+      throw new OzoneRestClientException(ex.getMessage(), ex);
     } finally {
       OzoneClientUtils.releaseConnection(httpPost);
     }
@@ -305,7 +305,7 @@ public class OzoneVolume {
       }
       executePutBucket(putRequest, httpClient);
     } catch (URISyntaxException | IOException ex) {
-      throw new OzoneRestClientException(ex.getMessage());
+      throw new OzoneRestClientException(ex.getMessage(), ex);
     } finally {
       OzoneClientUtils.releaseConnection(putRequest);
     }
@@ -334,7 +334,7 @@ public class OzoneVolume {
       }
       executePutBucket(putRequest, httpClient);
     } catch (URISyntaxException | IOException ex) {
-      throw new OzoneRestClientException(ex.getMessage());
+      throw new OzoneRestClientException(ex.getMessage(), ex);
     } finally {
       OzoneClientUtils.releaseConnection(putRequest);
     }
@@ -359,7 +359,7 @@ public class OzoneVolume {
       return executeInfoBucket(getRequest, httpClient);
 
     } catch (IOException | URISyntaxException | IllegalArgumentException ex) {
-      throw new OzoneRestClientException(ex.getMessage());
+      throw new OzoneRestClientException(ex.getMessage(), ex);
     } finally {
       OzoneClientUtils.releaseConnection(getRequest);
     }
@@ -465,7 +465,7 @@ public class OzoneVolume {
       return executeListBuckets(getRequest, httpClient);
 
     } catch (IOException | URISyntaxException e) {
-      throw new OzoneRestClientException(e.getMessage());
+      throw new OzoneRestClientException(e.getMessage(), e);
     } finally {
       OzoneClientUtils.releaseConnection(getRequest);
     }
@@ -533,7 +533,7 @@ public class OzoneVolume {
       executeDeleteBucket(delRequest, httpClient);
 
     } catch (IOException | URISyntaxException | IllegalArgumentException ex) {
-      throw new OzoneRestClientException(ex.getMessage());
+      throw new OzoneRestClientException(ex.getMessage(), ex);
     } finally {
       OzoneClientUtils.releaseConnection(delRequest);
     }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/14e184a2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/exceptions/OzoneException.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/exceptions/OzoneException.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/exceptions/OzoneException.java
index ea3abb0..a0b5184 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/exceptions/OzoneException.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/exceptions/OzoneException.java
@@ -34,6 +34,7 @@ import com.fasterxml.jackson.databind.ObjectReader;
  */
 @InterfaceAudience.Private
 public class OzoneException extends Exception {
+
   private static final ObjectReader READER =
       new ObjectMapper().readerFor(OzoneException.class);
   private static final ObjectMapper MAPPER;
@@ -113,7 +114,23 @@ public class OzoneException extends Exception {
   }
 
   /**
-   * Returns the Resource that was involved in the exception.
+   * Constructor that allows a shortMessage, a long message and an exception.
+   *
+   * @param httpCode Error code
+   * @param shortMessage Short message
+   * @param message Long error message
+   * @param ex Exception
+   */
+  public OzoneException(long httpCode, String shortMessage,
+      String message, Exception ex) {
+    super(ex);
+    this.shortMessage = shortMessage;
+    this.message = message;
+    this.httpCode = httpCode;
+  }
+
+  /**
+   * Returns the Resource that was involved in the stackTraceString.
    *
    * @return String
    */

http://git-wip-us.apache.org/repos/asf/hadoop/blob/14e184a2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/ozShell/Shell.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/ozShell/Shell.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/ozShell/Shell.java
index a9d46f9..0cde920 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/ozShell/Shell.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/ozShell/Shell.java
@@ -402,6 +402,7 @@ public class Shell extends Configured implements Tool {
       System.err.printf("Command Failed : %s%n", ex.getMessage());
     } catch (OzoneException ex) {
       System.err.printf("Command Failed : %s%n", ex.toJsonString());
+      ex.printStackTrace(System.err);
     } catch (IllegalArgumentException ex) {
       System.err.printf("Illegal argument: %s%n", ex.getMessage());
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org