hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sur...@apache.org
Subject svn commit: r1131288 - in /hadoop/common/branches/yahoo-merge: ./ src/contrib/ec2/ src/docs/ src/java/ src/java/org/apache/hadoop/fs/ src/java/org/apache/hadoop/fs/shell/ src/java/org/apache/hadoop/fs/viewfs/ src/test/core/ src/test/core/org/apache/had...
Date Fri, 03 Jun 2011 23:35:23 GMT
Author: suresh
Date: Fri Jun  3 23:35:23 2011
New Revision: 1131288

URL: http://svn.apache.org/viewvc?rev=1131288&view=rev
Log:
Merging r1129989 for HADOOP-7284 from trunk

Added:
    hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/fs/viewfs/TestViewFsTrash.java
      - copied unchanged from r1129989, hadoop/common/trunk/src/test/core/org/apache/hadoop/fs/viewfs/TestViewFsTrash.java
Modified:
    hadoop/common/branches/yahoo-merge/   (props changed)
    hadoop/common/branches/yahoo-merge/CHANGES.txt   (contents, props changed)
    hadoop/common/branches/yahoo-merge/src/contrib/ec2/   (props changed)
    hadoop/common/branches/yahoo-merge/src/docs/   (props changed)
    hadoop/common/branches/yahoo-merge/src/java/   (props changed)
    hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/Trash.java
    hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/shell/Delete.java
    hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/viewfs/ChRootedFileSystem.java
    hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/viewfs/ConfigUtil.java
    hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/viewfs/Constants.java
    hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/viewfs/InodeTree.java
    hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java
    hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/viewfs/ViewFs.java
    hadoop/common/branches/yahoo-merge/src/test/core/   (props changed)
    hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/fs/TestTrash.java
    hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/fs/viewfs/TestChRootedFileSystem.java
    hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/fs/viewfs/TestChRootedFs.java
    hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/fs/viewfs/TestFSMainOperationsLocalFileSystem.java
    hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/fs/viewfs/ViewFileSystemTestSetup.java

Propchange: hadoop/common/branches/yahoo-merge/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jun  3 23:35:23 2011
@@ -1,2 +1,2 @@
-/hadoop/common/trunk:1038480,1038493,1043117,1076296,1078148,1080396,1081598,1082329,1082787-1082788,1084415,1084769,1085043,1085122,1086309,1087159,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,1095761,1096522,1096988,1099612,1099633,1100026,1100356,1100369,1100400,1101132,1101199,1101653,1102012,1102068,1102093,1102861,1102940,1103968,1104426,1127591,1130833
+/hadoop/common/trunk:1038480,1038493,1043117,1076296,1078148,1080396,1081598,1082329,1082787-1082788,1084415,1084769,1085043,1085122,1086309,1087159,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,1095761,1096522,1096988,1099612,1099633,1100026,1100356,1100369,1100400,1101132,1101199,1101653,1102012,1102068,1102093,1102861,1102940,1103968,1104426,1127591,1129989,1130833
 /hadoop/core/branches/branch-0.19/core:713112

Modified: hadoop/common/branches/yahoo-merge/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/yahoo-merge/CHANGES.txt?rev=1131288&r1=1131287&r2=1131288&view=diff
==============================================================================
--- hadoop/common/branches/yahoo-merge/CHANGES.txt (original)
+++ hadoop/common/branches/yahoo-merge/CHANGES.txt Fri Jun  3 23:35:23 2011
@@ -124,6 +124,8 @@ Trunk (unreleased changes)
     HADOOP-7336. TestFileContextResolveAfs will fail with default 
     test.build.data property. (jitendra)
 
+    HADOOP-7284 Trash and shell's rm does not work for viewfs (Sanjay Radia)
+
 Release 0.22.0 - Unreleased
 
   INCOMPATIBLE CHANGES

Propchange: hadoop/common/branches/yahoo-merge/CHANGES.txt
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jun  3 23:35:23 2011
@@ -1,4 +1,4 @@
-/hadoop/common/trunk/CHANGES.txt:1038480,1038493,1043117,1076296,1078148,1080396,1081598,1082329,1082787-1082788,1084415,1084769,1085043,1085122,1086309,1087159,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1092832,1094750,1095121,1095761,1096522,1096988,1099612,1099633,1100026,1100356,1100369,1100400,1101132,1101199,1101653,1102012,1102068,1102093,1102861,1102940,1103968,1104426,1127591,1129905,1130833
+/hadoop/common/trunk/CHANGES.txt:1038480,1038493,1043117,1076296,1078148,1080396,1081598,1082329,1082787-1082788,1084415,1084769,1085043,1085122,1086309,1087159,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1092832,1094750,1095121,1095761,1096522,1096988,1099612,1099633,1100026,1100356,1100369,1100400,1101132,1101199,1101653,1102012,1102068,1102093,1102861,1102940,1103968,1104426,1127591,1129905,1129989,1130833
 /hadoop/core/branches/branch-0.18/CHANGES.txt:727226
 /hadoop/core/branches/branch-0.19/CHANGES.txt:713112
 /hadoop/core/trunk/CHANGES.txt:776175-785643,785929-786278

