فهرست منبع

HADOOP-3030. Release reserved space for file in InMemoryFileSystem if
checksum reservation fails. Contributed by Devaraj Das.



git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/trunk@638964 13f79535-47bb-0310-9956-ffa450edef68

Christopher Douglas 17 سال پیش
والد
کامیت
0fb0748760
2فایلهای تغییر یافته به همراه22 افزوده شده و 4 حذف شده
  1. 4 1
      CHANGES.txt
  2. 18 3
      src/java/org/apache/hadoop/fs/InMemoryFileSystem.java

+ 4 - 1
CHANGES.txt

@@ -279,7 +279,10 @@ Trunk (unreleased changes)
 
     HADOOP-3029. Datanode prints log message "firstbadlink" only if 
     it detects a bad connection to another datanode in the pipeline. (dhruba)
-    
+
+    HADOOP-3030. Release reserved space for file in InMemoryFileSystem if
+    checksum reservation fails. (Devaraj Das via cdouglas)
+
 Release 0.16.2 - Unreleased
 
   BUG FIXES

+ 18 - 3
src/java/org/apache/hadoop/fs/InMemoryFileSystem.java

@@ -319,6 +319,15 @@ public class InMemoryFileSystem extends ChecksumFileSystem {
         return true;
       }
     }
+    public void unreserveSpace(Path f) {
+      synchronized (this) {
+        FileAttributes fAttr = tempFileAttribs.remove(getPath(f));
+        if (fAttr != null) {
+          fAttr.data = null;
+          totalUsed -= fAttr.size;
+        }
+      }
+    }
   
     /** This API getClosedFiles could have been implemented over listPathsRaw
      * but it is an overhead to maintain directory structures for this impl of
@@ -416,11 +425,17 @@ public class InMemoryFileSystem extends ChecksumFileSystem {
    * false.
    */
   public boolean reserveSpaceWithCheckSum(Path f, long size) {
-    long checksumSize = getChecksumFileLength(f, size);
     RawInMemoryFileSystem mfs = (RawInMemoryFileSystem)getRawFileSystem();
     synchronized(mfs) {
-      return (mfs.reserveSpace(f, size) && 
-              mfs.reserveSpace(getChecksumFile(f), checksumSize)); 
+      boolean b = mfs.reserveSpace(f, size);
+      if (b) {
+        long checksumSize = getChecksumFileLength(f, size);
+        b = mfs.reserveSpace(getChecksumFile(f), checksumSize);
+        if (!b) {
+          mfs.unreserveSpace(f);
+        }
+      }
+      return b;
     }
   }