hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r501942 - in /lucene/hadoop/trunk: CHANGES.txt src/java/org/apache/hadoop/dfs/FSEditLog.java src/java/org/apache/hadoop/dfs/FSImage.java src/java/org/apache/hadoop/dfs/NameNode.java
Date Wed, 31 Jan 2007 18:47:53 GMT
Author: cutting
Date: Wed Jan 31 10:47:53 2007
New Revision: 501942

URL: http://svn.apache.org/viewvc?view=rev&rev=501942
Log:
HADOOP-959.  Fix namenode snapshot code added in HADOOP-227 to work on Windows.  Contributed
by Dhruba.

Modified:
    lucene/hadoop/trunk/CHANGES.txt
    lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSEditLog.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSImage.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/NameNode.java

Modified: lucene/hadoop/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/CHANGES.txt?view=diff&rev=501942&r1=501941&r2=501942
==============================================================================
--- lucene/hadoop/trunk/CHANGES.txt (original)
+++ lucene/hadoop/trunk/CHANGES.txt Wed Jan 31 10:47:53 2007
@@ -105,6 +105,9 @@
 32. HADOOP-961.  Add a 'job -events' sub-command that prints job
     events, including task completions and failures.  (omalley via cutting)
 
+33. HADOOP-959.  Fix namenode snapshot code added in HADOOP-227 to
+    work on Windows.  (Dhruba Borthakur via cutting)
+
 
 Release 0.10.1 - 2007-01-10
 

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSEditLog.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSEditLog.java?view=diff&rev=501942&r1=501941&r2=501942
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSEditLog.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSEditLog.java Wed Jan 31 10:47:53
2007
@@ -131,7 +131,7 @@
    * server to exit
    */
    void processIOError(int index) throws IOException {
-     if (editStreams.length == 1) {
+     if (editStreams == null || editStreams.length == 1) {
        throw new IOException("Checkpoint directories inaccessible.");
      }
      assert(index < editFiles.length);
@@ -590,8 +590,15 @@
     //
     for (int idx = 0; idx < editFiles.length; idx++ ) {
       if (!editFilesNew[idx].renameTo(editFiles[idx])) {
-        processIOError(idx); 
-        idx--; 
+        //
+        // renameTo() fails on Windows if the destination
+        // file exists.
+        //
+        editFiles[idx].delete();
+        if (!editFilesNew[idx].renameTo(editFiles[idx])) {
+          processIOError(idx); 
+          idx--; 
+        }
       }
     }
     //

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSImage.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSImage.java?view=diff&rev=501942&r1=501941&r2=501942
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSImage.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSImage.java Wed Jan 31 10:47:53 2007
@@ -174,11 +174,15 @@
           // shutdown. The fsimage.ckpt was created and the edits.new
           // file was moved to edits. We complete that checkpoint by
           // moving fsimage.new to fsimage. There is no need to 
-          // update the fstime file here.
+          // update the fstime file here. renameTo fails on Windows
+          // if the destination file already exists.
           //
           if (!ckptFile.renameTo(curFile)) {
-            throw new IOException("Unable to rename " + ckptFile +
-                                  " to " + curFile);
+            curFile.delete();
+            if (!ckptFile.renameTo(curFile)) {
+              throw new IOException("Unable to rename " + ckptFile +
+                                    " to " + curFile);
+            }
           }
         }
       }
@@ -480,9 +484,14 @@
                            NameNodeFile.CKPT.getName());
       File curFile = new File(imageDirs[idx], 
                               NameNodeFile.IMAGE.getName());
+      // renameTo fails on Windows if the destination file 
+      // already exists.
       if (!ckpt.renameTo(curFile)) {
-        editLog.processIOError(idx);
-        idx--;
+        curFile.delete();
+        if (!ckpt.renameTo(curFile)) {
+          editLog.processIOError(idx);
+          idx--;
+        }
       }
     }
 

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/NameNode.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/NameNode.java?view=diff&rev=501942&r1=501941&r2=501942
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/NameNode.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/NameNode.java Wed Jan 31 10:47:53 2007
@@ -95,6 +95,7 @@
       FSImage fsimage = new FSImage(dirs);
       FSNamesystem namesystem = new FSNamesystem(fsimage);
       fsimage.create();
+      fsimage.getEditLog().close();
     }
 
     /** Format a new filesystem.  Destroys any filesystem that may already
@@ -106,6 +107,7 @@
       FSImage fsimage = new FSImage(dirs);
       FSNamesystem namesystem = new FSNamesystem(fsimage);
       fsimage.create();
+      fsimage.getEditLog().close();
     }
 
     private class NameNodeMetrics {



Mime
View raw message