Propchange: hadoop/common/branches/yahoo-merge/src/contrib/ec2/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jun  3 23:35:23 2011
@@ -1,3 +1,3 @@
-/hadoop/common/trunk/src/contrib/ec2:1038480,1038493,1043117,1076296,1078148,1081598,1082329,1082787-1082788,1084415,1084769,1085043,1085122,1086309,1087159,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,1095761,1096522,1096988,1099612,1099633,1100026,1100356,1100369,1100400,1101132,1101199,1101653,1102012,1102068,1102093,1102861,1102940,1103968,1104426,1127591,1130833
+/hadoop/common/trunk/src/contrib/ec2:1038480,1038493,1043117,1076296,1078148,1081598,1082329,1082787-1082788,1084415,1084769,1085043,1085122,1086309,1087159,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,1095761,1096522,1096988,1099612,1099633,1100026,1100356,1100369,1100400,1101132,1101199,1101653,1102012,1102068,1102093,1102861,1102940,1103968,1104426,1127591,1129989,1130833
 /hadoop/core/branches/branch-0.19/core/src/contrib/ec2:713112
 /hadoop/core/trunk/src/contrib/ec2:776175-784663

Propchange: hadoop/common/branches/yahoo-merge/src/docs/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jun  3 23:35:23 2011
@@ -1,2 +1,2 @@
-/hadoop/common/trunk/src/docs:1038480,1038493,1043117,1076296,1078148,1080396,1081598,1082329,1082787-1082788,1084415,1084769,1085043,1085122,1086309,1087159,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,1095761,1096522,1096988,1099612,1099633,1100026,1100356,1100369,1100400,1101132,1101199,1101653,1102012,1102068,1102093,1102861,1102940,1103968,1104426,1127591,1130833
+/hadoop/common/trunk/src/docs:1038480,1038493,1043117,1076296,1078148,1080396,1081598,1082329,1082787-1082788,1084415,1084769,1085043,1085122,1086309,1087159,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,1095761,1096522,1096988,1099612,1099633,1100026,1100356,1100369,1100400,1101132,1101199,1101653,1102012,1102068,1102093,1102861,1102940,1103968,1104426,1127591,1129989,1130833
 /hadoop/core/branches/branch-0.19/src/docs:713112

Propchange: hadoop/common/branches/yahoo-merge/src/java/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jun  3 23:35:23 2011
@@ -1,3 +1,3 @@
-/hadoop/common/trunk/src/java:1038480,1038493,1043117,1076296,1078148,1080396,1081598,1082329,1082787-1082788,1084415,1084769,1085043,1085122,1086309,1087159,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,1095761,1096522,1096988,1099612,1099633,1100026,1100356,1100369,1100400,1101132,1101199,1101653,1102012,1102068,1102093,1102861,1102940,1103968,1104426,1127591,1130833
+/hadoop/common/trunk/src/java:1038480,1038493,1043117,1076296,1078148,1080396,1081598,1082329,1082787-1082788,1084415,1084769,1085043,1085122,1086309,1087159,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,1095761,1096522,1096988,1099612,1099633,1100026,1100356,1100369,1100400,1101132,1101199,1101653,1102012,1102068,1102093,1102861,1102940,1103968,1104426,1127591,1129989,1130833
 /hadoop/core/branches/branch-0.19/core/src/java:713112
 /hadoop/core/trunk/src/core:776175-785643,785929-786278

Modified: hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/Trash.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/Trash.java?rev=1131288&r1=1131287&r2=1131288&view=diff
==============================================================================
--- hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/Trash.java (original)
+++ hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/Trash.java Fri Jun  3
23:35:23 2011
@@ -17,6 +17,11 @@
  */
 package org.apache.hadoop.fs;
 
+import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.FS_TRASH_CHECKPOINT_INTERVAL_DEFAULT;
+import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.FS_TRASH_CHECKPOINT_INTERVAL_KEY;
+import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.FS_TRASH_INTERVAL_DEFAULT;
+import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.FS_TRASH_INTERVAL_KEY;
+
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.text.DateFormat;
@@ -30,7 +35,6 @@ import org.apache.hadoop.classification.
 import org.apache.hadoop.classification.InterfaceStability;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configured;
