HDFS-6288. DFSInputStream Pread doesn't update ReadStatistics. Contributed by Juan Yu.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1590778 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3434d7b78b
commit
d0bff50fed
|
@ -160,6 +160,9 @@ Release 2.5.0 - UNRELEASED
|
||||||
HDFS-6218. Audit log should use true client IP for proxied webhdfs
|
HDFS-6218. Audit log should use true client IP for proxied webhdfs
|
||||||
operations. (daryn via kihwal)
|
operations. (daryn via kihwal)
|
||||||
|
|
||||||
|
HDFS-6288. DFSInputStream Pread doesn't update ReadStatistics.
|
||||||
|
(Juan Yu via wang)
|
||||||
|
|
||||||
Release 2.4.1 - UNRELEASED
|
Release 2.4.1 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -1038,6 +1038,8 @@ implements ByteBufferReadable, CanSetDropBehind, CanSetReadahead,
|
||||||
setConfiguration(dfsClient.getConfiguration()).
|
setConfiguration(dfsClient.getConfiguration()).
|
||||||
build();
|
build();
|
||||||
int nread = reader.readAll(buf, offset, len);
|
int nread = reader.readAll(buf, offset, len);
|
||||||
|
updateReadStatistics(readStatistics, nread, reader);
|
||||||
|
|
||||||
if (nread != len) {
|
if (nread != len) {
|
||||||
throw new IOException("truncated return from reader.read(): " +
|
throw new IOException("truncated return from reader.read(): " +
|
||||||
"excpected " + len + ", got " + nread);
|
"excpected " + len + ", got " + nread);
|
||||||
|
|
|
@ -94,11 +94,25 @@ public class TestPread {
|
||||||
private void doPread(FSDataInputStream stm, long position, byte[] buffer,
|
private void doPread(FSDataInputStream stm, long position, byte[] buffer,
|
||||||
int offset, int length) throws IOException {
|
int offset, int length) throws IOException {
|
||||||
int nread = 0;
|
int nread = 0;
|
||||||
|
long totalRead = 0;
|
||||||
|
DFSInputStream dfstm = null;
|
||||||
|
|
||||||
|
if (stm.getWrappedStream() instanceof DFSInputStream) {
|
||||||
|
dfstm = (DFSInputStream) (stm.getWrappedStream());
|
||||||
|
totalRead = dfstm.getReadStatistics().getTotalBytesRead();
|
||||||
|
}
|
||||||
|
|
||||||
while (nread < length) {
|
while (nread < length) {
|
||||||
int nbytes = stm.read(position+nread, buffer, offset+nread, length-nread);
|
int nbytes =
|
||||||
|
stm.read(position + nread, buffer, offset + nread, length - nread);
|
||||||
assertTrue("Error in pread", nbytes > 0);
|
assertTrue("Error in pread", nbytes > 0);
|
||||||
nread += nbytes;
|
nread += nbytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dfstm != null) {
|
||||||
|
assertEquals("Expected read statistic to be incremented", length, dfstm
|
||||||
|
.getReadStatistics().getTotalBytesRead() - totalRead);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pReadFile(FileSystem fileSys, Path name) throws IOException {
|
private void pReadFile(FileSystem fileSys, Path name) throws IOException {
|
||||||
|
|
Loading…
Reference in New Issue