From d19b4c87633d39bc4939a826f2a45f41287ff1ca Mon Sep 17 00:00:00 2001 From: Yiqun Lin Date: Wed, 11 Oct 2017 14:00:12 +0800 Subject: [PATCH] HDFS-12583. Ozone: Fix swallow exceptions which makes hard to debug failures. Contributed by Yiqun Lin. --- .../java/org/apache/hadoop/scm/XceiverClientManager.java | 3 ++- .../org/apache/hadoop/scm/storage/ChunkInputStream.java | 2 +- .../org/apache/hadoop/scm/storage/ChunkOutputStream.java | 6 ++++-- .../hadoop/ozone/web/handlers/BucketProcessTemplate.java | 4 ++-- .../hadoop/ozone/web/handlers/KeyProcessTemplate.java | 6 +++--- .../hadoop/ozone/web/handlers/VolumeProcessTemplate.java | 4 ++-- 6 files changed, 14 insertions(+), 11 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/scm/XceiverClientManager.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/scm/XceiverClientManager.java index 05e51187fc..af8d19c599 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/scm/XceiverClientManager.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/scm/XceiverClientManager.java @@ -156,7 +156,8 @@ public XceiverClientSpi call() throws Exception { } }); } catch (Exception e) { - throw new IOException("Exception getting XceiverClient.", e); + throw new IOException( + "Exception getting XceiverClient: " + e.toString(), e); } } diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/scm/storage/ChunkInputStream.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/scm/storage/ChunkInputStream.java index c690474991..26cef65634 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/scm/storage/ChunkInputStream.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/scm/storage/ChunkInputStream.java @@ -180,7 +180,7 @@ private synchronized void readChunkFromContainer(int readChunkOffset) readChunkResponse = ContainerProtocolCalls.readChunk(xceiverClient, chunks.get(readChunkOffset), key, traceID); } catch (IOException e) { - throw new IOException("Unexpected OzoneException", e); + throw new IOException("Unexpected OzoneException: " + e.toString(), e); } chunkOffset = readChunkOffset; ByteString byteString = readChunkResponse.getData(); diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/scm/storage/ChunkOutputStream.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/scm/storage/ChunkOutputStream.java index 8daded5e83..64c10dac88 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/scm/storage/ChunkOutputStream.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/scm/storage/ChunkOutputStream.java @@ -151,7 +151,8 @@ public synchronized void close() throws IOException { } putKey(xceiverClient, containerKeyData.build(), traceID); } catch (IOException e) { - throw new IOException("Unexpected Storage Container Exception", e); + throw new IOException( + "Unexpected Storage Container Exception: " + e.toString(), e); } finally { xceiverClientManager.releaseClient(xceiverClient); xceiverClientManager = null; @@ -218,7 +219,8 @@ private synchronized void writeChunkToContainer() throws IOException { try { writeChunk(xceiverClient, chunk, key, data, traceID); } catch (IOException e) { - throw new IOException("Unexpected Storage Container Exception", e); + throw new IOException( + "Unexpected Storage Container Exception: " + e.toString(), e); } containerKeyData.addChunks(chunk); } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/handlers/BucketProcessTemplate.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/handlers/BucketProcessTemplate.java index bba3bcd5c2..77a20a98cd 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/handlers/BucketProcessTemplate.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/handlers/BucketProcessTemplate.java @@ -99,7 +99,7 @@ public Response handleCall(String volume, String bucket, Request request, return response; } catch (IllegalArgumentException argEx) { - LOG.debug("Invalid bucket. ex:{}", argEx); + LOG.error("Invalid bucket. ex:{}", argEx); throw ErrorTable.newError(ErrorTable.INVALID_BUCKET_NAME, userArgs, argEx); } catch (IOException fsExp) { @@ -149,7 +149,7 @@ void getAclsFromHeaders(BucketArgs args, boolean parseRemoveACL) */ void handleIOException(String bucket, String reqID, String hostName, IOException fsExp) throws OzoneException { - LOG.debug("IOException: {}", fsExp); + LOG.error("IOException: {}", fsExp); OzoneException exp = null; if (fsExp instanceof FileAlreadyExistsException) { diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/handlers/KeyProcessTemplate.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/handlers/KeyProcessTemplate.java index a1a718eb24..69938484d8 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/handlers/KeyProcessTemplate.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/handlers/KeyProcessTemplate.java @@ -94,9 +94,10 @@ public Response handleCall(String volume, String bucket, String key, return response; } 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); } catch (IOException fsExp) { + LOG.error("IOException. ex : {}", fsExp); // Map KEY_NOT_FOUND to INVALID_KEY if (fsExp.getMessage().endsWith( KeySpaceManagerProtocolProtos.Status.KEY_NOT_FOUND.name())) { @@ -105,10 +106,9 @@ public Response handleCall(String volume, String bucket, String key, // TODO : Handle errors from the FileSystem , let us map to server error // for now. - LOG.debug("IOException. ex : {}", fsExp); throw ErrorTable.newError(ErrorTable.SERVER_ERROR, userArgs, fsExp); } catch (NoSuchAlgorithmException algoEx) { - LOG.debug("NoSuchAlgorithmException. Probably indicates an unusual java " + LOG.error("NoSuchAlgorithmException. Probably indicates an unusual java " + "installation. ex : {}", algoEx); throw ErrorTable.newError(SERVER_ERROR, userArgs, algoEx); } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/handlers/VolumeProcessTemplate.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/handlers/VolumeProcessTemplate.java index 9bd8aa97bb..f70d8dcc80 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/handlers/VolumeProcessTemplate.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/handlers/VolumeProcessTemplate.java @@ -97,7 +97,7 @@ public Response handleCall(String volume, Request request, UriInfo info, return response; } catch (IllegalArgumentException ex) { - LOG.debug("illegal argument. {}", ex); + LOG.error("illegal argument. {}", ex); throw ErrorTable.newError(ErrorTable.INVALID_VOLUME_NAME, userArgs, ex); } catch (IOException ex) { handleIOException(volume, reqID, hostName, ex); @@ -130,6 +130,7 @@ public abstract Response doProcess(VolumeArgs args) */ private void handleIOException(String volume, String reqID, String hostName, IOException fsExp) throws OzoneException { + LOG.error("IOException: {}", fsExp); OzoneException exp = null; if ((fsExp != null && fsExp.getMessage().endsWith( @@ -161,7 +162,6 @@ private void handleIOException(String volume, String reqID, String hostName, exp.setMessage(fsExp.getMessage()); } } - LOG.debug("IOException: {}", exp); throw exp; }