-import static org.apache.hadoop.fs.CommonConfigurationKeys.*;
 import org.apache.hadoop.fs.permission.FsAction;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.util.StringUtils;
@@ -103,7 +107,12 @@ public class Trash extends Configured {
       Configuration conf) throws IOException {
     Path fullyResolvedPath = fs.resolvePath(p);
     Trash trash = new Trash(FileSystem.get(fullyResolvedPath.toUri(), conf), conf);
-    return trash.moveToTrash(fullyResolvedPath);
+    boolean success =  trash.moveToTrash(fullyResolvedPath);
+    if (success) {
+      System.out.println("Moved: '" + p + "' to trash at: " +
+          trash.getCurrentTrashDir() );
+    }
+    return success;
   }
   
   private Trash(Path home, Configuration conf) throws IOException {
@@ -141,7 +150,7 @@ public class Trash extends Configured {
     if (!fs.exists(path))                         // check that path exists
       throw new FileNotFoundException(path.toString());
 
-    String qpath = path.makeQualified(fs).toString();
+    String qpath = fs.makeQualified(path).toString();
 
     if (qpath.startsWith(trash.toString())) {
       return false;                               // already in trash

Modified: hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/shell/Delete.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/shell/Delete.java?rev=1131288&r1=1131287&r2=1131288&view=diff
==============================================================================
--- hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/shell/Delete.java (original)
+++ hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/shell/Delete.java Fri
Jun  3 23:35:23 2011
@@ -74,7 +74,6 @@ class Delete extends FsCommand {
       // etc), then the path will just be deleted because moveToTrash returns
       // false and it falls thru to fs.delete.  this doesn't seem right
       if (moveToTrash(item)) {
-        out.println("Moved to trash: " + item);
         return;
       }
       if (!item.fs.delete(item.path, deleteDirs)) {
@@ -86,8 +85,7 @@ class Delete extends FsCommand {
     private boolean moveToTrash(PathData item) throws IOException {
       boolean success = false;
       if (!skipTrash) {
-        Trash trash = new Trash(item.fs, getConf());
-        success = (trash.isEnabled() && trash.moveToTrash(item.path));
+        success = Trash.moveToAppropriateTrash(item.fs, item.path, getConf());
       }
       return success;
     }

Modified: hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/viewfs/ChRootedFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/viewfs/ChRootedFileSystem.java?rev=1131288&r1=1131287&r2=1131288&view=diff
==============================================================================
--- hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/viewfs/ChRootedFileSystem.java
(original)
+++ hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/viewfs/ChRootedFileSystem.java
Fri Jun  3 23:35:23 2011
@@ -116,8 +116,7 @@ class ChRootedFileSystem extends FileSys
           chRootPathPart.toString().substring(1));
 
     workingDir = getHomeDirectory();
-    // We don't use the wd of the myFs,  (lets set it to root anyway)
-    myFs.setWorkingDirectory(chRootPathPart);
+    // We don't use the wd of the myFs
   }
   
   /** 

Modified: hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/viewfs/ConfigUtil.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/viewfs/ConfigUtil.java?rev=1131288&r1=1131287&r2=1131288&view=diff
==============================================================================
--- hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/viewfs/ConfigUtil.java
(original)
+++ hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/viewfs/ConfigUtil.java
Fri Jun  3 23:35:23 2011
@@ -67,4 +67,51 @@ public class ConfigUtil {
     addLink( conf, Constants.CONFIG_VIEWFS_DEFAULT_MOUNT_TABLE, 
         src, target);   
   }
+  
+  /**
+   * Add config variable for homedir for default mount table
+   * @param conf - add to this conf
+   * @param homedir - the home dir path starting with slash
+   */
+  public static void setHomeDirConf(final Configuration conf,
+      final String homedir) {
+    setHomeDirConf(  conf,
+        Constants.CONFIG_VIEWFS_DEFAULT_MOUNT_TABLE,   homedir);
+  }
+  
+  /**
+   * Add config variable for homedir the specified mount table
+   * @param conf - add to this conf
+   * @param homedir - the home dir path starting with slash
+   */
+  public static void setHomeDirConf(final Configuration conf,
+              final String mountTableName, final String homedir) {
+    if (!homedir.startsWith("/")) {
+      throw new IllegalArgumentException("Home dir should start with /:"
+          + homedir);
+    }
+    conf.set(getConfigViewFsPrefix(mountTableName) + "." +
+        Constants.CONFIG_VIEWFS_HOMEDIR, homedir);
+  }
+  
+  /**
+   * Get the value of the home dir conf value for default mount table
+   * @param conf - from this conf
+   * @return home dir value, null if variable is not in conf
+   */
+  public static String getHomeDirValue(final Configuration conf) {
+    return getHomeDirValue(conf, Constants.CONFIG_VIEWFS_DEFAULT_MOUNT_TABLE);
+  }
+  
+  /**
+   * Get the value of the home dir conf value for specfied mount table
+   * @param conf - from this conf
+   * @param mountTableName - the mount table
+   * @return home dir value, null if variable is not in conf
+   */
+  public static String getHomeDirValue(final Configuration conf, 
+      final String mountTableName) {
+    return conf.get(getConfigViewFsPrefix(mountTableName) + "." +
+        Constants.CONFIG_VIEWFS_HOMEDIR);
+  }
 }

Modified: hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/viewfs/Constants.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/viewfs/Constants.java?rev=1131288&r1=1131287&r2=1131288&view=diff
==============================================================================
--- hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/viewfs/Constants.java
(original)
+++ hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/viewfs/Constants.java
Fri Jun  3 23:35:23 2011
@@ -30,6 +30,12 @@ public interface Constants {
    * Prefix for the config variable prefix for the ViewFs mount-table
    */
   public static final String CONFIG_VIEWFS_PREFIX = "fs.viewfs.mounttable";
+ 
+  /**
+   * Prefix for the home dir for the mount table - if not specified
+   * then the hadoop default value (/user) is used.
+   */
+  public static final String CONFIG_VIEWFS_HOMEDIR = "homedir";
   
   /**
    * Config variable name for the default mount table.

Modified: hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/viewfs/InodeTree.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/viewfs/InodeTree.java?rev=1131288&r1=1131287&r2=1131288&view=diff
==============================================================================
--- hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/viewfs/InodeTree.java
(original)
+++ hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/viewfs/InodeTree.java
Fri Jun  3 23:35:23 2011
@@ -62,6 +62,8 @@ abstract class InodeTree<T> {
   
   final INodeDir<T> root; // the root of the mount table
   
+  final String homedirPrefix; // the homedir config value for this mount table
+  
   List<MountPoint<T>> mountPoints = new ArrayList<MountPoint<T>>();
   
   
@@ -298,6 +300,7 @@ abstract class InodeTree<T> {
     if (vName == null) {
       vName = Constants.CONFIG_VIEWFS_DEFAULT_MOUNT_TABLE;
     }
+    homedirPrefix = ConfigUtil.getHomeDirValue(config, vName);
     root = new INodeDir<T>("/", UserGroupInformation.getCurrentUser());
     root.InodeDirFs = getTargetFileSystem(root);
     root.isRoot = true;
@@ -319,6 +322,9 @@ abstract class InodeTree<T> {
         } else if (src.startsWith(linkMergePrefix)) { // A merge link
           isMergeLink = true;
           src = src.substring(linkMergePrefix.length());
+        } else if (src.startsWith(Constants.CONFIG_VIEWFS_HOMEDIR)) {
+          // ignore - we set home dir from config
+          continue;
         } else {
           throw new IOException(
           "ViewFs: Cannot initialize: Invalid entry in Mount table in config: "+ 
@@ -442,4 +448,13 @@ abstract class InodeTree<T> {
   List<MountPoint<T>> getMountPoints() { 
     return mountPoints;
   }
+  
+  /**
+   * 
+   * @return home dir value from mount table; null if no config value
+   * was found.
+   */
+  String getHomeDirPrefixValue() {
+    return homedirPrefix;
+  }
 }

Modified: hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java?rev=1131288&r1=1131287&r2=1131288&view=diff
==============================================================================
--- hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java
(original)
+++ hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java
Fri Jun  3 23:35:23 2011
@@ -90,6 +90,7 @@ public class ViewFileSystem extends File
   private Path workingDir;
   Configuration config;
   InodeTree<FileSystem> fsState;  // the fs state; ie the mount table
+  Path homeDir = null;
   
   /**
    * Prohibits names which contain a ".", "..", ":" or "/" 
@@ -157,8 +158,6 @@ public class ViewFileSystem extends File
     final String authority = theUri.getAuthority();
     try {
       myUri = new URI(FsConstants.VIEWFS_SCHEME, authority, "/", null, null);
-      workingDir =
-        this.makeQualified(new Path("/user/" + ugi.getShortUserName()));
       fsState = new InodeTree<FileSystem>(conf, authority) {
 
         @Override
@@ -184,6 +183,7 @@ public class ViewFileSystem extends File
           // return MergeFs.createMergeFs(mergeFsURIList, config);
         }
       };
+      workingDir = this.getHomeDirectory();
     } catch (URISyntaxException e) {
       throw new IOException("URISyntax exception: " + theUri);
     }
@@ -235,6 +235,19 @@ public class ViewFileSystem extends File
   }
   
   @Override
+  public Path getHomeDirectory() {
+    if (homeDir == null) {
+      String base = fsState.getHomeDirPrefixValue();
+      if (base == null) {
+        base = "/user";
+      }
+      homeDir = 
+        this.makeQualified(new Path(base + "/" + ugi.getShortUserName()));
+    }
+    return homeDir;
+  }
+  
+  @Override
   public Path getWorkingDirectory() {
     return workingDir;
   }

Modified: hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/viewfs/ViewFs.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/viewfs/ViewFs.java?rev=1131288&r1=1131287&r2=1131288&view=diff
==============================================================================
--- hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/viewfs/ViewFs.java (original)
+++ hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/viewfs/ViewFs.java Fri
Jun  3 23:35:23 2011
@@ -146,6 +146,7 @@ public class ViewFs extends AbstractFile
   final UserGroupInformation ugi; // the user/group of user who created mtable
   final Configuration config;
   InodeTree<AbstractFileSystem> fsState;  // the fs state; ie the mount table
+  Path homeDir = null;
   
   static AccessControlException readOnlyMountTable(final String operation,
       final String p) {
@@ -235,6 +236,19 @@ public class ViewFs extends AbstractFile
   }
  
   @Override
+  public Path getHomeDirectory() {
+    if (homeDir == null) {
+      String base = fsState.getHomeDirPrefixValue();
+      if (base == null) {
+        base = "/user";
+      }
+      homeDir = 
+        this.makeQualified(new Path(base + "/" + ugi.getShortUserName()));
+    }
+    return homeDir;
+  }
+  
+  @Override
   public Path resolvePath(final Path f) throws FileNotFoundException,
           AccessControlException, UnresolvedLinkException, IOException {
     final InodeTree.ResolveResult<AbstractFileSystem> res;

Propchange: hadoop/common/branches/yahoo-merge/src/test/core/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jun  3 23:35:23 2011
@@ -1,3 +1,3 @@
-/hadoop/common/trunk/src/test/core:1038480,1038493,1043117,1076296,1078148,1080396,1081598,1082329,1082787-1082788,1084415,1084769,1085043,1085122,1086309,1087159,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,1095761,1096522,1096988,1099612,1099633,1100026,1100356,1100369,1100400,1101132,1101199,1101653,1102012,1102068,1102093,1102861,1102940,1103968,1104426,1127591,1130833
+/hadoop/common/trunk/src/test/core:1038480,1038493,1043117,1076296,1078148,1080396,1081598,1082329,1082787-1082788,1084415,1084769,1085043,1085122,1086309,1087159,1087844,1090039,1090485,1091618,1091902,1091970,1092519,1092565,1094750,1095121,1095761,1096522,1096988,1099612,1099633,1100026,1100356,1100369,1100400,1101132,1101199,1101653,1102012,1102068,1102093,1102861,1102940,1103968,1104426,1127591,1129989,1130833
 /hadoop/core/branches/branch-0.19/core/src/test/core:713112
 /hadoop/core/trunk/src/test/core:776175-785643,785929-786278

Modified: hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/fs/TestTrash.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/fs/TestTrash.java?rev=1131288&r1=1131287&r2=1131288&view=diff
==============================================================================
--- hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/fs/TestTrash.java (original)
+++ hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/fs/TestTrash.java Fri
Jun  3 23:35:23 2011
@@ -24,7 +24,6 @@ import java.io.DataOutputStream;
 import java.io.File;
 import java.io.IOException;
 import java.net.URI;
-import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -57,10 +56,10 @@ public class TestTrash extends TestCase 
   }
 
   // check that the specified file is in Trash
-  protected static void checkTrash(FileSystem fs, Path trashRoot,
+  protected static void checkTrash(FileSystem trashFs, Path trashRoot,
       Path path) throws IOException {
     Path p = new Path(trashRoot+"/"+ path.toUri().getPath());
-    assertTrue(fs.exists(p));
+    assertTrue("Could not find file in trash: "+ p , trashFs.exists(p));
   }
   
   // counts how many instances of the file are in the Trash
@@ -89,11 +88,33 @@ public class TestTrash extends TestCase 
     Path p = new Path(trashRoot+"/"+ new Path(pathname).getName());
     assertTrue(!fs.exists(p));
   }
-
+  
+  /**
+   * Test trash for the shell's delete command for the file system fs
+   * @param fs
+   * @param base - the base path where files are created
+   * @throws IOException
+   */
   protected static void trashShell(final FileSystem fs, final Path base)
-      throws IOException {
+  throws IOException {
     Configuration conf = new Configuration();
-    conf.set("fs.default.name", fs.getUri().toString());
+    conf.set("fs.defaultFS", fs.getUri().toString());
+    trashShell(conf, base, null, null);
+  }
+
+  /**
+   * 
+   * Test trash for the shell's delete command for the default file system
+   * specified in the paramter conf
+   * @param conf 
+   * @param base - the base path where files are created
+   * @param trashRoot - the expected place where the trashbin resides
+   * @throws IOException
+   */
+  public static void trashShell(final Configuration conf, final Path base,
+      FileSystem trashRootFs, Path trashRoot)
+      throws IOException {
+    FileSystem fs = FileSystem.get(conf);
 
     conf.set(FS_TRASH_INTERVAL_KEY, "0"); // disabled
     assertFalse(new Trash(conf).isEnabled());
@@ -103,7 +124,12 @@ public class TestTrash extends TestCase 
 
     FsShell shell = new FsShell();
     shell.setConf(conf);
-    Path trashRoot = null;
+    if (trashRoot == null) {
+      trashRoot = shell.getCurrentTrashDir();
+    }
+    if (trashRootFs == null) {
+      trashRootFs = fs;
+    }
 
     // First create a new directory with mkdirs
     Path myPath = new Path(base, "test/mkdirs");
@@ -143,8 +169,8 @@ public class TestTrash extends TestCase 
       }
       assertTrue(val == 0);
 
-      trashRoot = shell.getCurrentTrashDir();
-      checkTrash(fs, trashRoot, myFile);
+ 
+      checkTrash(trashRootFs, trashRoot, fs.makeQualified(myFile));
     }
 
     // Verify that we can recreate the file
@@ -206,7 +232,7 @@ public class TestTrash extends TestCase 
     {
         Path toErase = new Path(trashRoot, "toErase");
         int retVal = -1;
-        writeFile(fs, toErase);
+        writeFile(trashRootFs, toErase);
         try {
           retVal = shell.run(new String[] {"-rm", toErase.toString()});
         } catch (Exception e) {
@@ -214,8 +240,8 @@ public class TestTrash extends TestCase 
                              e.getLocalizedMessage());
         }
         assertTrue(retVal == 0);
-        checkNotInTrash (fs, trashRoot, toErase.toString());
-        checkNotInTrash (fs, trashRoot, toErase.toString()+".1");
+        checkNotInTrash (trashRootFs, trashRoot, toErase.toString());
+        checkNotInTrash (trashRootFs, trashRoot, toErase.toString()+".1");
     }
 
     // simulate Trash removal
@@ -233,7 +259,7 @@ public class TestTrash extends TestCase 
     }
 
     // verify that after expunging the Trash, it really goes away
-    checkNotInTrash(fs, trashRoot, new Path(base, "test/mkdirs/myFile").toString());
+    checkNotInTrash(trashRootFs, trashRoot, new Path(base, "test/mkdirs/myFile").toString());
 
     // recreate directory and file
     mkdir(fs, myPath);
@@ -252,7 +278,7 @@ public class TestTrash extends TestCase 
                            e.getLocalizedMessage());
       }
       assertTrue(val == 0);
