HDFS-2757. Cannot read a local block that's being written to when using the local read short circuit. Contributed by Jean-Daniel Cryans
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1382410 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c76e05c1b7
commit
bda287a486
|
@ -577,6 +577,9 @@ Release 2.0.2-alpha - 2012-09-07
|
||||||
(Andy Isaacson via eli)
|
(Andy Isaacson via eli)
|
||||||
|
|
||||||
HDFS-3895. hadoop-client must include commons-cli (tucu)
|
HDFS-3895. hadoop-client must include commons-cli (tucu)
|
||||||
|
|
||||||
|
HDFS-2757. Cannot read a local block that's being written to when
|
||||||
|
using the local read short circuit. (Jean-Daniel Cryans via eli)
|
||||||
|
|
||||||
BREAKDOWN OF HDFS-3042 SUBTASKS
|
BREAKDOWN OF HDFS-3042 SUBTASKS
|
||||||
|
|
||||||
|
|
|
@ -2112,10 +2112,7 @@ public class DFSClient implements java.io.Closeable {
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean shouldTryShortCircuitRead(InetSocketAddress targetAddr) {
|
boolean shouldTryShortCircuitRead(InetSocketAddress targetAddr) {
|
||||||
if (shortCircuitLocalReads && isLocalAddress(targetAddr)) {
|
return shortCircuitLocalReads && isLocalAddress(targetAddr);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void reportChecksumFailure(String file, ExtendedBlock blk, DatanodeInfo dn) {
|
void reportChecksumFailure(String file, ExtendedBlock blk, DatanodeInfo dn) {
|
||||||
|
|
|
@ -243,6 +243,10 @@ public class DFSInputStream extends FSInputStream implements ByteBufferReadable
|
||||||
locatedBlocks.getFileLength() + lastBlockBeingWrittenLength;
|
locatedBlocks.getFileLength() + lastBlockBeingWrittenLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private synchronized boolean blockUnderConstruction() {
|
||||||
|
return locatedBlocks.isUnderConstruction();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the datanode from which the stream is currently reading.
|
* Returns the datanode from which the stream is currently reading.
|
||||||
*/
|
*/
|
||||||
|
@ -878,7 +882,9 @@ public class DFSInputStream extends FSInputStream implements ByteBufferReadable
|
||||||
String clientName)
|
String clientName)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|
||||||
if (dfsClient.shouldTryShortCircuitRead(dnAddr)) {
|
// Can't local read a block under construction, see HDFS-2757
|
||||||
|
if (dfsClient.shouldTryShortCircuitRead(dnAddr) &&
|
||||||
|
!blockUnderConstruction()) {
|
||||||
return DFSClient.getLocalBlockReader(dfsClient.conf, src, block,
|
return DFSClient.getLocalBlockReader(dfsClient.conf, src, block,
|
||||||
blockToken, chosenNode, dfsClient.hdfsTimeout, startOffset,
|
blockToken, chosenNode, dfsClient.hdfsTimeout, startOffset,
|
||||||
dfsClient.connectToDnViaHostname());
|
dfsClient.connectToDnViaHostname());
|
||||||
|
|
Loading…
Reference in New Issue