Issue Details (XML | Word | Printable)

Key: HADOOP-1647
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Blocker Blocker
Assignee: dhruba borthakur
Reporter: Enis Soztutar
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Hadoop Common

DistributedFileSystem.getFileStatus() fails for path "/"

Created: 23/Jul/07 02:37 PM   Updated: 08/Jul/09 04:42 PM
Return to search
Component/s: None
Affects Version/s: 0.14.0, 0.15.0
Fix Version/s: 0.14.0

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works fileStatus3.patch 2007-07-31 06:43 PM dhruba borthakur 5 kB
Text File Licensed for inclusion in ASF works getFileStatusJavadoc.patch 2007-07-26 08:05 AM Enis Soztutar 0.5 kB
Issue Links:
Blocker
 
Dependants
 

Resolution Date: 31/Jul/07 07:17 PM


 Description  « Hide
DistributedFileSystem#getFileStatus throws the following exception when invoked with new Path("/"). LocalFileSystem does not. The code to produce this error is
public static void main(String[] args) throws Exception{
    Configuration conf = new Configuration();
    FileSystem fs = FileSystem.get(conf);
    Path path = new Path("/");
    System.out.println("Path : \"" + path.toString() + "\"");
    System.out.println(fs.isDirectory(path));
    System.out.println(fs.getFileStatus(path).isDir()); 
  }

for Local configuration the code prints :

Path : "/"
true
true

For a new formatted dfs with only one file /user/enis/file.txt, Path could not be created.

Path : "/"
false
Exception in thread "main" org.apache.hadoop.ipc.RemoteException: java.io.IOException: java.lang.IllegalArgumentException: Can not create a Path from an empty string
        at org.apache.hadoop.fs.Path.checkPathArg(Path.java:82)
        at org.apache.hadoop.fs.Path.<init>(Path.java:90)
        at org.apache.hadoop.dfs.DFSFileInfo.<init>(DFSFileInfo.java:59)
        at org.apache.hadoop.dfs.FSDirectory.getFileInfo(FSDirectory.java:729)
        at org.apache.hadoop.dfs.FSNamesystem.getFileInfo(FSNamesystem.java:1301)
        at org.apache.hadoop.dfs.NameNode.getFileInfo(NameNode.java:488)
        at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.hadoop.ipc.RPC$Server.call(RPC.java:340)
        at org.apache.hadoop.ipc.Server$Handler.run(Server.java:566)

        at org.apache.hadoop.ipc.Client.call(Client.java:470)
        at org.apache.hadoop.ipc.RPC$Invoker.invoke(RPC.java:165)
        at org.apache.hadoop.dfs.$Proxy0.getFileInfo(Unknown Source)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.hadoop.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:82)
        at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:59)
        at org.apache.hadoop.dfs.$Proxy0.getFileInfo(Unknown Source)
        at org.apache.hadoop.dfs.DFSClient.getFileInfo(DFSClient.java:430)
        at org.apache.hadoop.dfs.DistributedFileSystem.getFileStatus(DistributedFileSystem.java:319)
        at org.apache.hadoop.util.TestIsDir.main(TestIsDir.java:38)


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
dhruba borthakur added a comment - 25/Jul/07 10:53 PM
This patch returns "/" as the name of rootDir.

Enis Soztutar added a comment - 26/Jul/07 05:10 AM
Well, i had also fixed this, but haven't time to upload it smile
dhruba, why not we change only, in INode#computeName()
if (parent != null) {
         return parent.computeName() + "/" + name;
       } else {
-        return name;
+        return "/";
       }
     }

Enis Soztutar added a comment - 26/Jul/07 05:52 AM
It will be good if this patch is applied to 0.14 also.

Enis Soztutar added a comment - 26/Jul/07 08:05 AM
One line patch for slightly annoying javadoc.

Enis Soztutar added a comment - 26/Jul/07 12:58 PM
It seems that my version of the patch INode#computeName() fails other unit tests. I guess the root node is not the only one with parent being null.

dhruba borthakur added a comment - 26/Jul/07 05:21 PM
Hi Enis, i think ur patch might cause problems in some other areas. Especially if u rin the unit tests. Please let me know if my patch fixes your problem.

dhruba borthakur added a comment - 26/Jul/07 11:10 PM
I am marking this as a blocker so that it gets into 0.14.

Raghu Angadi added a comment - 26/Jul/07 11:23 PM
I am curious how Enis' patch above is functionally different? Is there any case where rootDir has non null parent?

Raghu Angadi added a comment - 31/Jul/07 12:37 AM
+1. As Dhruba pointed on hadoop-dev, Enis' patch results in "//root/dir1/dir2" (extra '/').

dhruba borthakur added a comment - 31/Jul/07 07:37 AM
Attach patch merged with latest trunk.

Raghu Angadi added a comment - 31/Jul/07 05:31 PM

This jira is marked to be in 0.14. Are you going to have another patch for 14?


Raghu Angadi added a comment - 31/Jul/07 05:50 PM
oops! HADOOP-1653 also went into 0.14.

dhruba borthakur added a comment - 31/Jul/07 05:51 PM
This patch is needed for 0.14. This patch depends on HADOOP-1653. So, HADOOP-1653 also went into 0.14.

dhruba borthakur added a comment - 31/Jul/07 06:43 PM
Raghu had an excellent review comment saying that the rootInode can be detected by comparing inode->parent == NULL rather than comparing an inode with FSDirectory.rootDir. Incorporated this change.

Raghu Angadi added a comment - 31/Jul/07 06:54 PM
+1.

dhruba borthakur added a comment - 31/Jul/07 07:17 PM
I just committed this.