-      checkTrash(fs, trashRoot, myFile);
+      checkTrash(trashRootFs, trashRoot, myFile);
 
       args = new String[2];
       args[0] = "-rmr";
@@ -265,7 +291,7 @@ public class TestTrash extends TestCase 
                            e.getLocalizedMessage());
       }
       assertTrue(val == 0);
-      checkTrash(fs, trashRoot, myPath);
+      checkTrash(trashRootFs, trashRoot, myPath);
     }
 
     // attempt to remove parent of trash
@@ -281,7 +307,7 @@ public class TestTrash extends TestCase 
                            e.getLocalizedMessage());
       }
       assertEquals("exit code", 1, val);
-      assertTrue(fs.exists(trashRoot));
+      assertTrue(trashRootFs.exists(trashRoot));
     }
     
     // Verify skip trash option really works
@@ -299,7 +325,8 @@ public class TestTrash extends TestCase 
       int val = -1;
       try {
         // Clear out trash
-        assertEquals(0, shell.run(new String [] { "-expunge" } ));
+        assertEquals("-expunge failed", 
+            0, shell.run(new String [] { "-expunge" } ));
         
         val = shell.run(args);
         
@@ -307,7 +334,10 @@ public class TestTrash extends TestCase 
         System.err.println("Exception raised from Trash.run " +
             e.getLocalizedMessage());
       }
