Przeglądaj źródła

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
Todd Lipcon 13 lat temu
rodzic
commit
66de48a353

+ 3 - 0
hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt

@@ -761,6 +761,9 @@ Release 0.23.0 - Unreleased
 
     HDFS-2118. Couple dfs data dir improvements. (eli)
 
+    HDFS-2500. Avoid file system operations in BPOfferService thread while
+    processing deletes. (todd)
+
   BUG FIXES
 
     HDFS-2344. Fix the TestOfflineEditsViewer test failure in 0.23 branch.

+ 7 - 0
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java

@@ -1108,8 +1108,15 @@ public class DataNode extends Configured
             if (!heartbeatsDisabledForTests) {
               DatanodeCommand[] cmds = sendHeartBeat();
               metrics.addHeartbeat(now() - startTime);
+
+              long startProcessCommands = now();
               if (!processCommand(cmds))
                 continue;
+              long endProcessCommands = now();
+              if (endProcessCommands - startProcessCommands > 2000) {
+                LOG.info("Took " + (endProcessCommands - startProcessCommands) +
+                    "ms to process " + cmds.length + " commands from NN");
+              }
             }
           }
 

+ 1 - 2
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/FSDataset.java

@@ -2088,10 +2088,9 @@ public class FSDataset implements FSDatasetInterface {
         volumeMap.remove(bpid, invalidBlks[i]);
       }
       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
-      asyncDiskService.deleteAsync(v, bpid, f, metaFile, dfsBytes,
+      asyncDiskService.deleteAsync(v, bpid, f, metaFile,
           invalidBlks[i].toString());
     }
     if (error) {

+ 4 - 5
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/FSDatasetAsyncDiskService.java

@@ -148,11 +148,11 @@ class FSDatasetAsyncDiskService {
    * dfsUsed statistics accordingly.
    */
   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
         + " for deletion");
     ReplicaFileDeleteTask deletionTask = 
-        new ReplicaFileDeleteTask(volume, bpid, blockFile, metaFile, dfsBytes,
+        new ReplicaFileDeleteTask(volume, bpid, blockFile, metaFile,
             blockName);
     execute(volume.getCurrentDir(), deletionTask);
   }
@@ -165,16 +165,14 @@ class FSDatasetAsyncDiskService {
     final String blockPoolId;
     final File blockFile;
     final File metaFile;
-    final long dfsBytes;
     final String blockName;
     
     ReplicaFileDeleteTask(FSDataset.FSVolume volume, String bpid,
-        File blockFile, File metaFile, long dfsBytes, String blockName) {
+        File blockFile, File metaFile, String blockName) {
       this.volume = volume;
       this.blockPoolId = bpid;
       this.blockFile = blockFile;
       this.metaFile = metaFile;
-      this.dfsBytes = dfsBytes;
       this.blockName = blockName;
     }
     
@@ -192,6 +190,7 @@ class FSDatasetAsyncDiskService {
 
     @Override
     public void run() {
+      long dfsBytes = blockFile.length() + metaFile.length();
       if ( !blockFile.delete() || ( !metaFile.delete() && metaFile.exists() ) ) {
         DataNode.LOG.warn("Unexpected error trying to delete block "
             + blockPoolId + " " + blockName + " at file " + blockFile