Browse Source

HADOOP-344. Fix some Windows-related problems with DF. Contributed by Konstantin.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@425337 13f79535-47bb-0310-9956-ffa450edef68
Doug Cutting 19 years ago
parent
commit
826f7d6727

+ 3 - 0
CHANGES.txt

@@ -73,6 +73,9 @@ Trunk (unreleased changes)
     tasks whose names match a regular expression, to facilliate
     debugging.  (omalley via cutting)
 
+21. HADOOP-344.  Fix some Windows-related problems with DF.
+   (Konstantin Shvachko via cutting)
+
 
 Release 0.4.0 - 2006-06-28
 

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

@@ -213,7 +213,7 @@ class FSDataset implements FSConstants {
     public FSDataset(File dir, Configuration conf) throws IOException {
     		this.reserved = conf.getLong("dfs.datanode.du.reserved", 0);
     		this.usableDiskPct = conf.getFloat("dfs.datanode.du.pct", (float) USABLE_DISK_PCT_DEFAULT);
-        diskUsage = new DF( dir.getCanonicalPath(), conf); 
+        diskUsage = new DF( dir, conf); 
         this.data = new File(dir, "data");
         if (! data.exists()) {
             data.mkdirs();

+ 16 - 3
src/java/org/apache/hadoop/fs/DF.java

@@ -15,6 +15,7 @@
  */
 package org.apache.hadoop.fs;
 
+import java.io.File;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.BufferedReader;
@@ -39,12 +40,24 @@ public class DF {
   private int percentUsed;
   private String mount;
   
+  /** @deprecated
+   */
   public DF(String path, Configuration conf ) throws IOException {
-    this( path, conf.getLong( "dfs.df.interval", DF.DF_INTERVAL_DEFAULT ));
+    this( new File(path), conf );
   }
 
+  /** @deprecated
+   */
   public DF(String path, long dfInterval) throws IOException {
-    this.dirPath = path;
+    this( new File(path), dfInterval );
+  }
+  
+  public DF(File path, Configuration conf ) throws IOException {
+    this( path, conf.getLong( "dfs.df.interval", DF.DF_INTERVAL_DEFAULT ));
+  }
+
+  public DF(File path, long dfInterval) throws IOException {
+    this.dirPath = path.getCanonicalPath();
     this.dfInterval = dfInterval;
     lastDF = ( dfInterval < 0 ) ? 0 : -dfInterval;
     this.doDF();
@@ -145,6 +158,6 @@ public class DF {
     if( args.length > 0 )
       path = args[0];
 
-    System.out.println(new DF(path, DF_INTERVAL_DEFAULT).toString());
+    System.out.println(new DF(new File(path), DF_INTERVAL_DEFAULT).toString());
   }
 }

+ 1 - 1
src/java/org/apache/hadoop/fs/LocalFileSystem.java

@@ -345,7 +345,7 @@ public class LocalFileSystem extends FileSystem {
         File f = pathToFile(p).getCanonicalFile();
       
         // find highest writable parent dir of f on the same device
-        String device = new DF(f.toString(), getConf()).getMount();
+        String device = new DF(f, getConf()).getMount();
         File parent = f.getParentFile();
         File dir;
         do {

+ 1 - 1
src/java/org/apache/hadoop/mapred/TaskTracker.java

@@ -544,7 +544,7 @@ public class TaskTracker
         if (localDirsDf.containsKey(localDirs[i])) {
           df = (DF) localDirsDf.get(localDirs[i]);
         } else {
-          df = new DF(localDirs[i], fConf);
+          df = new DF(new File(localDirs[i]), fConf);
           localDirsDf.put(localDirs[i], df);
         }