-      assertFalse(fs.exists(trashRoot)); // No new Current should be created
+      assertFalse("Expected TrashRoot (" + trashRoot + 
+          ") to exist in file system:"
+          + trashRootFs.getUri(), 
+          trashRootFs.exists(trashRoot)); // No new Current should be created
       assertFalse(fs.exists(myFile));
       assertTrue(val == 0);
     }
@@ -335,7 +365,7 @@ public class TestTrash extends TestCase 
             e.getLocalizedMessage());
       }
 
-      assertFalse(fs.exists(trashRoot)); // No new Current should be created
+      assertFalse(trashRootFs.exists(trashRoot)); // No new Current should be created
       assertFalse(fs.exists(myPath));
       assertFalse(fs.exists(myFile));
       assertTrue(val == 0);
@@ -420,7 +450,7 @@ public class TestTrash extends TestCase 
   public void testNonDefaultFS() throws IOException {
     Configuration conf = new Configuration();
     conf.setClass("fs.file.impl", TestLFS.class, FileSystem.class);
-    conf.set("fs.default.name", "invalid://host/bar/foo");
+    conf.set("fs.defaultFS", "invalid://host/bar/foo");
     trashNonDefaultFS(conf);
   }
   
@@ -438,7 +468,7 @@ public class TestTrash extends TestCase 
     emptierThread.start();
 
     FileSystem fs = FileSystem.getLocal(conf);
