Browse Source

HDFS-12583. Ozone: Fix swallow exceptions which makes hard to debug failures. Contributed by Yiqun Lin.

Yiqun Lin 7 years ago
parent
commit
d19b4c8763

+ 2 - 1
hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/scm/XceiverClientManager.java

@@ -156,7 +156,8 @@ public class XceiverClientManager implements Closeable {
           }
           }
         });
         });
     } catch (Exception e) {
     } catch (Exception e) {
-      throw new IOException("Exception getting XceiverClient.", e);
+      throw new IOException(
+          "Exception getting XceiverClient: " + e.toString(), e);
     }
     }
   }
   }
 
 

+ 1 - 1
hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/scm/storage/ChunkInputStream.java

@@ -180,7 +180,7 @@ public class ChunkInputStream extends InputStream {
       readChunkResponse = ContainerProtocolCalls.readChunk(xceiverClient,
       readChunkResponse = ContainerProtocolCalls.readChunk(xceiverClient,
           chunks.get(readChunkOffset), key, traceID);
           chunks.get(readChunkOffset), key, traceID);
     } catch (IOException e) {
     } catch (IOException e) {
-      throw new IOException("Unexpected OzoneException", e);
+      throw new IOException("Unexpected OzoneException: " + e.toString(), e);
     }
     }
     chunkOffset = readChunkOffset;
     chunkOffset = readChunkOffset;
     ByteString byteString = readChunkResponse.getData();
     ByteString byteString = readChunkResponse.getData();

+ 4 - 2
hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/scm/storage/ChunkOutputStream.java

@@ -151,7 +151,8 @@ public class ChunkOutputStream extends OutputStream {
         }
         }
         putKey(xceiverClient, containerKeyData.build(), traceID);
         putKey(xceiverClient, containerKeyData.build(), traceID);
       } catch (IOException e) {
       } catch (IOException e) {
-        throw new IOException("Unexpected Storage Container Exception", e);
+        throw new IOException(
+            "Unexpected Storage Container Exception: " + e.toString(), e);
       } finally {
       } finally {
         xceiverClientManager.releaseClient(xceiverClient);
         xceiverClientManager.releaseClient(xceiverClient);
         xceiverClientManager = null;
         xceiverClientManager = null;
@@ -218,7 +219,8 @@ public class ChunkOutputStream extends OutputStream {
     try {
     try {
       writeChunk(xceiverClient, chunk, key, data, traceID);
       writeChunk(xceiverClient, chunk, key, data, traceID);
     } catch (IOException e) {
     } catch (IOException e) {
-      throw new IOException("Unexpected Storage Container Exception", e);
+      throw new IOException(
+          "Unexpected Storage Container Exception: " + e.toString(), e);
     }
     }
     containerKeyData.addChunks(chunk);
     containerKeyData.addChunks(chunk);
   }
   }

+ 2 - 2
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/handlers/BucketProcessTemplate.java

