Uploaded image for project: 'Hadoop Common'
  1. Hadoop Common
  2. HADOOP-18444

Add Support for localized trash for ViewFileSystem in Trash.moveToAppropriateTrash

    XMLWordPrintableJSON

Details

    • Reviewed

    Description

      Trash.moveToAppropriateTrash is used by hadoop cli -rm and hive, to move files to trash. However, its current implementation does not support localized trash policy we added to ViewFileSystem in HADOOP-18144.

      The reason is in moveToAppropriateTrash, it first resolves a path and then uses the resolvedFs, to initialize the trash. As a result, it uses getTrashRoot() implementation from targetFs, not ViewFileSystem. The new localized trash policy we implemented in ViewFileSystem is not invoked.

      With the new localized trash policy for ViewFileSystem, the trash root would be local to a mount point, thus, for ViewFileSystem with this flag turned on, there is no need to resolve the path in moveToAppropriateTrash. Rename in ViewFileSystem can resolve the logical paths correctly and be able to move a file to trash within a mount point. 

      Code section of current moveToAppropriateTrash implementation.

      public static boolean moveToAppropriateTrash(FileSystem fs, Path p,
          Configuration conf) throws IOException {
        Path fullyResolvedPath = fs.resolvePath(p);
        FileSystem fullyResolvedFs =
            FileSystem.get(fullyResolvedPath.toUri(), conf);
        ...
        Trash trash = new Trash(fullyResolvedFs, conf);
        return trash.moveToTrash(fullyResolvedPath);
      }

      Attachments

        Issue Links

          Activity

            People

              xinglin Xing Lin
              xinglin Xing Lin
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: