[ 
https://issues.apache.org/jira/browse/HDFS-14369?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16806926#comment-16806926
 ] 

Ayush Saxena commented on HDFS-14369:
-------------------------------------

Thanx [~ajisakaa] .

Guess, It isn't covering the case where the number of trailing slashes at end 
is more than 1 (/user//// ---> Fetches in end /user/) so 1 leading slash  stays.

Checked the add mount Command part how this problem isn't there, Realized as 
part of add we call \{{normalizeFileSystemPath(mount)}} twice. Once in 
RouterAdmin L482 and once as part of newInstance L493. So in the first time 
/user/////  changes to /user/ and in the second time to /user and fetches the 
intended result.

The logic there fails due to \{{normalizePath(path)}} in Path.java. The javadoc 
of the method says it shall remove all trailing slashes.

 
{code:java}
Normalize a path string to use non-duplicated forward slashes as
   * the path separator and remove any trailing path separators.
{code}
But tends to remove only one here.
{code:java}
  path = path.substring(0, path.length()-1);
{code}
I changed this logic for testing purpose to :
{code:java}
      path = path.replaceAll("/+$", "");{code}
And the failed tests passes for me. Not sure, if we are using this utility 
correct or if there is a miss in the logic here only. Ideally I think it should 
remove all trailing slashes rather than just one as javadoc says.

Anyway if this a problem and I haven't misunderstood and  we decide to correct 
this Path problem we need to do this separately, not here in branch.

 

 

 

> RBF: Fix trailing "/" for webhdfs
> ---------------------------------
>
>                 Key: HDFS-14369
>                 URL: https://issues.apache.org/jira/browse/HDFS-14369
>             Project: Hadoop HDFS
>          Issue Type: Sub-task
>            Reporter: CR Hota
>            Assignee: Akira Ajisaka
>            Priority: Major
>         Attachments: HDFS-14369-HDFS-13891-regressiontest-001.patch, 
> HDFS-14369-HDFS-13891.001.patch, HDFS-14369-HDFS-13891.002.patch, 
> HDFS-14369-HDFS-13891.003.patch, HDFS-14369-HDFS-13891.004.patch
>
>
> WebHDFS doesn't trim trailing slash causing discrepancy in operations.
> Example below
> --------------------------
> Using HDFS API, two directory are listed.
> {code}
> $ hdfs dfs -ls hdfs://<router>:8888/tmp/
> Found 2 items
> drwxrwxrwx   - hdfs supergroup          0 2018-11-09 17:50 
> hdfs://<router>:8888/tmp/tmp1
> drwxrwxrwx   - hdfs supergroup          0 2018-11-09 17:50 
> hdfs://<router>:8888/tmp/tmp2
> {code}
> Using WebHDFS API, only one directory is listed.
> {code}
> $ curl -u : --negotiate -i 
> "http://<router>:50071/webhdfs/v1/tmp/?op=LISTSTATUS"
> (snip)
> {"FileStatuses":{"FileStatus":[
> {"accessTime":0,"blockSize":0,"childrenNum":0,"fileId":16387,"group":"supergroup","length":0,"modificationTime":1552016766769,"owner":"hdfs","pathSuffix":"tmp1","permission":"755","replication":0,"storagePolicy":0,"type":"DIRECTORY"}
> ]}}
> {code}
> The mount table is as follows:
> {code}
> $ hdfs dfsrouteradmin -ls /tmp
> Mount Table Entries:
> Source                    Destinations              Owner                     
> Group                     Mode                      Quota/Usage              
> /tmp                      ns1->/tmp                 aajisaka                  
> users                     rwxr-xr-x                 [NsQuota: -/-, SsQuota: 
> -/-]
> /tmp/tmp1                 ns1->/tmp/tmp1            aajisaka                  
> users                     rwxr-xr-x                 [NsQuota: -/-, SsQuota: 
> -/-]
> /tmp/tmp2                 ns2->/tmp/tmp2            aajisaka                  
> users                     rwxr-xr-x                 [NsQuota: -/-, SsQuota: 
> -/-]
> {code}
> Without trailing thrash, two directories are listed.
> {code}
> $ curl -u : --negotiate -i 
> "http://<router>:50071/webhdfs/v1/tmp?op=LISTSTATUS"
> (snip)
> {"FileStatuses":{"FileStatus":[
> {"accessTime":1541753421917,"blockSize":0,"childrenNum":0,"fileId":0,"group":"supergroup","length":0,"modificationTime":1541753421917,"owner":"hdfs","pathSuffix":"tmp1","permission":"777","replication":0,"storagePolicy":0,"symlink":"","type":"DIRECTORY"},
> {"accessTime":1541753429812,"blockSize":0,"childrenNum":0,"fileId":0,"group":"supergroup","length":0,"modificationTime":1541753429812,"owner":"hdfs","pathSuffix":"tmp2","permission":"777","replication":0,"storagePolicy":0,"symlink":"","type":"DIRECTORY"}
> ]}}
> {code}
> [~ajisakaa] Thanks for reporting this, I borrowed the text from 
> HDFS-13972



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to