-    conf.set("fs.default.name", fs.getUri().toString());
+    conf.set("fs.defaultFS", fs.getUri().toString());
     FsShell shell = new FsShell();
     shell.setConf(conf);
     shell.init();
@@ -521,7 +551,7 @@ public class TestTrash extends TestCase 
     conf.setClass("fs.file.impl", TestLFS.class, FileSystem.class);
     FileSystem fs = FileSystem.getLocal(conf);
     
-    conf.set("fs.default.name", fs.getUri().toString());
+    conf.set("fs.defaultFS", fs.getUri().toString());
     conf.set(FS_TRASH_INTERVAL_KEY, "10"); //minutes..
     FsShell shell = new FsShell();
     shell.setConf(conf);

Modified: hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/fs/viewfs/TestChRootedFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/fs/viewfs/TestChRootedFileSystem.java?rev=1131288&r1=1131287&r2=1131288&view=diff
==============================================================================
--- hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/fs/viewfs/TestChRootedFileSystem.java
(original)
+++ hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/fs/viewfs/TestChRootedFileSystem.java
Fri Jun  3 23:35:23 2011
@@ -17,6 +17,7 @@
  */
 package org.apache.hadoop.fs.viewfs;
 
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.net.URI;
 
@@ -287,5 +288,21 @@ public class TestChRootedFileSystem {
     Assert.assertEquals(absoluteDir, fSys.getWorkingDirectory());
 
   }
