HDFS-3342. SocketTimeoutException in BlockSender.sendChunks could have a better error message. Contributed by Yongjun Zhang.

(cherry picked from commit 16c0f04c50822a39610e34e0715d3d4a44be5a5f)
This commit is contained in:
Andrew Wang 2014-10-30 11:03:13 -07:00
parent 2b5baa6714
commit ec19c85e65
3 changed files with 19 additions and 7 deletions

View File

@ -67,6 +67,9 @@ Release 2.7.0 - UNRELEASED
HDFS-7280. Use netty 4 in WebImageViewer. (wheat9) HDFS-7280. Use netty 4 in WebImageViewer. (wheat9)
HDFS-3342. SocketTimeoutException in BlockSender.sendChunks could
have a better error message. (Yongjun Zhang via wang)
OPTIMIZATIONS OPTIMIZATIONS
BUG FIXES BUG FIXES

View File

@ -574,12 +574,9 @@ class BlockSender implements java.io.Closeable {
* writing to client timed out. This happens if the client reads * writing to client timed out. This happens if the client reads
* part of a block and then decides not to read the rest (but leaves * part of a block and then decides not to read the rest (but leaves
* the socket open). * the socket open).
*
* Reporting of this case is done in DataXceiver#run
*/ */
if (LOG.isTraceEnabled()) {
LOG.trace("Failed to send data:", e);
} else {
LOG.info("Failed to send data: " + e);
}
} else { } else {
/* Exception while writing to the client. Connection closure from /* Exception while writing to the client. Connection closure from
* the other end is mostly the case and we do not care much about * the other end is mostly the case and we do not care much about

View File

@ -39,6 +39,7 @@ import java.io.OutputStream;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.Socket; import java.net.Socket;
import java.net.SocketException; import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.nio.channels.ClosedChannelException; import java.nio.channels.ClosedChannelException;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.util.Arrays; import java.util.Arrays;
@ -240,6 +241,15 @@ class DataXceiver extends Receiver implements Runnable {
} else { } else {
LOG.info(s + "; " + t); LOG.info(s + "; " + t);
} }
} else if (op == Op.READ_BLOCK && t instanceof SocketTimeoutException) {
String s1 =
"Likely the client has stopped reading, disconnecting it";
s1 += " (" + s + ")";
if (LOG.isTraceEnabled()) {
LOG.trace(s1, t);
} else {
LOG.info(s1 + "; " + t);
}
} else { } else {
LOG.error(s, t); LOG.error(s, t);
} }
@ -520,9 +530,11 @@ class DataXceiver extends Receiver implements Runnable {
/* What exactly should we do here? /* What exactly should we do here?
* Earlier version shutdown() datanode if there is disk error. * Earlier version shutdown() datanode if there is disk error.
*/ */
LOG.warn(dnR + ":Got exception while serving " + block + " to " if (!(ioe instanceof SocketTimeoutException)) {
LOG.warn(dnR + ":Got exception while serving " + block + " to "
+ remoteAddress, ioe); + remoteAddress, ioe);
datanode.metrics.incrDatanodeNetworkErrors(); datanode.metrics.incrDatanodeNetworkErrors();
}
throw ioe; throw ioe;
} finally { } finally {
IOUtils.closeStream(blockSender); IOUtils.closeStream(blockSender);