HDFS-9576: HTrace: collect position/length information on read operations (zhz via cmccabe)
This commit is contained in:
parent
1425578690
commit
7905788db9
|
@ -2966,6 +2966,25 @@ public class DFSClient implements java.io.Closeable, RemotePeerFactory,
|
||||||
return scope;
|
return scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Full detailed tracing for read requests: path, position in the file,
|
||||||
|
* and length.
|
||||||
|
*
|
||||||
|
* @param reqLen requested length
|
||||||
|
*/
|
||||||
|
TraceScope newReaderTraceScope(String description, String path, long pos,
|
||||||
|
int reqLen) {
|
||||||
|
TraceScope scope = newPathTraceScope(description, path);
|
||||||
|
scope.addKVAnnotation("pos", Long.toString(pos));
|
||||||
|
scope.addKVAnnotation("reqLen", Integer.toString(reqLen));
|
||||||
|
return scope;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Add the returned length info to the scope. */
|
||||||
|
void addRetLenToReaderScope(TraceScope scope, int retLen) {
|
||||||
|
scope.addKVAnnotation("retLen", Integer.toString(retLen));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the erasure coding policy information for the specified path
|
* Get the erasure coding policy information for the specified path
|
||||||
*
|
*
|
||||||
|
|
|
@ -973,18 +973,29 @@ public class DFSInputStream extends FSInputStream
|
||||||
public synchronized int read(@Nonnull final byte buf[], int off, int len)
|
public synchronized int read(@Nonnull final byte buf[], int off, int len)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
ReaderStrategy byteArrayReader = new ByteArrayStrategy(buf);
|
ReaderStrategy byteArrayReader = new ByteArrayStrategy(buf);
|
||||||
try (TraceScope ignored =
|
try (TraceScope scope =
|
||||||
dfsClient.newPathTraceScope("DFSInputStream#byteArrayRead", src)) {
|
dfsClient.newReaderTraceScope("DFSInputStream#byteArrayRead",
|
||||||
return readWithStrategy(byteArrayReader, off, len);
|
src, getPos(), len)) {
|
||||||
|
int retLen = readWithStrategy(byteArrayReader, off, len);
|
||||||
|
if (retLen < len) {
|
||||||
|
dfsClient.addRetLenToReaderScope(scope, retLen);
|
||||||
|
}
|
||||||
|
return retLen;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized int read(final ByteBuffer buf) throws IOException {
|
public synchronized int read(final ByteBuffer buf) throws IOException {
|
||||||
ReaderStrategy byteBufferReader = new ByteBufferStrategy(buf);
|
ReaderStrategy byteBufferReader = new ByteBufferStrategy(buf);
|
||||||
try (TraceScope ignored =
|
int reqLen = buf.remaining();
|
||||||
dfsClient.newPathTraceScope("DFSInputStream#byteBufferRead", src)){
|
try (TraceScope scope =
|
||||||
return readWithStrategy(byteBufferReader, 0, buf.remaining());
|
dfsClient.newReaderTraceScope("DFSInputStream#byteBufferRead",
|
||||||
|
src, getPos(), reqLen)){
|
||||||
|
int retLen = readWithStrategy(byteBufferReader, 0, reqLen);
|
||||||
|
if (retLen < reqLen) {
|
||||||
|
dfsClient.addRetLenToReaderScope(scope, retLen);
|
||||||
|
}
|
||||||
|
return retLen;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1433,9 +1444,14 @@ public class DFSInputStream extends FSInputStream
|
||||||
@Override
|
@Override
|
||||||
public int read(long position, byte[] buffer, int offset, int length)
|
public int read(long position, byte[] buffer, int offset, int length)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
try (TraceScope ignored = dfsClient.
|
try (TraceScope scope = dfsClient.
|
||||||
newPathTraceScope("DFSInputStream#byteArrayPread", src)) {
|
newReaderTraceScope("DFSInputStream#byteArrayPread",
|
||||||
return pread(position, buffer, offset, length);
|
src, position, length)) {
|
||||||
|
int retLen = pread(position, buffer, offset, length);
|
||||||
|
if (retLen < length) {
|
||||||
|
dfsClient.addRetLenToReaderScope(scope, retLen);
|
||||||
|
}
|
||||||
|
return retLen;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -936,6 +936,9 @@ Release 2.9.0 - UNRELEASED
|
||||||
HDFS-9624. DataNode start slowly due to the initial DU command operations.
|
HDFS-9624. DataNode start slowly due to the initial DU command operations.
|
||||||
(Lin Yiqun via wang)
|
(Lin Yiqun via wang)
|
||||||
|
|
||||||
|
HDFS-9576: HTrace: collect position/length information on read operations
|
||||||
|
(zhz via cmccabe)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
BUG FIXES
|
BUG FIXES
|
||||||
|
|
Loading…
Reference in New Issue