hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r611333 - in /lucene/hadoop/trunk: ./ src/java/org/apache/hadoop/dfs/ src/java/org/apache/hadoop/fs/ src/test/org/apache/hadoop/dfs/
Date Fri, 11 Jan 2008 23:48:45 GMT
Author: cutting
Date: Fri Jan 11 15:48:39 2008
New Revision: 611333

URL: http://svn.apache.org/viewvc?rev=611333&view=rev
Log:
HADOOP-2567.  Add FileSystem#getHomeDirectory().

Modified:
    lucene/hadoop/trunk/CHANGES.txt
    lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DistributedFileSystem.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/FileSystem.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/FilterFileSystem.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/RawLocalFileSystem.java
    lucene/hadoop/trunk/src/test/org/apache/hadoop/dfs/TestDecommission.java

Modified: lucene/hadoop/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/CHANGES.txt?rev=611333&r1=611332&r2=611333&view=diff
==============================================================================
--- lucene/hadoop/trunk/CHANGES.txt (original)
+++ lucene/hadoop/trunk/CHANGES.txt Fri Jan 11 15:48:39 2008
@@ -41,6 +41,13 @@
     Datanode Protocol version changed from 10 to 11.  
     (Sanjay Radia via dhruba)
     
+    HADOOP-2567.  Add FileSystem#getHomeDirectory(), which returns the
+    user's home directory in a FileSystem as a fully-qualified path.
+    FileSystem#getWorkingDirectory() is also changed to return a
+    fully-qualified path, which can break applications that attempt
+    to, e.g., pass LocalFileSystem#getWorkingDir().toString() directly
+    to java.io methods that accept file names. (cutting)
+
   NEW FEATURES
 
     HADOOP-1857.  Ability to run a script when a task fails to capture stack

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DistributedFileSystem.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DistributedFileSystem.java?rev=611333&r1=611332&r2=611333&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DistributedFileSystem.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DistributedFileSystem.java Fri Jan
11 15:48:39 2008
@@ -35,8 +35,7 @@
  *
  *****************************************************************/
 public class DistributedFileSystem extends FileSystem {
-  private Path workingDir =
-    new Path("/user", System.getProperty("user.name")); 
+  private Path workingDir;
   private URI uri;
 
   DFSClient dfs;
@@ -64,6 +63,7 @@
     int port = uri.getPort();
     this.dfs = new DFSClient(new InetSocketAddress(host, port), conf);
     this.uri = URI.create("hdfs://"+host+":"+port);
+    this.workingDir = getHomeDirectory();
   }
 
   public Path getWorkingDirectory() {
@@ -87,8 +87,8 @@
   }
 
   public void setWorkingDirectory(Path dir) {
-    Path result = makeAbsolute(dir);
-    if (!FSNamesystem.isValidName(result.toString())) {
+    String result = makeAbsolute(dir).toUri().getPath();
+    if (!FSNamesystem.isValidName(result)) {
       throw new IllegalArgumentException("Invalid DFS directory name " + 
                                          result);
     }

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/FileSystem.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/FileSystem.java?rev=611333&r1=611332&r2=611333&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/FileSystem.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/FileSystem.java Fri Jan 11 15:48:39
2008
@@ -863,6 +863,15 @@
     }
   }
     
+  /** Return the current user's home directory in this filesystem.
+   * The default implementation returns "/user/$USER/".
+   */
+  public Path getHomeDirectory() {
+    return new Path("/user/"+System.getProperty("user.name"))
+      .makeQualified(this);
+  }
+
+
   /**
    * Set the current working directory for the given file system. All relative
    * paths will be resolved relative to it.

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/FilterFileSystem.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/FilterFileSystem.java?rev=611333&r1=611332&r2=611333&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/FilterFileSystem.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/FilterFileSystem.java Fri Jan 11 15:48:39
2008
@@ -152,6 +152,11 @@
     return fs.listStatus(f);
   }
   
+  public Path getHomeDirectory() {
+    return fs.getHomeDirectory();
+  }
+
+
   /**
    * Set the current working directory for the given file system. All relative
    * paths will be resolved relative to it.

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/RawLocalFileSystem.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/RawLocalFileSystem.java?rev=611333&r1=611332&r2=611333&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/RawLocalFileSystem.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/RawLocalFileSystem.java Fri Jan 11 15:48:39
2008
@@ -36,8 +36,7 @@
  *****************************************************************/
 public class RawLocalFileSystem extends FileSystem {
   static final URI NAME = URI.create("file:///");
-  private Path workingDir =
-    new Path(System.getProperty("user.dir"));
+  private Path workingDir;
   TreeMap<File, FileInputStream> sharedLockDataSet =
     new TreeMap<File, FileInputStream>();
   TreeMap<File, FileOutputStream> nonsharedLockDataSet =
@@ -46,7 +45,9 @@
   // by default use copy/delete instead of rename
   boolean useCopyForRename = true;
   
-  public RawLocalFileSystem() {}
+  public RawLocalFileSystem() {
+    workingDir = new Path(System.getProperty("user.dir")).makeQualified(this);
+  }
   
   /** Convert a path to a File. */
   public File pathToFile(Path path) {
@@ -264,6 +265,11 @@
     return b;
   }
   
+  @Override
+  public Path getHomeDirectory() {
+    return new Path(System.getProperty("user.home")).makeQualified(this);
+  }
+
   /**
    * Set the working directory to the given directory.
    */

Modified: lucene/hadoop/trunk/src/test/org/apache/hadoop/dfs/TestDecommission.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/test/org/apache/hadoop/dfs/TestDecommission.java?rev=611333&r1=611332&r2=611333&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/test/org/apache/hadoop/dfs/TestDecommission.java (original)
+++ lucene/hadoop/trunk/src/test/org/apache/hadoop/dfs/TestDecommission.java Fri Jan 11 15:48:39
2008
@@ -270,7 +270,7 @@
     assertTrue(localFileSys.mkdirs(dir));
     hostsFile = new Path(dir, "hosts");
     excludeFile = new Path(dir, "exclude");
-    conf.set("dfs.hosts.exclude", excludeFile.toString());
+    conf.set("dfs.hosts.exclude", excludeFile.toUri().getPath());
     writeConfigFile(localFileSys, excludeFile, null);
 
     MiniDFSCluster cluster = new MiniDFSCluster(conf, numDatanodes, true, null);



Mime
View raw message