svn merge -c 1565310 merging from trunk to branch-2 to fix: HDFS-5881. Fix skip() of the short-circuit local reader(legacy).

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1565313 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Kihwal Lee 2014-02-06 15:48:21 +00:00
parent ed2a0ec7f6
commit f56ff3b5ed
3 changed files with 13 additions and 3 deletions

View File

@ -51,6 +51,8 @@ Release 2.4.0 - UNRELEASED
HDFS-5709. Improve NameNode upgrade with existing reserved paths and path HDFS-5709. Improve NameNode upgrade with existing reserved paths and path
components. (Andrew Wang via atm) components. (Andrew Wang via atm)
HDFS-5881. Fix skip() of the short-circuit local reader(legacy). (kihwal)
Release 2.3.0 - UNRELEASED Release 2.3.0 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -629,7 +629,7 @@ class BlockReaderLocalLegacy implements BlockReader {
skipBuf = new byte[bytesPerChecksum]; skipBuf = new byte[bytesPerChecksum];
} }
int ret = read(skipBuf, 0, (int)(n - remaining)); int ret = read(skipBuf, 0, (int)(n - remaining));
return ret; return (remaining + ret);
} }
// optimize for big gap: discard the current buffer, skip to // optimize for big gap: discard the current buffer, skip to
@ -660,9 +660,9 @@ class BlockReaderLocalLegacy implements BlockReader {
int ret = read(skipBuf, 0, myOffsetFromChunkBoundary); int ret = read(skipBuf, 0, myOffsetFromChunkBoundary);
if (ret == -1) { // EOS if (ret == -1) { // EOS
return toskip; return (toskip + remaining);
} else { } else {
return (toskip + ret); return (toskip + remaining + ret);
} }
} }

View File

@ -1345,6 +1345,14 @@ implements ByteBufferReadable, CanSetDropBehind, CanSetReadahead,
pos += blockReader.skip(diff); pos += blockReader.skip(diff);
if (pos == targetPos) { if (pos == targetPos) {
done = true; done = true;
} else {
// The range was already checked. If the block reader returns
// something unexpected instead of throwing an exception, it is
// most likely a bug.
String errMsg = "BlockReader failed to seek to " +
targetPos + ". Instead, it seeked to " + pos + ".";
DFSClient.LOG.warn(errMsg);
throw new IOException(errMsg);
} }
} catch (IOException e) {//make following read to retry } catch (IOException e) {//make following read to retry
if(DFSClient.LOG.isDebugEnabled()) { if(DFSClient.LOG.isDebugEnabled()) {