- 
+  
+  /*
+   * Test resolvePath(p) 
+   */
+  
+  @Test
+  public void testResolvePath() throws IOException {
+    Assert.assertEquals(chrootedTo, fSys.resolvePath(new Path("/"))); 
+    FileSystemTestHelper.createFile(fSys, "/foo");
+    Assert.assertEquals(new Path(chrootedTo, "foo"),
+        fSys.resolvePath(new Path("/foo"))); 
+  }
+
+  @Test(expected=FileNotFoundException.class) 
+  public void testResolvePathNonExisting() throws IOException {
+      fSys.resolvePath(new Path("/nonExisting"));
+  }
 }

Modified: hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/fs/viewfs/TestChRootedFs.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/fs/viewfs/TestChRootedFs.java?rev=1131288&r1=1131287&r2=1131288&view=diff
==============================================================================
--- hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/fs/viewfs/TestChRootedFs.java
(original)
+++ hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/fs/viewfs/TestChRootedFs.java
Fri Jun  3 23:35:23 2011
@@ -17,6 +17,7 @@
  */
 package org.apache.hadoop.fs.viewfs;
 
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.net.URI;
 import java.util.EnumSet;
@@ -288,5 +289,22 @@ public class TestChRootedFs {
     Assert.assertEquals(absoluteDir, fc.getWorkingDirectory());
 
   }
+  
+  /*
+   * Test resolvePath(p) 
+   */
+  
+  @Test
+  public void testResolvePath() throws IOException {
+    Assert.assertEquals(chrootedTo, fc.getDefaultFileSystem().resolvePath(new Path("/")));

+    FileContextTestHelper.createFile(fc, "/foo");
+    Assert.assertEquals(new Path(chrootedTo, "foo"),
+        fc.getDefaultFileSystem().resolvePath(new Path("/foo"))); 
+  }
+
+  @Test(expected=FileNotFoundException.class) 
+  public void testResolvePathNonExisting() throws IOException {
+      fc.getDefaultFileSystem().resolvePath(new Path("/nonExisting"));
+  }
  
 }

