HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than DFSOutputStream#writeChunk (cmccabe)
(cherry picked from commit c94d594a57
)
This commit is contained in:
parent
6d0bebc912
commit
4b74aa7182
|
@ -21,6 +21,8 @@ package org.apache.hadoop.fs;
|
||||||
import org.apache.hadoop.classification.InterfaceAudience;
|
import org.apache.hadoop.classification.InterfaceAudience;
|
||||||
import org.apache.hadoop.classification.InterfaceStability;
|
import org.apache.hadoop.classification.InterfaceStability;
|
||||||
import org.apache.hadoop.util.DataChecksum;
|
import org.apache.hadoop.util.DataChecksum;
|
||||||
|
import org.apache.htrace.NullScope;
|
||||||
|
import org.apache.htrace.TraceScope;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
@ -194,16 +196,26 @@ abstract public class FSOutputSummer extends OutputStream {
|
||||||
return sum.getChecksumSize();
|
return sum.getChecksumSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected TraceScope createWriteTraceScope() {
|
||||||
|
return NullScope.INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
/** Generate checksums for the given data chunks and output chunks & checksums
|
/** Generate checksums for the given data chunks and output chunks & checksums
|
||||||
* to the underlying output stream.
|
* to the underlying output stream.
|
||||||
*/
|
*/
|
||||||
private void writeChecksumChunks(byte b[], int off, int len)
|
private void writeChecksumChunks(byte b[], int off, int len)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
sum.calculateChunkedSums(b, off, len, checksum, 0);
|
sum.calculateChunkedSums(b, off, len, checksum, 0);
|
||||||
for (int i = 0; i < len; i += sum.getBytesPerChecksum()) {
|
TraceScope scope = createWriteTraceScope();
|
||||||
int chunkLen = Math.min(sum.getBytesPerChecksum(), len - i);
|
try {
|
||||||
int ckOffset = i / sum.getBytesPerChecksum() * getChecksumSize();
|
for (int i = 0; i < len; i += sum.getBytesPerChecksum()) {
|
||||||
writeChunk(b, off + i, chunkLen, checksum, ckOffset, getChecksumSize());
|
int chunkLen = Math.min(sum.getBytesPerChecksum(), len - i);
|
||||||
|
int ckOffset = i / sum.getBytesPerChecksum() * getChecksumSize();
|
||||||
|
writeChunk(b, off + i, chunkLen, checksum, ckOffset,
|
||||||
|
getChecksumSize());
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
scope.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,9 @@ Release 2.8.0 - UNRELEASED
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
|
HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than
|
||||||
|
DFSOutputStream#writeChunk (cmccabe)
|
||||||
|
|
||||||
BUG FIXES
|
BUG FIXES
|
||||||
|
|
||||||
HDFS-7501. TransactionsSinceLastCheckpoint can be negative on SBNs.
|
HDFS-7501. TransactionsSinceLastCheckpoint can be negative on SBNs.
|
||||||
|
|
|
@ -372,21 +372,14 @@ public class DFSOutputStream extends FSOutputSummer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected TraceScope createWriteTraceScope() {
|
||||||
|
return dfsClient.getPathTraceScope("DFSOutputStream#write", src);
|
||||||
|
}
|
||||||
|
|
||||||
// @see FSOutputSummer#writeChunk()
|
// @see FSOutputSummer#writeChunk()
|
||||||
@Override
|
@Override
|
||||||
protected synchronized void writeChunk(byte[] b, int offset, int len,
|
protected synchronized void writeChunk(byte[] b, int offset, int len,
|
||||||
byte[] checksum, int ckoff, int cklen) throws IOException {
|
byte[] checksum, int ckoff, int cklen) throws IOException {
|
||||||
TraceScope scope =
|
|
||||||
dfsClient.getPathTraceScope("DFSOutputStream#writeChunk", src);
|
|
||||||
try {
|
|
||||||
writeChunkImpl(b, offset, len, checksum, ckoff, cklen);
|
|
||||||
} finally {
|
|
||||||
scope.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private synchronized void writeChunkImpl(byte[] b, int offset, int len,
|
|
||||||
byte[] checksum, int ckoff, int cklen) throws IOException {
|
|
||||||
dfsClient.checkOpen();
|
dfsClient.checkOpen();
|
||||||
checkClosed();
|
checkClosed();
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ public class TestTracing {
|
||||||
"org.apache.hadoop.hdfs.protocol.ClientProtocol.complete",
|
"org.apache.hadoop.hdfs.protocol.ClientProtocol.complete",
|
||||||
"ClientNamenodeProtocol#complete",
|
"ClientNamenodeProtocol#complete",
|
||||||
"newStreamForCreate",
|
"newStreamForCreate",
|
||||||
"DFSOutputStream#writeChunk",
|
"DFSOutputStream#write",
|
||||||
"DFSOutputStream#close",
|
"DFSOutputStream#close",
|
||||||
"dataStreamer",
|
"dataStreamer",
|
||||||
"OpWriteBlockProto",
|
"OpWriteBlockProto",
|
||||||
|
@ -117,7 +117,7 @@ public class TestTracing {
|
||||||
"org.apache.hadoop.hdfs.protocol.ClientProtocol.complete",
|
"org.apache.hadoop.hdfs.protocol.ClientProtocol.complete",
|
||||||
"ClientNamenodeProtocol#complete",
|
"ClientNamenodeProtocol#complete",
|
||||||
"newStreamForCreate",
|
"newStreamForCreate",
|
||||||
"DFSOutputStream#writeChunk",
|
"DFSOutputStream#write",
|
||||||
"DFSOutputStream#close",
|
"DFSOutputStream#close",
|
||||||
};
|
};
|
||||||
for (String desc : spansInTopTrace) {
|
for (String desc : spansInTopTrace) {
|
||||||
|
|
Loading…
Reference in New Issue