HDFS-2500. Avoid file system operations in BPOfferService thread while processing deletes. Contributed by Todd Lipcon.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.23@1190072 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cc5a75b521
commit
66de48a353
|
@ -761,6 +761,9 @@ Release 0.23.0 - Unreleased
|
||||||
|
|
||||||
HDFS-2118. Couple dfs data dir improvements. (eli)
|
HDFS-2118. Couple dfs data dir improvements. (eli)
|
||||||
|
|
||||||
|
HDFS-2500. Avoid file system operations in BPOfferService thread while
|
||||||
|
processing deletes. (todd)
|
||||||
|
|
||||||
BUG FIXES
|
BUG FIXES
|
||||||
|
|
||||||
HDFS-2344. Fix the TestOfflineEditsViewer test failure in 0.23 branch.
|
HDFS-2344. Fix the TestOfflineEditsViewer test failure in 0.23 branch.
|
||||||
|
|
|
@ -1108,8 +1108,15 @@ public class DataNode extends Configured
|
||||||
if (!heartbeatsDisabledForTests) {
|
if (!heartbeatsDisabledForTests) {
|
||||||
DatanodeCommand[] cmds = sendHeartBeat();
|
DatanodeCommand[] cmds = sendHeartBeat();
|
||||||
metrics.addHeartbeat(now() - startTime);
|
metrics.addHeartbeat(now() - startTime);
|
||||||
|
|
||||||
|
long startProcessCommands = now();
|
||||||
if (!processCommand(cmds))
|
if (!processCommand(cmds))
|
||||||
continue;
|
continue;
|
||||||
|
long endProcessCommands = now();
|
||||||
|
if (endProcessCommands - startProcessCommands > 2000) {
|
||||||
|
LOG.info("Took " + (endProcessCommands - startProcessCommands) +
|
||||||
|
"ms to process " + cmds.length + " commands from NN");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2088,10 +2088,9 @@ public class FSDataset implements FSDatasetInterface {
|
||||||
volumeMap.remove(bpid, invalidBlks[i]);
|
volumeMap.remove(bpid, invalidBlks[i]);
|
||||||
}
|
}
|
||||||
File metaFile = getMetaFile(f, invalidBlks[i].getGenerationStamp());
|
File metaFile = getMetaFile(f, invalidBlks[i].getGenerationStamp());
|
||||||
long dfsBytes = f.length() + metaFile.length();
|
|
||||||
|
|
||||||
// Delete the block asynchronously to make sure we can do it fast enough
|
// Delete the block asynchronously to make sure we can do it fast enough
|
||||||
asyncDiskService.deleteAsync(v, bpid, f, metaFile, dfsBytes,
|
asyncDiskService.deleteAsync(v, bpid, f, metaFile,
|
||||||
invalidBlks[i].toString());
|
invalidBlks[i].toString());
|
||||||
}
|
}
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|
|
@ -148,11 +148,11 @@ class FSDatasetAsyncDiskService {
|
||||||
* dfsUsed statistics accordingly.
|
* dfsUsed statistics accordingly.
|
||||||
*/
|
*/
|
||||||
void deleteAsync(FSDataset.FSVolume volume, String bpid, File blockFile,
|
void deleteAsync(FSDataset.FSVolume volume, String bpid, File blockFile,
|
||||||
File metaFile, long dfsBytes, String blockName) {
|
File metaFile, String blockName) {
|
||||||
DataNode.LOG.info("Scheduling block " + blockName + " file " + blockFile
|
DataNode.LOG.info("Scheduling block " + blockName + " file " + blockFile
|
||||||
+ " for deletion");
|
+ " for deletion");
|
||||||
ReplicaFileDeleteTask deletionTask =
|
ReplicaFileDeleteTask deletionTask =
|
||||||
new ReplicaFileDeleteTask(volume, bpid, blockFile, metaFile, dfsBytes,
|
new ReplicaFileDeleteTask(volume, bpid, blockFile, metaFile,
|
||||||
blockName);
|
blockName);
|
||||||
execute(volume.getCurrentDir(), deletionTask);
|
execute(volume.getCurrentDir(), deletionTask);
|
||||||
}
|
}
|
||||||
|
@ -165,16 +165,14 @@ class FSDatasetAsyncDiskService {
|
||||||
final String blockPoolId;
|
final String blockPoolId;
|
||||||
final File blockFile;
|
final File blockFile;
|
||||||
final File metaFile;
|
final File metaFile;
|
||||||
final long dfsBytes;
|
|
||||||
final String blockName;
|
final String blockName;
|
||||||
|
|
||||||
ReplicaFileDeleteTask(FSDataset.FSVolume volume, String bpid,
|
ReplicaFileDeleteTask(FSDataset.FSVolume volume, String bpid,
|
||||||
File blockFile, File metaFile, long dfsBytes, String blockName) {
|
File blockFile, File metaFile, String blockName) {
|
||||||
this.volume = volume;
|
this.volume = volume;
|
||||||
this.blockPoolId = bpid;
|
this.blockPoolId = bpid;
|
||||||
this.blockFile = blockFile;
|
this.blockFile = blockFile;
|
||||||
this.metaFile = metaFile;
|
this.metaFile = metaFile;
|
||||||
this.dfsBytes = dfsBytes;
|
|
||||||
this.blockName = blockName;
|
this.blockName = blockName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,6 +190,7 @@ class FSDatasetAsyncDiskService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
long dfsBytes = blockFile.length() + metaFile.length();
|
||||||
if ( !blockFile.delete() || ( !metaFile.delete() && metaFile.exists() ) ) {
|
if ( !blockFile.delete() || ( !metaFile.delete() && metaFile.exists() ) ) {
|
||||||
DataNode.LOG.warn("Unexpected error trying to delete block "
|
DataNode.LOG.warn("Unexpected error trying to delete block "
|
||||||
+ blockPoolId + " " + blockName + " at file " + blockFile
|
+ blockPoolId + " " + blockName + " at file " + blockFile
|
||||||
|
|
Loading…
Reference in New Issue