@@ -99,7 +99,7 @@ public abstract class BucketProcessTemplate {
       return response;
       return response;
 
 
     } catch (IllegalArgumentException argEx) {
     } catch (IllegalArgumentException argEx) {
-      LOG.debug("Invalid bucket. ex:{}", argEx);
+      LOG.error("Invalid bucket. ex:{}", argEx);
       throw ErrorTable.newError(ErrorTable.INVALID_BUCKET_NAME, userArgs,
       throw ErrorTable.newError(ErrorTable.INVALID_BUCKET_NAME, userArgs,
           argEx);
           argEx);
     } catch (IOException fsExp) {
     } catch (IOException fsExp) {
@@ -149,7 +149,7 @@ public abstract class BucketProcessTemplate {
    */
    */
   void handleIOException(String bucket, String reqID, String hostName,
   void handleIOException(String bucket, String reqID, String hostName,
                          IOException fsExp) throws OzoneException {
                          IOException fsExp) throws OzoneException {
-    LOG.debug("IOException: {}", fsExp);
+    LOG.error("IOException: {}", fsExp);
 
 
     OzoneException exp = null;
     OzoneException exp = null;
     if (fsExp instanceof FileAlreadyExistsException) {
     if (fsExp instanceof FileAlreadyExistsException) {

+ 3 - 3
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/handlers/KeyProcessTemplate.java

@@ -94,9 +94,10 @@ public abstract class KeyProcessTemplate {
       return response;
       return response;
 
 
     } catch (IllegalArgumentException argExp) {
     } catch (IllegalArgumentException argExp) {
-      LOG.debug("Invalid bucket in key call. ex:{}", argExp);
+      LOG.error("Invalid bucket in key call. ex:{}", argExp);
       throw newError(INVALID_BUCKET_NAME, userArgs, argExp);
       throw newError(INVALID_BUCKET_NAME, userArgs, argExp);
     } catch (IOException fsExp) {
     } catch (IOException fsExp) {
+      LOG.error("IOException. ex : {}", fsExp);
       // Map KEY_NOT_FOUND to INVALID_KEY
       // Map KEY_NOT_FOUND to INVALID_KEY
       if (fsExp.getMessage().endsWith(
       if (fsExp.getMessage().endsWith(
           KeySpaceManagerProtocolProtos.Status.KEY_NOT_FOUND.name())) {
           KeySpaceManagerProtocolProtos.Status.KEY_NOT_FOUND.name())) {
@@ -105,10 +106,9 @@ public abstract class KeyProcessTemplate {
 
 
       // TODO : Handle errors from the FileSystem , let us map to server error
       // TODO : Handle errors from the FileSystem , let us map to server error
       // for now.
       // for now.
-      LOG.debug("IOException. ex : {}", fsExp);
       throw ErrorTable.newError(ErrorTable.SERVER_ERROR, userArgs, fsExp);
       throw ErrorTable.newError(ErrorTable.SERVER_ERROR, userArgs, fsExp);
     } catch (NoSuchAlgorithmException algoEx) {
     } catch (NoSuchAlgorithmException algoEx) {
-      LOG.debug("NoSuchAlgorithmException. Probably indicates an unusual java "
+      LOG.error("NoSuchAlgorithmException. Probably indicates an unusual java "
           + "installation.  ex : {}", algoEx);
           + "installation.  ex : {}", algoEx);
       throw ErrorTable.newError(SERVER_ERROR, userArgs, algoEx);
       throw ErrorTable.newError(SERVER_ERROR, userArgs, algoEx);
     }
     }

+ 2 - 2
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/handlers/VolumeProcessTemplate.java

@@ -97,7 +97,7 @@ public abstract class VolumeProcessTemplate {
       return response;
       return response;
 
 
     } catch (IllegalArgumentException ex) {
     } catch (IllegalArgumentException ex) {
-      LOG.debug("illegal argument. {}", ex);
+      LOG.error("illegal argument. {}", ex);
       throw ErrorTable.newError(ErrorTable.INVALID_VOLUME_NAME, userArgs, ex);
       throw ErrorTable.newError(ErrorTable.INVALID_VOLUME_NAME, userArgs, ex);
     } catch (IOException ex) {
     } catch (IOException ex) {
       handleIOException(volume, reqID, hostName, ex);
       handleIOException(volume, reqID, hostName, ex);
@@ -130,6 +130,7 @@ public abstract class VolumeProcessTemplate {
    */
    */
   private void handleIOException(String volume, String reqID, String hostName,
   private void handleIOException(String volume, String reqID, String hostName,
                                  IOException fsExp) throws OzoneException {
                                  IOException fsExp) throws OzoneException {
+    LOG.error("IOException: {}", fsExp);
     OzoneException exp = null;
     OzoneException exp = null;
 
 
     if ((fsExp != null && fsExp.getMessage().endsWith(
     if ((fsExp != null && fsExp.getMessage().endsWith(
@@ -161,7 +162,6 @@ public abstract class VolumeProcessTemplate {
         exp.setMessage(fsExp.getMessage());
         exp.setMessage(fsExp.getMessage());
       }
       }
     }
     }
-    LOG.debug("IOException: {}", exp);
     throw exp;
     throw exp;
   }
   }