Browse Source

HADOOP-1997. TestCheckpoint closes the edits file after writing to it,
otherwise the rename of this file on Windows fails.
(Konstantin Shvachko via dhruba)



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

Dhruba Borthakur 18 years ago
parent
commit
c9a65ec940

+ 4 - 0
CHANGES.txt

@@ -381,6 +381,10 @@ Release 0.14.2 - unreleased
     HADOOP-1961.  The -get option to dfs-shell works when a single filename
     is specified.  (Raghu Angadi via dhruba)
 
+    HADOOP-1997.  TestCheckpoint closes the edits file after writing to it,
+    otherwise the rename of this file on Windows fails.
+    (Konstantin Shvachko via dhruba)
+
 Release 0.14.1 - 2007-09-04
 
   BUG FIXES

+ 2 - 2
src/java/org/apache/hadoop/dfs/FSEditLog.java

@@ -161,7 +161,7 @@ class FSEditLog {
    * server to exit
    */
   synchronized void processIOError(int index) throws IOException {
-    if (editStreams == null || editStreams.size() == 1) {
+    if (editStreams == null || editStreams.size() <= 1) {
       throw new IOException("Checkpoint directories inaccessible.");
     }
     assert(index < getNumStorageDirs());
@@ -630,7 +630,7 @@ class FSEditLog {
         //
         getEditFile(idx).delete();
         if (!getEditNewFile(idx).renameTo(getEditFile(idx))) {
-          processIOError(idx); 
+          fsimage.processIOError(idx); 
           idx--; 
         }
       }

+ 1 - 1
src/java/org/apache/hadoop/dfs/FSImage.java

@@ -446,7 +446,7 @@ class FSImage extends Storage {
   void processIOError(int index) throws IOException {
     int nrDirs = getNumStorageDirs();
     assert(index >= 0 && index < nrDirs);
-    if (nrDirs == 1)
+    if (nrDirs <= 1)
       throw new IOException("Checkpoint directories inaccessible.");
     storageDirs.remove(index);
   }

+ 10 - 2
src/test/org/apache/hadoop/dfs/TestCheckpoint.java

@@ -173,8 +173,16 @@ public class TestCheckpoint extends TestCase {
       assertFalse(image.getEditNewFile(idx).exists());
       File edits = image.getEditFile(idx);
       assertTrue(edits.exists()); // edits should exist and be empty
-      assertTrue(
-        (new RandomAccessFile(edits, "r")).length() == Integer.SIZE/Byte.SIZE);
+      long editsLen = -1;
+      RandomAccessFile eF = null;
+      try {
+        eF = new RandomAccessFile(edits, "r");
+        editsLen = eF.length();
+      } finally {
+        if(eF != null)
+          eF.close();
+      }
+      assertTrue(editsLen == Integer.SIZE/Byte.SIZE);
     }
     
     fileSys = cluster.getFileSystem();