Uploaded image for project: 'Hadoop HDFS'
  1. Hadoop HDFS
  2. HDFS-836

Make dot a valid HDFS path?

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Resolved
    • Major
    • Resolution: Later
    • None
    • None
    • None
    • None

    Description

      What do people think of making "." a valid path in HDFS? The motivation is to allow users to create symlinks to the current directory in HDFS-245, eg see the following test for the current behavior:

        @Test
        /** Test create symlink to . */
        public void testCreateLinkToDot() throws IOException {
          Path dir  = new Path("/test");
          Path link = new Path("/test/linkToDot");
          fc.mkdir(dir, FileContext.DEFAULT_PERM, true);        
          fc.setWorkingDirectory(dir);
          try {
            fc.createSymlink(new Path("."), link);
            fail("Created symlink to dot");
            readFile(new Path("/test/linkToDot/file"));
          } catch (IOException x) {
            // Expected. Path(".") resolves to "" because URI normalizes
            // the dot away and AbstractFileSystem considers "" invalid.  
          }
          fc.delete(dir, true);
        }
      

      This involves trade offs since Hadoop Paths represent URIs (rather than the path component of a URI) and in URIs dot normalizes away. Some options:

      1. Make symlinks to "." an exception per the above, though it seems odd to consider ".", "..", "/" etc invalid paths (and the latter two happen to work based on how the Path constructor initializes the URI even though isValidName in AbstractFileSystem would consider them invalid names.
      2. Making "." immediately parse to an absolute path would be poor symlink semantics (eg a link to "." should not break if you rename the link's parent directory).
      3. Making Path special case this so "." doesn't normalize away would be a weird one off case where Path and URIs differ.

      Other alternatives? Of the above I'd prefer the last one.

      Attachments

        1. hdfs-836-1.patch
          0.6 kB
          Eli Collins

        Activity

          People

            Unassigned Unassigned
            eli Eli Collins
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: