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

This commit is contained in:
Yiqun Lin 2017-10-11 14:00:12 +08:00 committed by Owen O'Malley
parent 9445a9267f
commit d19b4c8763
6 changed files with 14 additions and 11 deletions

View File

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

View File

@ -180,7 +180,7 @@ public class ChunkInputStream extends InputStream {
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();

View File

@ -151,7 +151,8 @@ public class ChunkOutputStream extends OutputStream {
}
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 @@ public class ChunkOutputStream extends OutputStream {
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);
}

View File

@ -99,7 +99,7 @@ public abstract class BucketProcessTemplate {
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 @@ public abstract class BucketProcessTemplate {
*/
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) {

View File

@ -94,9 +94,10 @@ public abstract class KeyProcessTemplate {
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 abstract class KeyProcessTemplate {
// 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);
}

View File

@ -97,7 +97,7 @@ public abstract class VolumeProcessTemplate {
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 class VolumeProcessTemplate {
*/
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 @@ public abstract class VolumeProcessTemplate {
exp.setMessage(fsExp.getMessage());
}
}
LOG.debug("IOException: {}", exp);
throw exp;
}