Преглед на файлове

DFS re-format should fully delete old namenode data.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@390498 13f79535-47bb-0310-9956-ffa450edef68
Doug Cutting преди 19 години
родител
ревизия
1740f0b0d4
променени са 2 файла, в които са добавени 8 реда и са изтрити 3 реда
  1. 7 2
      src/java/org/apache/hadoop/dfs/FSDirectory.java
  2. 1 1
      src/java/org/apache/hadoop/dfs/NameNode.java

+ 7 - 2
src/java/org/apache/hadoop/dfs/FSDirectory.java

@@ -20,6 +20,9 @@ import org.apache.hadoop.io.*;
 import java.io.*;
 import java.util.*;
 
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileUtil;
+
 /*************************************************
  * FSDirectory stores the filesystem directory state.
  * It handles writing/loading values to disk, and logging
@@ -265,13 +268,15 @@ class FSDirectory implements FSConstants {
 
     /** Create a new dfs name directory.  Caution: this destroys all files
      * in this filesystem. */
-    public static void format(File dir) throws IOException {
+    public static void format(File dir, Configuration conf)
+      throws IOException {
         File image = new File(dir, "image");
         File edits = new File(dir, "edits");
 
-        if (!((!image.exists() || image.delete()) &&
+        if (!((!image.exists() || FileUtil.fullyDelete(image, conf)) &&
               (!edits.exists() || edits.delete()) &&
               image.mkdirs())) {
+          
           throw new IOException("Unable to format: "+dir);
         }
     }

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

@@ -68,7 +68,7 @@ public class NameNode implements ClientProtocol, DatanodeProtocol, FSConstants {
     /** Format a new filesystem.  Destroys any filesystem that may already
      * exist at this location.  **/
     public static void format(Configuration conf) throws IOException {
-      FSDirectory.format(getDir(conf));
+      FSDirectory.format(getDir(conf), conf);
     }
 
     /**