Modified: hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/fs/viewfs/TestFSMainOperationsLocalFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/fs/viewfs/TestFSMainOperationsLocalFileSystem.java?rev=1131288&r1=1131287&r2=1131288&view=diff
==============================================================================
--- hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/fs/viewfs/TestFSMainOperationsLocalFileSystem.java
(original)
+++ hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/fs/viewfs/TestFSMainOperationsLocalFileSystem.java
Fri Jun  3 23:35:23 2011
@@ -37,7 +37,8 @@ public class TestFSMainOperationsLocalFi
   public void setUp() throws Exception {
     Configuration conf = new Configuration();
     fcTarget = FileSystem.getLocal(conf);
-    fSys = ViewFileSystemTestSetup.setupForViewFs(fcTarget);
+    fSys = ViewFileSystemTestSetup.setupForViewFs(
+        ViewFileSystemTestSetup.configWithViewfsScheme(), fcTarget);
     super.setUp();
   }
   

Modified: hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/fs/viewfs/ViewFileSystemTestSetup.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/fs/viewfs/ViewFileSystemTestSetup.java?rev=1131288&r1=1131287&r2=1131288&view=diff
==============================================================================
--- hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/fs/viewfs/ViewFileSystemTestSetup.java
(original)
+++ hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/fs/viewfs/ViewFileSystemTestSetup.java
Fri Jun  3 23:35:23 2011
@@ -32,7 +32,8 @@ import org.apache.hadoop.fs.viewfs.Confi
  * If tests launched via ant (build.xml) the test root is absolute path
  * If tests launched via eclipse, the test root is 
  * is a test dir below the working directory. (see FileSystemTestHelper).
- * Since viewFs has no built-in wd, its wd is /user/<username>.
+ * Since viewFs has no built-in wd, its wd is /user/<username> 
+ *          (or /User/<username> on mac)
  * 
  * We set a viewFileSystems with mount point for 
  * /<firstComponent>" pointing to the target fs's  testdir 
@@ -45,32 +46,28 @@ public class ViewFileSystemTestSetup {
    * @return return the ViewFS File context to be used for tests
    * @throws Exception
    */
-  static public FileSystem setupForViewFs(FileSystem fsTarget) throws Exception {
+  static public FileSystem setupForViewFs(Configuration conf, FileSystem fsTarget) throws
Exception {
     /**
      * create the test root on local_fs - the  mount table will point here
      */
-    Configuration conf = configWithViewfsScheme();
     Path targetOfTests = FileSystemTestHelper.getTestRootPath(fsTarget);
     // In case previous test was killed before cleanup
     fsTarget.delete(targetOfTests, true);
     
     fsTarget.mkdirs(targetOfTests);
   
-    String srcTestFirstDir;
-    if (FileSystemTestHelper.TEST_ROOT_DIR.startsWith("/")) {
-      int indexOf2ndSlash = FileSystemTestHelper.TEST_ROOT_DIR.indexOf('/', 1);
-      srcTestFirstDir = FileSystemTestHelper.TEST_ROOT_DIR.substring(0, indexOf2ndSlash);
-    } else {
-      srcTestFirstDir = "/user"; 
-  
-    }
-    //System.out.println("srcTestFirstDir=" + srcTestFirstDir);
-  
-    // Set up the defaultMT in the config with mount point links
-    // The test dir is root is below  /user/<userid>
 
-    ConfigUtil.addLink(conf, srcTestFirstDir,
-        targetOfTests.toUri());
+    // Now set up a link from viewfs to targetfs for the first component of
+    // path of testdir. For example, if testdir is /user/<userid>/xx then
+    // a link from /user to targetfs://user.
+    
+    String testDir = FileSystemTestHelper.getTestRootPath(fsTarget).toUri().getPath();
+    int indexOf2ndSlash = testDir.indexOf('/', 1);
+    String testDirFirstComponent = testDir.substring(0, indexOf2ndSlash);
+    
+    
+    ConfigUtil.addLink(conf, testDirFirstComponent,
+        fsTarget.makeQualified(new Path(testDirFirstComponent)).toUri()); 
     
     FileSystem fsView = FileSystem.get(FsConstants.VIEWFS_URI, conf);
     //System.out.println("SRCOfTests = "+ getTestRootPath(fs, "test"));



Mime
View raw message