[
https://issues.apache.org/jira/browse/HDFS-13622?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16548303#comment-16548303
]
Siyao Meng edited comment on HDFS-13622 at 7/18/18 7:49 PM:
------------------------------------------------------------
Thanks [~shwetayakkali] for the patch.
The current patch [^HDFS-13622.02.patch] will work for "hdfs dfs -mkdir
/testParent/testChild", when "/testParent" directory doesn't exist, it would
return:
{code:java}
mkdir: `/testParent': No such file or directory
{code}
However, for "hdfs dfs -mkdir /testParent/testChild1/testChild2", when
"/testParent" directory doesn't exist, it would return:
{code:java}
mkdir: `/testParent/testChild1': No such file or directory{code}
It implies that "/testParent" exists, which is still a bit counterintuitive.
In my opinion, it should also return:
{code:java}
mkdir: `/testParent': No such file or directory{code}
My implementation of processNonexistentPath() based on [^HDFS-13622.02.patch]
that solves the problem above would be:
{code:java}
@Override
protected void processNonexistentPath(PathData item) throws IOException {
if (!createParents){
Path itemPath = new Path(item.path.toString());
Path itemParentPath = itemPath.getParent();
while (!item.fs.exists(itemParentPath)) {
itemPath = itemParentPath;
itemParentPath = itemParentPath.getParent();
}
throw new PathNotFoundException(itemPath.toString());
}
if (!item.fs.mkdirs(item.path)) {
throw new PathIOException(item.toString());
}
}
{code}
I hope this helps. :)
was (Author: smeng):
Thanks [~shwetayakkali] for the patch.
The current patch [^HDFS-13622.02.patch] will work for "hdfs dfs -mkdir
/testParent/testChild", when "/testParent" directory doesn't exist, it would
return:
{code:java}
mkdir: `/testParent': No such file or directory
{code}
However, for "hdfs dfs -mkdir /testParent/testChild1/testChild2", when
"/testParent" directory doesn't exist, it would return:
{code:java}
mkdir: `/testParent/testChild1': No such file or directory{code}
It implies that "/testParent" exists, which is still a bit counterintuitive.
In my opinion, it should also return:
{code:java}
mkdir: `/testParent': No such file or directory{code}
> dfs mkdir should not report the directory which to be created
> -------------------------------------------------------------
>
> Key: HDFS-13622
> URL: https://issues.apache.org/jira/browse/HDFS-13622
> Project: Hadoop HDFS
> Issue Type: Bug
> Reporter: Zoltan Haindrich
> Assignee: Shweta
> Priority: Major
> Attachments: HDFS-13622.02.patch
>
>
> this is a bit misleading:
> {code}
> $ hdfs dfs -mkdir /nonexistent/newdir
> mkdir: `/nonexistent/newdir': No such file or directory
> {code}
> I think this command should fail because "nonexistent" doesn't exists...
> the correct would be:
> {code}
> $ hdfs dfs -mkdir /nonexistent/newdir
> mkdir: `/nonexistent': No such file or directory
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]